claygl-next
Advanced tools
Comparing version 2.0.0-alpha.25 to 2.0.0-alpha.26
@@ -26,4 +26,5 @@ import * as rayPicking from '../picking/rayPicking'; | ||
private _listenedEvents; | ||
constructor(container: HTMLElement, renderer: Renderer, scene: Scene, camera?: Camera); | ||
constructor(container: HTMLElement, renderer: Renderer, scene?: Scene, camera?: Camera); | ||
setCamera(camera?: Camera): void; | ||
setScene(scene?: Scene): void; | ||
enable(enabledTriggers?: EventTriggers[]): void; | ||
@@ -30,0 +31,0 @@ disable(): void; |
@@ -40,2 +40,5 @@ import * as rayPicking from '../picking/rayPicking'; | ||
} | ||
setScene(scene) { | ||
this._scene = scene; | ||
} | ||
enable(enabledTriggers) { | ||
@@ -45,3 +48,2 @@ // Disable before enable. | ||
const dom = this._container; | ||
const scene = this._scene; | ||
const renderer = this._renderer; | ||
@@ -60,4 +62,5 @@ enabledTriggers = enabledTriggers || ['click', 'hover', 'wheel']; | ||
vendor.addEventListener(dom, domEveType, (this[makeHandlerName(domEveType)] = (e) => { | ||
const mainCamera = this._camera || scene.getMainCamera(); | ||
if (!mainCamera) { | ||
const scene = this._scene; | ||
const mainCamera = this._camera || (scene && scene.getMainCamera()); | ||
if (!mainCamera || !scene) { | ||
// Not have camera yet. | ||
@@ -64,0 +67,0 @@ return; |
@@ -23,3 +23,3 @@ import Renderer from './Renderer'; | ||
import { Notifier } from './core'; | ||
import { EventTriggers } from './app/EventManager'; | ||
import { EventManager, EventTriggers } from './app/EventManager'; | ||
import Shader from './Shader'; | ||
@@ -157,2 +157,3 @@ import { createStandardShader } from './shader/create'; | ||
get scene(): Scene; | ||
set scene(scene: Scene); | ||
get renderer(): Renderer; | ||
@@ -166,2 +167,3 @@ get container(): HTMLElement; | ||
getShadowMapPass(): ShadowMapPass | undefined; | ||
getEventManager(): EventManager | undefined; | ||
/** | ||
@@ -178,2 +180,3 @@ * Init app3D. Only available when lazyInit is set true. | ||
loop(cb: (frameTime: number) => void): void; | ||
private _onBeforeRenderScene; | ||
private _doInit; | ||
@@ -180,0 +183,0 @@ private _updateGraphicOptions; |
@@ -114,3 +114,3 @@ // TODO createCompositor | ||
const renderer = (this._renderer = new Renderer(rendererOpts)); | ||
const scene = (this._scene = new Scene()); | ||
const scene = new Scene(); | ||
const width = opts.width || container.clientWidth; | ||
@@ -129,6 +129,9 @@ const height = opts.height || container.clientHeight; | ||
if (eventOpts && eventOpts.enabled) { | ||
this._eventManager = new EventManager(eventOpts.container || container, renderer, this._scene); | ||
this._eventManager = new EventManager(eventOpts.container || container, renderer, scene); | ||
this._eventManager.enable(eventOpts.trigger); | ||
} | ||
!isDomCanvas && container.appendChild(renderer.canvas); | ||
// Set scene to initialize. | ||
this._onBeforeRenderScene = this._onBeforeRenderScene.bind(this); | ||
this.scene = scene; | ||
renderer.resize(width, height); | ||
@@ -139,10 +142,2 @@ timeline.start(); | ||
} | ||
scene.on('beforerender', (renderer, scene, camera, renderList) => { | ||
if (this._inRender) { | ||
// Only update graphic options when using #render function. | ||
['opaque', 'transparent'].forEach((type) => { | ||
this._updateGraphicOptions(graphicOpts, renderList[type], false); | ||
}); | ||
} | ||
}); | ||
} | ||
@@ -152,2 +147,13 @@ get scene() { | ||
} | ||
set scene(scene) { | ||
if (scene === this._scene || this._disposed) { | ||
return; | ||
} | ||
if (this._eventManager) { | ||
this._eventManager.setScene(scene); | ||
} | ||
this._scene && this._scene.off('beforerender', this._onBeforeRenderScene); | ||
scene.on('beforerender', this._onBeforeRenderScene); | ||
this._scene = scene; | ||
} | ||
get renderer() { | ||
@@ -177,2 +183,5 @@ return this._renderer; | ||
} | ||
getEventManager() { | ||
return this._eventManager; | ||
} | ||
/** | ||
@@ -199,2 +208,10 @@ * Init app3D. Only available when lazyInit is set true. | ||
} | ||
_onBeforeRenderScene(renderer, scene, camera, renderList) { | ||
if (this._inRender) { | ||
// Only update graphic options when using #render function. | ||
['opaque', 'transparent'].forEach((type) => { | ||
this._updateGraphicOptions(this._graphicOpts, renderList[type], false); | ||
}); | ||
} | ||
} | ||
_doInit() { | ||
@@ -201,0 +218,0 @@ this._inited = true; |
@@ -17,2 +17,3 @@ import type Renderer from '../Renderer'; | ||
* If using the previous frame result of output. | ||
* Can't be used with output.persist. | ||
*/ | ||
@@ -19,0 +20,0 @@ prevFrame?: boolean; |
@@ -88,3 +88,3 @@ import { keys } from '../core/util'; | ||
function logMissingLink(input) { | ||
console.warn('Pin of ' + | ||
console.warn('Output of ' + | ||
(input.node.name || 'Anoymous') + | ||
@@ -91,0 +91,0 @@ (input.output ? '.' + input.output : '') + |
@@ -1,2 +0,2 @@ | ||
import ClayNode, { ClayNodeOpts, GetBoundingBoxFilter } from './Node'; | ||
import ClayNode, { ClayNodeOpts } from './Node'; | ||
import BoundingBox from './math/BoundingBox'; | ||
@@ -89,3 +89,2 @@ import type Material from './Material'; | ||
afterRender(): void; | ||
getBoundingBox(filter?: GetBoundingBoxFilter, out?: BoundingBox): BoundingBox; | ||
/** | ||
@@ -92,0 +91,0 @@ * Clone a new renderable |
@@ -50,9 +50,9 @@ import ClayNode from './Node'; | ||
afterRender() { } | ||
getBoundingBox(filter, out) { | ||
out = super.getBoundingBox.call(this, filter, out); | ||
if (this.geometry && this.geometry.boundingBox) { | ||
out.union(this.geometry.boundingBox); | ||
} | ||
return out; | ||
} | ||
// getBoundingBox(filter?: GetBoundingBoxFilter, out?: BoundingBox): BoundingBox { | ||
// out = super.getBoundingBox.call(this, filter, out); | ||
// if (this.geometry && this.geometry.boundingBox) { | ||
// out.union(this.geometry.boundingBox); | ||
// } | ||
// return out; | ||
// } | ||
/** | ||
@@ -59,0 +59,0 @@ * Clone a new renderable |
@@ -140,3 +140,3 @@ import { createArrayUniform, createAttribute as attribute, createUniform as uniform, createVarying as varying, FragmentShader, glsl, VertexShader } from '../../../Shader'; | ||
name: 'gBufferFrag', | ||
outputs: outputs, | ||
outputs, | ||
uniforms: { | ||
@@ -143,0 +143,0 @@ viewInverse: VIEWINVERSE(), |
{ | ||
"name": "claygl-next", | ||
"version": "2.0.0-alpha.25", | ||
"version": "2.0.0-alpha.26", | ||
"description": "A 3D graphic library", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6979404
105932