From 052056ed2ec7a281f87dd2b8cb0664464b6bd962 Mon Sep 17 00:00:00 2001 From: Aki Rodic Date: Fri, 23 Feb 2024 14:04:20 +0100 Subject: [PATCH] Removed renderer. --- build/elements/iconset.js | 8 +- build/elements/renderer.d.ts | 23 -- build/elements/renderer.d.ts.map | 1 - build/elements/renderer.js | 130 --------- build/elements/renderer.js.map | 1 - build/elements/viewport.d.ts | 12 +- build/elements/viewport.d.ts.map | 2 +- build/elements/viewport.js | 438 +++++++++++++++++++++--------- build/elements/viewport.js.map | 2 +- build/index.d.ts | 2 - build/index.d.ts.map | 2 +- build/index.js | 6 +- build/index.js.map | 2 +- build/rigs/lightProbeRig.d.ts | 11 - build/rigs/lightProbeRig.d.ts.map | 1 - build/rigs/lightProbeRig.js | 28 -- build/rigs/lightProbeRig.js.map | 1 - src/elements/renderer.ts | 136 ---------- src/elements/viewport.ts | 111 +++++++- src/index.ts | 4 +- 20 files changed, 432 insertions(+), 489 deletions(-) delete mode 100644 build/elements/renderer.d.ts delete mode 100644 build/elements/renderer.d.ts.map delete mode 100644 build/elements/renderer.js delete mode 100644 build/elements/renderer.js.map delete mode 100644 build/rigs/lightProbeRig.d.ts delete mode 100644 build/rigs/lightProbeRig.d.ts.map delete mode 100644 build/rigs/lightProbeRig.js delete mode 100644 build/rigs/lightProbeRig.js.map delete mode 100644 src/elements/renderer.ts diff --git a/build/elements/iconset.js b/build/elements/iconset.js index 34e0c65..039ccb5 100644 --- a/build/elements/iconset.js +++ b/build/elements/iconset.js @@ -1,5 +1,6 @@ import { IoIconsetSingleton } from 'io-gui'; -IoIconsetSingleton.registerIcons('three', /* html */ ` + +IoIconsetSingleton.registerIcons( 'three', /* html */ ` -`); -//# sourceMappingURL=iconset.js.map \ No newline at end of file +` ); + +//# sourceMappingURL=iconset.js.map diff --git a/build/elements/renderer.d.ts b/build/elements/renderer.d.ts deleted file mode 100644 index e4d9486..0000000 --- a/build/elements/renderer.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { WebGLRenderer } from "three"; -import { IoElement } from "io-gui"; -export declare class ThreeRenderer extends IoElement { - static get Style(): string; - _ctx: CanvasRenderingContext2D; - static get Properties(): { - ishost: { - type: BooleanConstructor; - }; - size: number[]; - tabindex: number; - clearColor: number; - clearAlpha: number; - }; - static get Listeners(): { - dragstart: string; - }; - get renderer(): WebGLRenderer; - constructor(properties?: Record); - setHost(): void; - onResized(): void; -} -//# sourceMappingURL=renderer.d.ts.map \ No newline at end of file diff --git a/build/elements/renderer.d.ts.map b/build/elements/renderer.d.ts.map deleted file mode 100644 index 5b60e97..0000000 --- a/build/elements/renderer.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/elements/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AACpC,OAAO,EAAC,SAAS,EAAoB,MAAM,QAAQ,CAAC;AA2CpD,qBAAa,aAAc,SAAQ,SAAS;IAC1C,MAAM,KAAK,KAAK,WA+Bf;IACD,IAAI,EAAE,wBAAwB,CAAC;IAC/B,MAAM,KAAK,UAAU;;;;;;;;MAWpB;IACD,MAAM,KAAK,SAAS;;MAInB;IACD,IAAI,QAAQ,kBAEX;gBACW,UAAU,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;IAMhD,OAAO;IAqBP,SAAS;CAQV"} \ No newline at end of file diff --git a/build/elements/renderer.js b/build/elements/renderer.js deleted file mode 100644 index 76ffc36..0000000 --- a/build/elements/renderer.js +++ /dev/null @@ -1,130 +0,0 @@ -import { WebGLRenderer } from "three"; -import { IoElement, RegisterIoElement } from "io-gui"; -const renderer = new WebGLRenderer({ antialias: false, preserveDrawingBuffer: true, alpha: true }); -const gl = renderer.getContext(); -renderer.domElement.className = 'canvas3d'; -renderer.shadowMap.enabled = true; -renderer.setClearColor(0x000000, 1.0); -renderer.autoClear = false; -let host; -let perfNow = 0; -let perfDelta = 1000; -let perfAverage = 1000; -let perfWarned; -const _performanceCheck = function () { - if (perfWarned) - return; - perfDelta = performance.now() - perfNow; - perfAverage = Math.min((perfAverage * 10 + perfDelta) / 11, 1000); - perfNow = performance.now(); - if (perfAverage < 16) { - console.warn('ThreeRenderer performance warning: rendering multiple canvases!'); - perfWarned = true; - } -}; -const renderedQueue = []; -const renderNextQueue = []; -const animate = function () { - for (let i = 0; i < renderedQueue.length; i++) - renderedQueue[i].rendered = false; - renderedQueue.length = 0; - for (let i = 0; i < renderNextQueue.length; i++) { - renderNextQueue[i].scheduled = false; - renderNextQueue[i].render(); - } - renderNextQueue.length = 0; - requestAnimationFrame(animate); -}; -requestAnimationFrame(animate); -export class ThreeRenderer extends IoElement { - static get Style() { - return /* css */ ` - :host { - display: block; - overflow: hidden; - position: relative; - touch-action: none; - user-select: none; - box-sizing: border-box; - flex: 1 1 auto; - } - :host:focus > canvas { - outline: var(--io-border-width) solid var(--io-color-focus); - outline-offset: calc(var(--io-border-width) * -1); - } - :host > canvas { - position: absolute; - top: 0; - left: 0; - pointer-events: none; - image-rendering: optimizeSpeed; /* Older versions of FF */ - image-rendering: -moz-crisp-edges; /* FF 6.0+ */ - image-rendering: -webkit-optimize-contrast; /* Safari */ - image-rendering: -o-crisp-edges; /* OS X & Windows Opera (12.02+) */ - image-rendering: pixelated; /* Awesome future-browsers */ - -ms-interpolation-mode: nearest-neighbor; - } - :host[ishost] > canvas:not(.canvas3d) { - display: none; - } - `; - } - _ctx; - static get Properties() { - return { - ishost: { - type: Boolean, - // reflect: 1 - }, - size: [0, 0], - tabindex: 1, - clearColor: 0x000000, - clearAlpha: 1, - }; - } - static get Listeners() { - return { - 'dragstart': 'preventDefault' - }; - } - get renderer() { - return renderer; - } - constructor(properties = {}) { - super(properties); - this.template([['canvas', { $: 'canvas' }]]); - this._ctx = this.$.canvas.getContext('2d'); - this.$.canvas.imageSmoothingEnabled = false; - } - setHost() { - if (!this.ishost) { - if (host) { - const r = window.devicePixelRatio || 1; - host._ctx.clearRect(0, 0, host.size[0] * r, host.size[1] * r); - host._ctx.drawImage(host.renderer.domElement, 0, 0, host.size[0] * r, host.size[1] * r); - gl.flush(); - host.ishost = false; - } - /* eslint-disable-next-line */ - host = this; - this.appendChild(this.renderer.domElement); - this.ishost = true; - _performanceCheck(); - } - if (this.size[0] && this.size[1]) { - this.renderer.setSize(this.size[0], this.size[1]); - this.renderer.setPixelRatio(window.devicePixelRatio); - this.renderer.setClearColor(this.clearColor, this.clearAlpha); - } - } - onResized() { - const rect = this.getBoundingClientRect(); - this.size[0] = Math.floor(rect.width); - this.size[1] = Math.floor(rect.height); - const r = window.devicePixelRatio || 1; - this.$.canvas.width = this.size[0] * r; - this.$.canvas.height = this.size[1] * r; - } -} -RegisterIoElement(ThreeRenderer); -//# sourceMappingURL=renderer.js.map \ No newline at end of file diff --git a/build/elements/renderer.js.map b/build/elements/renderer.js.map deleted file mode 100644 index 81a62bf..0000000 --- a/build/elements/renderer.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"renderer.js","sourceRoot":"","sources":["../../src/elements/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AACpC,OAAO,EAAC,SAAS,EAAE,iBAAiB,EAAC,MAAM,QAAQ,CAAC;AAEpD,MAAM,QAAQ,GAAG,IAAI,aAAa,CAAC,EAAC,SAAS,EAAE,KAAK,EAAE,qBAAqB,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAC,CAAC,CAAC;AACjG,MAAM,EAAE,GAAG,QAAQ,CAAC,UAAU,EAAE,CAAC;AAEjC,QAAQ,CAAC,UAAU,CAAC,SAAS,GAAG,UAAU,CAAC;AAC3C,QAAQ,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC;AAClC,QAAQ,CAAC,aAAa,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;AACtC,QAAQ,CAAC,SAAS,GAAG,KAAK,CAAC;AAE3B,IAAI,IAAmB,CAAC;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,MAAM,CAAC,gBAAgB,IAAI,CAAC,CAAC;QACvC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACvC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAC1C,CAAC;CACF;AAED,iBAAiB,CAAC,aAAa,CAAC,CAAC"} \ No newline at end of file diff --git a/build/elements/viewport.d.ts b/build/elements/viewport.d.ts index c7455dc..89b9471 100644 --- a/build/elements/viewport.d.ts +++ b/build/elements/viewport.d.ts @@ -3,9 +3,9 @@ import { WebGLRenderer, Scene, PerspectiveCamera, Texture } from 'three'; import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer.js'; import { RenderPass } from 'three/examples/jsm/postprocessing/RenderPass.js'; import { OrbitControls, TransformControls } from 'io-gui-three-controls'; -import './renderer.js'; export declare class ThreeViewport extends IoElement { static get Style(): string; + _ctx: CanvasRenderingContext2D; renderer: WebGLRenderer; camera: PerspectiveCamera; controls: OrbitControls; @@ -15,9 +15,19 @@ export declare class ThreeViewport extends IoElement { composer: EffectComposer; envMap: null | Texture; static get Properties(): { + ishost: { + type: BooleanConstructor; + }; + size: number[]; tabindex: number; + clearColor: number; + clearAlpha: number; + }; + static get Listeners(): { + dragstart: string; }; constructor(properties?: Record); + setHost(): void; connectedCallback(): void; disconnectedCallback(): void; onResized(): void; diff --git a/build/elements/viewport.d.ts.map b/build/elements/viewport.d.ts.map index 62f471d..86ab332 100644 --- a/build/elements/viewport.d.ts.map +++ b/build/elements/viewport.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"viewport.d.ts","sourceRoot":"","sources":["../../src/elements/viewport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAoB,MAAM,QAAQ,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,KAAK,EAAU,iB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U,EAAE,MAAM,iDAAiD,CAAC;AAG7E,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AA8CzE,qBAAa,aAAc,SAAQ,SAAS;IAC1C,MAAM,KAAK,KAAK,WAyBf;IAED,IAAI,EAAE,wBAAwB,CAAC;IAE/B,QAAQ,EAAE,aAAa,CAAC;IACxB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,EAAE,aAAa,CAAC;IACxB,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,KAAK,EAAE,KAAK,CAAC;IACb,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,cAAc,CAAC;IACzB,MAAM,EAAE,IAAI,GAAG,OAAO,CAAQ;IAE9B,MAAM,KAAK,UAAU;;;;;;;;MAWpB;IACD,MAAM,KAAK,SAAS;;MAInB;gBACW,UAAU,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;IAmDhD,OAAO;IAqBP,iBAAiB;IAIjB,oBAAoB;IAIpB,SAAS;IAmCT,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG;IAW/D,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG;IAQjE,MAAM;CAiBP"} \ No newline at end of file diff --git a/build/elements/viewport.js b/build/elements/viewport.js index 7944468..e19ae63 100644 --- a/build/elements/viewport.js +++ b/build/elements/viewport.js @@ -1,5 +1,5 @@ import { IoElement, RegisterIoElement } from "io-gui"; -import { Scene, PerspectiveCamera, OrthographicCamera, Vector3, sRGBEncoding, EquirectangularReflectionMapping, ACESFilmicToneMapping, Object3D } from 'three'; +import { WebGLRenderer, Scene, PerspectiveCamera, OrthographicCamera, Vector3, sRGBEncoding, EquirectangularReflectionMapping, ACESFilmicToneMapping, Object3D } from 'three'; import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js'; import { RGBELoader } from 'three/examples/jsm/loaders/RGBELoader.js'; import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer.js'; @@ -7,149 +7,319 @@ import { RenderPass } from 'three/examples/jsm/postprocessing/RenderPass.js'; import { ShaderPass } from 'three/examples/jsm/postprocessing/ShaderPass.js'; import { GammaCorrectionShader } from 'three/examples/jsm/shaders/GammaCorrectionShader.js'; import { OrbitControls, TransformControls } from 'io-gui-three-controls'; -import './renderer.js'; + const gltfLoader = new GLTFLoader(); const rgbeLoader = new RGBELoader(); +const renderer = new WebGLRenderer( { antialias: false, preserveDrawingBuffer: true, alpha: true } ); +const gl = renderer.getContext(); +renderer.domElement.className = 'canvas3d'; +renderer.shadowMap.enabled = true; +renderer.setClearColor( 0x000000, 1.0 ); +renderer.autoClear = false; +let host; +let perfNow = 0; +let perfDelta = 1000; +let perfAverage = 1000; +let perfWarned; + +const _performanceCheck = function () { + + if ( perfWarned ) + return; + + perfDelta = performance.now() - perfNow; + perfAverage = Math.min( ( perfAverage * 10 + perfDelta ) / 11, 1000 ); + perfNow = performance.now(); + + if ( perfAverage < 16 ) { + + console.warn( 'ThreeViewport performance warning: rendering multiple canvases!' ); + perfWarned = true; + + } + +}; + +const renderedQueue = []; +const renderNextQueue = []; + +const animate = function () { + + for ( let i = 0; i < renderedQueue.length; i ++ ) + renderedQueue[ i ].rendered = false; + renderedQueue.length = 0; + + for ( let i = 0; i < renderNextQueue.length; i ++ ) { + + renderNextQueue[ i ].scheduled = false; + renderNextQueue[ i ].render(); + + } + + renderNextQueue.length = 0; + requestAnimationFrame( animate ); + +}; + +requestAnimationFrame( animate ); + export class ThreeViewport extends IoElement { - static get Style() { - return /* css */ ` + + static get Style() { + + return /* css */ ` :host { position: relative; overflow: hidden; display: flex; + touch-action: none; + user-select: none; + box-sizing: border-box; + } + :host:focus > canvas { + outline: var(--io-border-width) solid var(--io-color-focus); + outline-offset: calc(var(--io-border-width) * -1); } :host > canvas { position: absolute; - top: 0 !important; - left: 0 !important; + top: 0; + left: 0; + pointer-events: none; + image-rendering: pixelated; + } + :host[ishost] > canvas:not(.canvas3d) { + display: none; } `; - } - renderer; - camera; - controls; - transformControls; - scene; - renderPass; - composer; - envMap = null; - static get Properties() { - return { - tabindex: 1 - }; - } - constructor(properties = {}) { - super(properties); - this.template([['three-renderer', { $: 'renderer' }]]); - this.renderer = this.$.renderer.renderer; - this.camera = new PerspectiveCamera(75, 1, 10, 3000); - this.controls = new OrbitControls(this.camera, this); - this.transformControls = new TransformControls(this.camera, this); - this.scene = new Scene(); - this.renderPass = new RenderPass(this.scene, this.camera); - this.composer = new EffectComposer(this.renderer); - // envMap: null | Texture = null; - this.renderer.setClearColor(0x999999); - this.renderer.setPixelRatio(window.devicePixelRatio); - this.renderer.outputEncoding = sRGBEncoding; - this.renderer.toneMapping = ACESFilmicToneMapping; - this.renderer.autoClear = false; - this.composer.addPass(this.renderPass); - this.composer.addPass(new ShaderPass(GammaCorrectionShader)); - this.camera.position.set(300, 200, 300); - this.camera.lookAt(new Vector3(0, 0, 0)); - this.render = this.render.bind(this); - this.controls.addEventListener('change', this.render); - this.controls.minDistance = 200; - this.controls.maxDistance = 500; - this.controls.zoomSpeed = 0.3; - this.controls.enableDamping = true; - const target = new Object3D(); - target.position.set(0, 0, 0); - this.scene.add(target); - this.transformControls.attach(target); - this.transformControls.traverse((obj) => { - obj.layers.set(1); - }); - this.scene.add(this.transformControls); - this.transformControls.addEventListener('change', this.render); - this.transformControls.addEventListener('dragging-changed', (event) => { - this.controls.enabled = !event.value; - }); - } - connectedCallback() { - super.connectedCallback(); - this._connected = true; - } - disconnectedCallback() { - super.disconnectedCallback(); - this._connected = false; - } - onResized() { - const rect = this.getBoundingClientRect(); - const aspect = rect.width / rect.height; - this.composer.setSize(rect.width, rect.height); - const camera = this.camera; - if (camera instanceof PerspectiveCamera) { - if (camera.aspect !== aspect) { - camera.aspect = aspect; - camera.updateProjectionMatrix(); - } - } - if (camera instanceof OrthographicCamera) { - const hh = camera.top - camera.bottom / 2; - const hw = hh * aspect; - if (camera.top !== hh || camera.right !== hw) { - camera.top = hh; - camera.bottom = -hh; - camera.right = hw; - camera.left = -hw; - camera.updateProjectionMatrix(); - } - } - this.rendered = false; - setTimeout(() => { - this.render(); - }); - } - // initPostprocessing() {} - loadIbl(url, onLoad, onProgress, onError) { - rgbeLoader.load(url, (texture) => { - if (onLoad) - onLoad(texture); - texture.mapping = EquirectangularReflectionMapping; - this.scene.background = texture; - this.scene.environment = texture; - this.envMap = texture; - this.lightProbeRig.update(this.renderer, this.scene); - this.render(); - }, onProgress, onError); - } - loadModel(url, onLoad, onProgress, onError) { - gltfLoader.load(url, (gltf) => { - if (onLoad) - onLoad(gltf.scene); - this.scene.add(gltf.scene); - this.lightProbeRig.update(this.renderer, this.scene); - this.render(); - }, onProgress, onError); - } - render() { - this.$.renderer.setHost(); - this.renderer.clear(); - this.scene.background = this.envMap; - this.camera.layers.set(0); - this.composer.render(); - this.renderer.clearDepth(); - this.camera.layers.set(1); - this.scene.background = null; - this.renderer.render(this.scene, this.camera); - this.renderer.clearDepth(); - this.camera.layers.set(100); - this.scene.background = null; - this.renderer.render(this.scene, this.camera); - this.rendered = true; - } + + } + _ctx; + renderer; + camera; + controls; + transformControls; + scene; + renderPass; + composer; + envMap = null; + static get Properties() { + + return { + ishost: { + type: Boolean, + + // reflect: 1 + }, + size: [ 0, 0 ], + tabindex: 1, + clearColor: 0x000000, + clearAlpha: 1 + }; + + } + static get Listeners() { + + return { + 'dragstart': 'preventDefault' + }; + + } + constructor( properties = {} ) { + + super( properties ); + this.template( [[ 'canvas', { $: 'canvas' } ]] ); + this._ctx = this.$.canvas.getContext( '2d' ); + this.$.canvas.imageSmoothingEnabled = false; + this.renderer = renderer; + this.camera = new PerspectiveCamera( 75, 1, 10, 3000 ); + this.controls = new OrbitControls( this.camera, this ); + this.transformControls = new TransformControls( this.camera, this ); + this.scene = new Scene(); + this.renderPass = new RenderPass( this.scene, this.camera ); + this.composer = new EffectComposer( this.renderer ); + + // envMap: null | Texture = null; + this.renderer.setClearColor( 0x999999 ); + this.renderer.setPixelRatio( window.devicePixelRatio ); + this.renderer.outputEncoding = sRGBEncoding; + this.renderer.toneMapping = ACESFilmicToneMapping; + this.renderer.autoClear = false; + this.composer.addPass( this.renderPass ); + this.composer.addPass( new ShaderPass( GammaCorrectionShader ) ); + this.camera.position.set( 300, 200, 300 ); + this.camera.lookAt( new Vector3( 0, 0, 0 ) ); + this.render = this.render.bind( this ); + this.controls.addEventListener( 'change', this.render ); + this.controls.minDistance = 200; + this.controls.maxDistance = 500; + this.controls.zoomSpeed = 0.3; + this.controls.enableDamping = true; + const target = new Object3D(); + target.position.set( 0, 0, 0 ); + this.scene.add( target ); + this.transformControls.attach( target ); + + this.transformControls.traverse( ( obj ) => { + + obj.layers.set( 1 ); + + } ); + + this.scene.add( this.transformControls ); + this.transformControls.addEventListener( 'change', this.render ); + + this.transformControls.addEventListener( 'dragging-changed', ( event ) => { + + this.controls.enabled = ! event.value; + + } ); + + } + setHost() { + + if ( ! this.ishost ) { + + if ( host ) { + + const r = window.devicePixelRatio || 1; + host._ctx.clearRect( 0, 0, host.size[ 0 ] * r, host.size[ 1 ] * r ); + host._ctx.drawImage( host.renderer.domElement, 0, 0, host.size[ 0 ] * r, host.size[ 1 ] * r ); + gl.flush(); + host.ishost = false; + + } + /* eslint-disable-next-line */ + host = this; + this.appendChild( this.renderer.domElement ); + this.ishost = true; + _performanceCheck(); + + } + + if ( this.size[ 0 ] && this.size[ 1 ] ) { + + this.renderer.setSize( this.size[ 0 ], this.size[ 1 ] ); + this.renderer.setPixelRatio( window.devicePixelRatio ); + this.renderer.setClearColor( this.clearColor, this.clearAlpha ); + + } + + } + connectedCallback() { + + super.connectedCallback(); + this._connected = true; + + } + disconnectedCallback() { + + super.disconnectedCallback(); + this._connected = false; + + } + onResized() { + + const rect = this.getBoundingClientRect(); + const aspect = rect.width / rect.height; + this.composer.setSize( rect.width, rect.height ); + const camera = this.camera; + + if ( camera instanceof PerspectiveCamera ) { + + if ( camera.aspect !== aspect ) { + + camera.aspect = aspect; + camera.updateProjectionMatrix(); + + } + + } + + if ( camera instanceof OrthographicCamera ) { + + const hh = camera.top - camera.bottom / 2; + const hw = hh * aspect; + + if ( camera.top !== hh || camera.right !== hw ) { + + camera.top = hh; + camera.bottom = - hh; + camera.right = hw; + camera.left = - hw; + camera.updateProjectionMatrix(); + + } + + } + + this.rendered = false; + this.size[ 0 ] = Math.floor( rect.width ); + this.size[ 1 ] = Math.floor( rect.height ); + const r = window.devicePixelRatio || 1; + this.$.canvas.width = this.size[ 0 ] * r; + this.$.canvas.height = this.size[ 1 ] * r; + + setTimeout( () => { + + this.render(); + + } ); + + } + + // initPostprocessing() {} + loadIbl( url, onLoad, onProgress, onError ) { + + rgbeLoader.load( url, ( texture ) => { + + if ( onLoad ) + onLoad( texture ); + + texture.mapping = EquirectangularReflectionMapping; + this.scene.background = texture; + this.scene.environment = texture; + this.envMap = texture; + this.lightProbeRig.update( this.renderer, this.scene ); + this.render(); + + }, onProgress, onError ); + + } + loadModel( url, onLoad, onProgress, onError ) { + + gltfLoader.load( url, ( gltf ) => { + + if ( onLoad ) + onLoad( gltf.scene ); + + this.scene.add( gltf.scene ); + this.lightProbeRig.update( this.renderer, this.scene ); + this.render(); + + }, onProgress, onError ); + + } + render() { + + this.setHost(); + this.renderer.clear(); + this.scene.background = this.envMap; + this.camera.layers.set( 0 ); + this.composer.render(); + this.renderer.clearDepth(); + this.camera.layers.set( 1 ); + this.scene.background = null; + this.renderer.render( this.scene, this.camera ); + this.renderer.clearDepth(); + this.camera.layers.set( 100 ); + this.scene.background = null; + this.renderer.render( this.scene, this.camera ); + this.rendered = true; + + } + } -RegisterIoElement(ThreeViewport); -//# sourceMappingURL=viewport.js.map \ No newline at end of file + +RegisterIoElement( ThreeViewport ); + +//# sourceMappingURL=viewport.js.map diff --git a/build/elements/viewport.js.map b/build/elements/viewport.js.map index 3397e38..ccea41a 100644 --- a/build/elements/viewport.js.map +++ b/build/elements/viewport.js.map @@ -1 +1 @@ -{"version":3,"file":"viewport.js","sourceRoot":"","sources":["../../src/elements/viewport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,iBAAiB,EAAC,MAAM,QAAQ,CAAC;AACpD,OAAO,EAAiB,KAAK,EAAU,iBAAiB,EAAE,kBAAkB,EAAE,OAAO,EAAE,YAAY,EAAE,gCAAgC,EAAE,qBAAqB,EAAE,QAAQ,EAAW,MAAM,OAAO,CAAC;AAC/L,OAAO,EAAQ,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,qDAAqD,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,MAAM,iDAAiD,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,iDAAiD,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,qDAAqD,CAAC;AAC5F,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,eAAe,CAAC;AAEvB,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;AACpC,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;AAEpC,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC1C,MAAM,KAAK,KAAK;QACd,OAAO,SAAS,CAAA;;;;;;;;;;;KAWf,CAAC;IACJ,CAAC;IACD,QAAQ,CAAgB;IACxB,MAAM,CAAoB;IAC1B,QAAQ,CAAgB;IACxB,iBAAiB,CAAoB;IACrC,KAAK,CAAQ;IACb,UAAU,CAAa;IACvB,QAAQ,CAAiB;IACzB,MAAM,GAAmB,IAAI,CAAC;IAE9B,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,QAAQ,EAAE,CAAC;SACZ,CAAC;IACJ,CA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,CAAC,MAAM,EAAE,CAAC;QAChB,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;IACD,MAAM;QACJ,IAAI,CAAC,OAAO,EAAE,CAAC;QAEf,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;QACpC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC1B,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACvB,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;QAC3B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC1B,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC;QAC7B,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC9C,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;QAC3B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC;QAC7B,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC9C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;CACF;AAED,iBAAiB,CAAC,aAAa,CAAC,CAAC"} \ No newline at end of file diff --git a/build/index.d.ts b/build/index.d.ts index d0b387d..536b4a1 100644 --- a/build/index.d.ts +++ b/build/index.d.ts @@ -1,5 +1,3 @@ export * from './elements/iconset.js'; -export * from './elements/renderer.js'; export * from './elements/viewport.js'; -export * from './rigs/lightProbeRig.js'; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/build/index.d.ts.map b/build/index.d.ts.map index 8bd4265..0d63840 100644 --- a/build/index.d.ts.map +++ b/build/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC"} \ No newline at end of file +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC"} \ No newline at end of file diff --git a/build/index.js b/build/index.js index ab1b45e..6659e97 100644 --- a/build/index.js +++ b/build/index.js @@ -1,5 +1,5 @@ export * from './elements/iconset.js'; -export * from './elements/renderer.js'; + export * from './elements/viewport.js'; -export * from './rigs/lightProbeRig.js'; -//# sourceMappingURL=index.js.map \ No newline at end of file + +//# sourceMappingURL=index.js.map diff --git a/build/index.js.map b/build/index.js.map index 70d5037..33336ef 100644 --- a/build/index.js.map +++ b/build/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC"} \ No newline at end of file diff --git a/build/rigs/lightProbeRig.d.ts b/build/rigs/lightProbeRig.d.ts deleted file mode 100644 index d31a69b..0000000 --- a/build/rigs/lightProbeRig.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Object3D, WebGLCubeRenderTarget, CubeCamera, LightProbe, WebGLRenderer, Scene } from "three"; -import { LightProbeHelper } from 'three/examples/jsm/helpers/LightProbeHelper.js'; -export declare class LightProbeRig extends Object3D { - lightProbe: LightProbe; - lightProbeHelper: LightProbeHelper; - cubeRenderTarget: WebGLCubeRenderTarget; - cubeCamera: CubeCamera; - constructor(resolution?: number); - update(renderer: WebGLRenderer, scene: Scene): void; -} -//# sourceMappingURL=lightProbeRig.d.ts.map \ No newline at end of file diff --git a/build/rigs/lightProbeRig.d.ts.map b/build/rigs/lightProbeRig.d.ts.map deleted file mode 100644 index bb35300..0000000 --- a/build/rigs/lightProbeRig.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"lightProbeRig.d.ts","sourceRoot":"","sources":["../../src/rigs/lightProbeRig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,qBAAqB,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AACtG,OAAO,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAGlF,qBAAa,aAAc,SAAQ,QAAQ;IACzC,UAAU,EAAE,UAAU,CAAoB;IAC1C,gBAAgB,EAAE,gBAAgB,CAA6C;IAC/E,gBAAgB,EAAE,qBAAqB,CAAC;IACxC,UAAU,EAAE,UAAU,CAAC;gBACX,UAAU,SAAM;IAQ5B,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK;CAU7C"} \ No newline at end of file diff --git a/build/rigs/lightProbeRig.js b/build/rigs/lightProbeRig.js deleted file mode 100644 index dd6d41e..0000000 --- a/build/rigs/lightProbeRig.js +++ /dev/null @@ -1,28 +0,0 @@ -import { Object3D, WebGLCubeRenderTarget, CubeCamera, LightProbe } from "three"; -import { LightProbeHelper } from 'three/examples/jsm/helpers/LightProbeHelper.js'; -import { LightProbeGenerator } from 'three/examples/jsm/lights/LightProbeGenerator.js'; -export class LightProbeRig extends Object3D { - lightProbe = new LightProbe(); - lightProbeHelper = new LightProbeHelper(this.lightProbe, 50); - cubeRenderTarget; - cubeCamera; - constructor(resolution = 256) { - super(); - this.cubeRenderTarget = new WebGLCubeRenderTarget(resolution); - this.cubeCamera = new CubeCamera(1, 1000, this.cubeRenderTarget); - this.add(this.cubeCamera); - this.add(this.lightProbe); - this.add(this.lightProbeHelper); - } - update(renderer, scene) { - this.cubeCamera.layers.set(1); - this.cubeCamera.update(renderer, scene); - this.lightProbe.copy(LightProbeGenerator.fromCubeRenderTarget(renderer, this.cubeRenderTarget)); - this.lightProbe.position.copy(this.cubeCamera.position); - this.lightProbeHelper.position.copy(this.cubeCamera.position); - this.lightProbe.intensity = 0.5; - this.lightProbe.layers.mask = this.layers.mask; - this.lightProbeHelper.layers.mask = this.layers.mask; - } -} -//# sourceMappingURL=lightProbeRig.js.map \ No newline at end of file diff --git a/build/rigs/lightProbeRig.js.map b/build/rigs/lightProbeRig.js.map deleted file mode 100644 index 49898d1..0000000 --- a/build/rigs/lightProbeRig.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"lightProbeRig.js","sourceRoot":"","sources":["../../src/rigs/lightProbeRig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,qBAAqB,EAAE,UAAU,EAAE,UAAU,EAAwB,MAAM,OAAO,CAAC;AACtG,OAAO,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kDAAkD,CAAC;AAEvF,MAAM,OAAO,aAAc,SAAQ,QAAQ;IACzC,UAAU,GAAe,IAAI,UAAU,EAAE,CAAC;IAC1C,gBAAgB,GAAqB,IAAI,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAC/E,gBAAgB,CAAwB;IACxC,UAAU,CAAa;IACvB,YAAY,UAAU,GAAG,GAAG;QAC1B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,gBAAgB,GAAG,IAAI,qBAAqB,CAAC,UAAU,CAAC,CAAC;QAC9D,IAAI,CAAC,UAAU,GAAG,IAAI,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACjE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC1B,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC1B,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAClC,CAAC;IACD,MAAM,CAAC,QAAuB,EAAE,KAAY;QAC1C,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC9B,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACxC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,QAAQ,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;QAChG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QACxD,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC9D,IAAI,CAAC,UAAU,CAAC,SAAS,GAAG,GAAG,CAAC;QAChC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;QAC/C,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IACvD,CAAC;CACF"} \ No newline at end of file diff --git a/src/elements/renderer.ts b/src/elements/renderer.ts deleted file mode 100644 index 88b5ac4..0000000 --- a/src/elements/renderer.ts +++ /dev/null @@ -1,136 +0,0 @@ -import {WebGLRenderer} from "three"; -import {IoElement, RegisterIoElement} from "io-gui"; - -const renderer = new WebGLRenderer({antialias: false, preserveDrawingBuffer: true, alpha: true}); -const gl = renderer.getContext(); - -renderer.domElement.className = 'canvas3d'; -renderer.shadowMap.enabled = true; -renderer.setClearColor(0x000000, 1.0); -renderer.autoClear = false; - -let host: ThreeRenderer; - -let perfNow = 0; -let perfDelta = 1000; -let perfAverage = 1000; -let perfWarned: boolean; - -const _performanceCheck = function() { - if (perfWarned) return; - perfDelta = performance.now() - perfNow; - perfAverage = Math.min((perfAverage * 10 + perfDelta) / 11, 1000); - perfNow = performance.now(); - if (perfAverage < 16) { - console.warn('ThreeRenderer performance warning: rendering multiple canvases!'); - perfWarned = true; - } -}; - -const renderedQueue: ThreeRenderer[] = []; -const renderNextQueue: ThreeRenderer[] = []; - -const animate = function() { - for (let i = 0; i < renderedQueue.length; i++) renderedQueue[i].rendered = false; - renderedQueue.length = 0; - for (let i = 0; i < renderNextQueue.length; i++) { - renderNextQueue[i].scheduled = false; - renderNextQueue[i].render(); - } - renderNextQueue.length = 0; - requestAnimationFrame(animate); -}; -requestAnimationFrame(animate); - -export class ThreeRenderer extends IoElement { - static get Style() { - return /* css */` - :host { - display: block; - overflow: hidden; - position: relative; - touch-action: none; - user-select: none; - box-sizing: border-box; - flex: 1 1 auto; - } - :host:focus > canvas { - outline: var(--io-border-width) solid var(--io-color-focus); - outline-offset: calc(var(--io-border-width) * -1); - } - :host > canvas { - position: absolute; - top: 0; - left: 0; - pointer-events: none; - image-rendering: optimizeSpeed; /* Older versions of FF */ - image-rendering: -moz-crisp-edges; /* FF 6.0+ */ - image-rendering: -webkit-optimize-contrast; /* Safari */ - image-rendering: -o-crisp-edges; /* OS X & Windows Opera (12.02+) */ - image-rendering: pixelated; /* Awesome future-browsers */ - -ms-interpolation-mode: nearest-neighbor; - } - :host[ishost] > canvas:not(.canvas3d) { - display: none; - } - `; - } - _ctx: CanvasRenderingContext2D; - static get Properties() { - return { - ishost: { - type: Boolean, - // reflect: 1 - }, - size: [0, 0], - tabindex: 1, - clearColor: 0x000000, - clearAlpha: 1, - }; - } - static get Listeners() { - return { - 'dragstart': 'preventDefault' - }; - } - get renderer() { - return renderer; - } - constructor(properties: Record = {}) { - super(properties); - this.template([['canvas', {$: 'canvas'}]]); - this._ctx = this.$.canvas.getContext('2d'); - this.$.canvas.imageSmoothingEnabled = false; - } - setHost() { - if (!this.ishost) { - if (host) { - const r = window.devicePixelRatio || 1; - host._ctx.clearRect(0, 0, host.size[0] * r, host.size[1] * r); - host._ctx.drawImage(host.renderer.domElement, 0, 0, host.size[0] * r, host.size[1] * r); - gl.flush(); - host.ishost = false; - } - /* eslint-disable-next-line */ - host = this; - this.appendChild(this.renderer.domElement); - this.ishost = true; - _performanceCheck(); - } - if (this.size[0] && this.size[1]) { - this.renderer.setSize(this.size[0], this.size[1]); - this.renderer.setPixelRatio(window.devicePixelRatio); - this.renderer.setClearColor(this.clearColor, this.clearAlpha); - } - } - onResized() { - const rect = this.getBoundingClientRect(); - this.size[0] = Math.floor(rect.width); - this.size[1] = Math.floor(rect.height); - const r = window.devicePixelRatio || 1; - this.$.canvas.width = this.size[0] * r; - this.$.canvas.height = this.size[1] * r; - } -} - -RegisterIoElement(ThreeRenderer); \ No newline at end of file diff --git a/src/elements/viewport.ts b/src/elements/viewport.ts index ec6f95e..ee09d1a 100644 --- a/src/elements/viewport.ts +++ b/src/elements/viewport.ts @@ -7,11 +7,51 @@ import { RenderPass } from 'three/examples/jsm/postprocessing/RenderPass.js'; import { ShaderPass } from 'three/examples/jsm/postprocessing/ShaderPass.js'; import { GammaCorrectionShader } from 'three/examples/jsm/shaders/GammaCorrectionShader.js'; import { OrbitControls, TransformControls } from 'io-gui-three-controls'; -import './renderer.js'; const gltfLoader = new GLTFLoader(); const rgbeLoader = new RGBELoader(); +const renderer = new WebGLRenderer({antialias: false, preserveDrawingBuffer: true, alpha: true}); +const gl = renderer.getContext(); + +renderer.domElement.className = 'canvas3d'; +renderer.shadowMap.enabled = true; +renderer.setClearColor(0x000000, 1.0); +renderer.autoClear = false; + +let host: ThreeViewport; + +let perfNow = 0; +let perfDelta = 1000; +let perfAverage = 1000; +let perfWarned: boolean; + +const _performanceCheck = function() { + if (perfWarned) return; + perfDelta = performance.now() - perfNow; + perfAverage = Math.min((perfAverage * 10 + perfDelta) / 11, 1000); + perfNow = performance.now(); + if (perfAverage < 16) { + console.warn('ThreeViewport performance warning: rendering multiple canvases!'); + perfWarned = true; + } +}; + +const renderedQueue: ThreeViewport[] = []; +const renderNextQueue: ThreeViewport[] = []; + +const animate = function() { + for (let i = 0; i < renderedQueue.length; i++) renderedQueue[i].rendered = false; + renderedQueue.length = 0; + for (let i = 0; i < renderNextQueue.length; i++) { + renderNextQueue[i].scheduled = false; + renderNextQueue[i].render(); + } + renderNextQueue.length = 0; + requestAnimationFrame(animate); +}; +requestAnimationFrame(animate); + export class ThreeViewport extends IoElement { static get Style() { return /* css */` @@ -19,14 +59,29 @@ export class ThreeViewport extends IoElement { position: relative; overflow: hidden; display: flex; + touch-action: none; + user-select: none; + box-sizing: border-box; + } + :host:focus > canvas { + outline: var(--io-border-width) solid var(--io-color-focus); + outline-offset: calc(var(--io-border-width) * -1); } :host > canvas { position: absolute; - top: 0 !important; - left: 0 !important; + top: 0; + left: 0; + pointer-events: none; + image-rendering: pixelated; + } + :host[ishost] > canvas:not(.canvas3d) { + display: none; } `; } + + _ctx: CanvasRenderingContext2D; + renderer: WebGLRenderer; camera: PerspectiveCamera; controls: OrbitControls; @@ -38,14 +93,28 @@ export class ThreeViewport extends IoElement { static get Properties() { return { - tabindex: 1 + ishost: { + type: Boolean, + // reflect: 1 + }, + size: [0, 0], + tabindex: 1, + clearColor: 0x000000, + clearAlpha: 1 + }; + } + static get Listeners() { + return { + 'dragstart': 'preventDefault' }; } constructor(properties: Record = {}) { super(properties); - this.template([['three-renderer', {$: 'renderer'}]]); + this.template([['canvas', {$: 'canvas'}]]); + this._ctx = this.$.canvas.getContext('2d'); + this.$.canvas.imageSmoothingEnabled = false; - this.renderer = this.$.renderer.renderer; + this.renderer = renderer; this.camera = new PerspectiveCamera(75, 1, 10, 3000); this.controls = new OrbitControls(this.camera, this as unknown as HTMLElement); @@ -90,6 +159,27 @@ export class ThreeViewport extends IoElement { this.controls.enabled = !(event as any).value; }); } + setHost() { + if (!this.ishost) { + if (host) { + const r = window.devicePixelRatio || 1; + host._ctx.clearRect(0, 0, host.size[0] * r, host.size[1] * r); + host._ctx.drawImage(host.renderer.domElement, 0, 0, host.size[0] * r, host.size[1] * r); + gl.flush(); + host.ishost = false; + } + /* eslint-disable-next-line */ + host = this; + this.appendChild(this.renderer.domElement); + this.ishost = true; + _performanceCheck(); + } + if (this.size[0] && this.size[1]) { + this.renderer.setSize(this.size[0], this.size[1]); + this.renderer.setPixelRatio(window.devicePixelRatio); + this.renderer.setClearColor(this.clearColor, this.clearAlpha); + } + } connectedCallback() { super.connectedCallback(); this._connected = true; @@ -121,6 +211,13 @@ export class ThreeViewport extends IoElement { } } this.rendered = false; + + this.size[0] = Math.floor(rect.width); + this.size[1] = Math.floor(rect.height); + const r = window.devicePixelRatio || 1; + this.$.canvas.width = this.size[0] * r; + this.$.canvas.height = this.size[1] * r; + setTimeout(()=>{ this.render(); }); @@ -146,7 +243,7 @@ export class ThreeViewport extends IoElement { }, onProgress, onError); } render() { - this.$.renderer.setHost(); + this.setHost(); this.renderer.clear(); this.scene.background = this.envMap; diff --git a/src/index.ts b/src/index.ts index cc13927..c7b9214 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,2 @@ export * from './elements/iconset.js'; -export * from './elements/renderer.js'; -export * from './elements/viewport.js'; -export * from './rigs/lightProbeRig.js'; \ No newline at end of file +export * from './elements/viewport.js'; \ No newline at end of file