Added headless-gl and a sample test. Working on macOS
This commit is contained in:
Родитель
55d51bd84f
Коммит
3142412509
|
@ -75,6 +75,7 @@
|
|||
"@rollup/plugin-babel": "^5.3.1",
|
||||
"@rollup/plugin-image": "^3.0.2",
|
||||
"@types/babel__core": "^7.20.1",
|
||||
"@types/jsdom": "^21.1.7",
|
||||
"@types/lodash-es": "4.17.12",
|
||||
"@types/three": "^0.136.0",
|
||||
"@typescript-eslint/eslint-plugin": "^7.12.0",
|
||||
|
@ -83,6 +84,7 @@
|
|||
"core-js": "^3.21.1",
|
||||
"eslint": "^9.4.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"gl": "8.0.2",
|
||||
"jsdom": "^24.0.0",
|
||||
"prettier": "^2.5.1",
|
||||
"regenerator-runtime": "^0.13.7",
|
||||
|
|
|
@ -321,12 +321,13 @@ export default class SpeckleRenderer {
|
|||
this.viewer = viewer
|
||||
}
|
||||
|
||||
public create(container: HTMLElement) {
|
||||
public create(container: HTMLElement, gl?: WebGLRenderingContext) {
|
||||
this._renderer = new SpeckleWebGLRenderer({
|
||||
antialias: true,
|
||||
alpha: true,
|
||||
preserveDrawingBuffer: true,
|
||||
stencil: true
|
||||
stencil: true,
|
||||
context: gl
|
||||
})
|
||||
this._renderer.setClearColor(0xffffff, 0)
|
||||
this._renderer.setPixelRatio(window.devicePixelRatio)
|
||||
|
|
|
@ -139,7 +139,8 @@ export class Viewer extends EventEmitter implements IViewer {
|
|||
|
||||
public constructor(
|
||||
container: HTMLElement,
|
||||
params: ViewerParams = DefaultViewerParams
|
||||
params: ViewerParams = DefaultViewerParams,
|
||||
gl?: WebGLRenderingContext
|
||||
) {
|
||||
super()
|
||||
Logger.useDefaults()
|
||||
|
@ -157,7 +158,7 @@ export class Viewer extends EventEmitter implements IViewer {
|
|||
this.inProgressOperations = 0
|
||||
|
||||
this.speckleRenderer = new SpeckleRenderer(this.tree, this)
|
||||
this.speckleRenderer.create(this.container)
|
||||
this.speckleRenderer.create(this.container, gl)
|
||||
window.addEventListener('resize', this.resize.bind(this), false)
|
||||
|
||||
this.propertyManager = new PropertyManager()
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
import { test } from 'vitest'
|
||||
import { JSDOM } from 'jsdom'
|
||||
import { Viewer } from '../src'
|
||||
|
||||
test('Viewer', async () => {
|
||||
const width = 64
|
||||
const height = 64
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const gl = require('gl')(width, height, { preserveDrawingBuffer: true })
|
||||
gl
|
||||
const dom = new JSDOM(`<!DOCTYPE html><p>Hello world</p>`)
|
||||
const viewer = new Viewer(dom.window.document.createElement('div'), undefined, gl)
|
||||
console.warn(viewer)
|
||||
})
|
123
yarn.lock
123
yarn.lock
|
@ -16020,6 +16020,7 @@ __metadata:
|
|||
"@speckle/shared": "workspace:^"
|
||||
"@types/babel__core": "npm:^7.20.1"
|
||||
"@types/flat": "npm:^5.0.2"
|
||||
"@types/jsdom": "npm:^21.1.7"
|
||||
"@types/lodash-es": "npm:4.17.12"
|
||||
"@types/three": "npm:^0.136.0"
|
||||
"@typescript-eslint/eslint-plugin": "npm:^7.12.0"
|
||||
|
@ -16029,6 +16030,7 @@ __metadata:
|
|||
eslint: "npm:^9.4.0"
|
||||
eslint-config-prettier: "npm:^9.1.0"
|
||||
flat: "npm:^5.0.2"
|
||||
gl: "npm:8.0.2"
|
||||
js-logger: "npm:1.6.1"
|
||||
jsdom: "npm:^24.0.0"
|
||||
lodash-es: "npm:^4.17.21"
|
||||
|
@ -18647,6 +18649,17 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@types/jsdom@npm:^21.1.7":
|
||||
version: 21.1.7
|
||||
resolution: "@types/jsdom@npm:21.1.7"
|
||||
dependencies:
|
||||
"@types/node": "npm:*"
|
||||
"@types/tough-cookie": "npm:*"
|
||||
parse5: "npm:^7.0.0"
|
||||
checksum: 10/a5ee54aec813ac928ef783f69828213af4d81325f584e1fe7573a9ae139924c40768d1d5249237e62d51b9a34ed06bde059c86c6b0248d627457ec5e5d532dfa
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@types/json-schema@npm:*, @types/json-schema@npm:^7.0.5, @types/json-schema@npm:^7.0.8, @types/json-schema@npm:^7.0.9":
|
||||
version: 7.0.11
|
||||
resolution: "@types/json-schema@npm:7.0.11"
|
||||
|
@ -23939,7 +23952,7 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"bindings@npm:^1.4.0":
|
||||
"bindings@npm:^1.4.0, bindings@npm:^1.5.0":
|
||||
version: 1.5.0
|
||||
resolution: "bindings@npm:1.5.0"
|
||||
dependencies:
|
||||
|
@ -23976,6 +23989,13 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"bit-twiddle@npm:^1.0.2":
|
||||
version: 1.0.2
|
||||
resolution: "bit-twiddle@npm:1.0.2"
|
||||
checksum: 10/9fec3df5608a5625ab0dfd221a1755f54cbd541032f1930522221fa445814218ffd15c0af0e22487cf258dcc012f4a81b6aa30e308e58e4f06192c4f148ff1f9
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"bl@npm:>=1.2.3":
|
||||
version: 6.0.3
|
||||
resolution: "bl@npm:6.0.3"
|
||||
|
@ -31568,6 +31588,21 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"gl@npm:8.0.2":
|
||||
version: 8.0.2
|
||||
resolution: "gl@npm:8.0.2"
|
||||
dependencies:
|
||||
bindings: "npm:^1.5.0"
|
||||
bit-twiddle: "npm:^1.0.2"
|
||||
glsl-tokenizer: "npm:^2.1.5"
|
||||
nan: "npm:^2.18.0"
|
||||
node-abi: "npm:^3.56.0"
|
||||
node-gyp: "npm:^10.0.1"
|
||||
prebuild-install: "npm:^7.1.1"
|
||||
checksum: 10/4309dae00d48e76bb010d6a0134dceb91a3de54ae996d784e80a11f06977206e4d30d7ffb1dbb9cdca0c82c09de326d79bf1caa7f5d5d2483d10eddcca85cc86
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"glob-parent@npm:^5.1.2, glob-parent@npm:~5.1.2":
|
||||
version: 5.1.2
|
||||
resolution: "glob-parent@npm:5.1.2"
|
||||
|
@ -31989,6 +32024,15 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"glsl-tokenizer@npm:^2.1.5":
|
||||
version: 2.1.5
|
||||
resolution: "glsl-tokenizer@npm:2.1.5"
|
||||
dependencies:
|
||||
through2: "npm:^0.6.3"
|
||||
checksum: 10/e76b62667182a2f31686a28f10e86b76bab46369f2923da0862a3c7772271889b34cc9cd3fe490b478c8ca303993c067d9d5f6d594d40ef2e8cf1d7f4e13a42c
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"google-auth-library@npm:^8.9.0":
|
||||
version: 8.9.0
|
||||
resolution: "google-auth-library@npm:8.9.0"
|
||||
|
@ -39373,6 +39417,15 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"node-abi@npm:^3.56.0":
|
||||
version: 3.65.0
|
||||
resolution: "node-abi@npm:3.65.0"
|
||||
dependencies:
|
||||
semver: "npm:^7.3.5"
|
||||
checksum: 10/2b58813cfdd816b9f08e901179270fb6e916bd529ca1de2fc8d088787fea5affbb093fc8e783ccfd09a7464186a7f48079f5f92f14126fb04ceec74e0eab06d2
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"node-abort-controller@npm:^3.0.1":
|
||||
version: 3.0.1
|
||||
resolution: "node-abort-controller@npm:3.0.1"
|
||||
|
@ -39562,6 +39615,26 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"node-gyp@npm:^10.0.1":
|
||||
version: 10.1.0
|
||||
resolution: "node-gyp@npm:10.1.0"
|
||||
dependencies:
|
||||
env-paths: "npm:^2.2.0"
|
||||
exponential-backoff: "npm:^3.1.1"
|
||||
glob: "npm:^10.3.10"
|
||||
graceful-fs: "npm:^4.2.6"
|
||||
make-fetch-happen: "npm:^13.0.0"
|
||||
nopt: "npm:^7.0.0"
|
||||
proc-log: "npm:^3.0.0"
|
||||
semver: "npm:^7.3.5"
|
||||
tar: "npm:^6.1.2"
|
||||
which: "npm:^4.0.0"
|
||||
bin:
|
||||
node-gyp: bin/node-gyp.js
|
||||
checksum: 10/89e105e495e66cd4568af3cf79cdeb67d670eb069e33163c7781d3366470a30367c9bd8dea59e46db16370020139e5bf78b1fbc03284cb571754dfaa59744db5
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"node-gyp@npm:^9.0.0":
|
||||
version: 9.3.1
|
||||
resolution: "node-gyp@npm:9.3.1"
|
||||
|
@ -44434,6 +44507,18 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"readable-stream@npm:>=1.0.33-1 <1.1.0-0, readable-stream@npm:~1.0.26, readable-stream@npm:~1.0.26-4":
|
||||
version: 1.0.34
|
||||
resolution: "readable-stream@npm:1.0.34"
|
||||
dependencies:
|
||||
core-util-is: "npm:~1.0.0"
|
||||
inherits: "npm:~2.0.1"
|
||||
isarray: "npm:0.0.1"
|
||||
string_decoder: "npm:~0.10.x"
|
||||
checksum: 10/20537fca5a8ffd4af0f483be1cce0e981ed8cbb1087e0c762e2e92ae77f1005627272cebed8422f28047b465056aa1961fefd24baf532ca6a3616afea6811ae0
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"readable-stream@npm:^1.0.26-4":
|
||||
version: 1.1.14
|
||||
resolution: "readable-stream@npm:1.1.14"
|
||||
|
@ -44508,18 +44593,6 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"readable-stream@npm:~1.0.26, readable-stream@npm:~1.0.26-4":
|
||||
version: 1.0.34
|
||||
resolution: "readable-stream@npm:1.0.34"
|
||||
dependencies:
|
||||
core-util-is: "npm:~1.0.0"
|
||||
inherits: "npm:~2.0.1"
|
||||
isarray: "npm:0.0.1"
|
||||
string_decoder: "npm:~0.10.x"
|
||||
checksum: 10/20537fca5a8ffd4af0f483be1cce0e981ed8cbb1087e0c762e2e92ae77f1005627272cebed8422f28047b465056aa1961fefd24baf532ca6a3616afea6811ae0
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"readable-stream@npm:~2.3.6":
|
||||
version: 2.3.8
|
||||
resolution: "readable-stream@npm:2.3.8"
|
||||
|
@ -48496,6 +48569,16 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"through2@npm:^0.6.3":
|
||||
version: 0.6.5
|
||||
resolution: "through2@npm:0.6.5"
|
||||
dependencies:
|
||||
readable-stream: "npm:>=1.0.33-1 <1.1.0-0"
|
||||
xtend: "npm:>=4.0.0 <4.1.0-0"
|
||||
checksum: 10/37571f0bd4fa3d22f421ecf27af4c4b5eee34f350e6ca81d1a748dc09e0ede589a88248497d5bb2855c61a583a8e0dc9cd751e71c130040fceb19f778d43503d
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"through2@npm:^2.0.3":
|
||||
version: 2.0.5
|
||||
resolution: "through2@npm:2.0.5"
|
||||
|
@ -52712,6 +52795,13 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"xtend@npm:>=4.0.0 <4.1.0-0, xtend@npm:^4.0.0, xtend@npm:^4.0.2, xtend@npm:~4.0.1":
|
||||
version: 4.0.2
|
||||
resolution: "xtend@npm:4.0.2"
|
||||
checksum: 10/ac5dfa738b21f6e7f0dd6e65e1b3155036d68104e67e5d5d1bde74892e327d7e5636a076f625599dc394330a731861e87343ff184b0047fef1360a7ec0a5a36a
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"xtend@npm:^2.2.0":
|
||||
version: 2.2.0
|
||||
resolution: "xtend@npm:2.2.0"
|
||||
|
@ -52719,13 +52809,6 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"xtend@npm:^4.0.0, xtend@npm:^4.0.2, xtend@npm:~4.0.1":
|
||||
version: 4.0.2
|
||||
resolution: "xtend@npm:4.0.2"
|
||||
checksum: 10/ac5dfa738b21f6e7f0dd6e65e1b3155036d68104e67e5d5d1bde74892e327d7e5636a076f625599dc394330a731861e87343ff184b0047fef1360a7ec0a5a36a
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"xtend@npm:~2.0.4":
|
||||
version: 2.0.6
|
||||
resolution: "xtend@npm:2.0.6"
|
||||
|
|
Загрузка…
Ссылка в новой задаче