claygl-next
Advanced tools
Comparing version 2.0.0-alpha.39 to 2.0.0-alpha.40
@@ -56,3 +56,3 @@ declare class Notifier { | ||
*/ | ||
off(name: string, action: Function): this | undefined; | ||
off(name: string, action?: Function): this | undefined; | ||
/** | ||
@@ -59,0 +59,0 @@ * If registered the event handler |
@@ -152,10 +152,2 @@ import Vector3 from './math/Vector3'; | ||
/** | ||
* Query descendant node by path | ||
* @param {string} path | ||
* @return {clay.Node} | ||
* @example | ||
* node.queryNode('root/parent/child'); | ||
*/ | ||
queryNode(path: string): ClayNode | undefined; | ||
/** | ||
* Get query path, relative to rootNode(default is scene) | ||
@@ -170,5 +162,5 @@ * @param {clay.Node} [rootNode] | ||
* **WARN** Don't do `add`, `remove` operation in the callback during traverse. | ||
* @param {Function} callback | ||
* @param {Function} callback Return true to stop traverse | ||
*/ | ||
traverse(callback: (node: ClayNode) => void): void; | ||
traverse(callback: (node: ClayNode) => boolean | void): void; | ||
/** | ||
@@ -175,0 +167,0 @@ * Traverse all children nodes. |
@@ -56,3 +56,3 @@ declare class Notifier { | ||
*/ | ||
off(name: string, action: Function): this | undefined; | ||
off(name: string, action?: Function): this | undefined; | ||
/** | ||
@@ -59,0 +59,0 @@ * If registered the event handler |
@@ -5,2 +5,3 @@ import * as vec3 from './glmatrix/vec3'; | ||
import GeometryBase, { GeometryAttribute } from './GeometryBase'; | ||
import { mat3 } from './glmatrix'; | ||
/** | ||
@@ -413,9 +414,10 @@ * Geometry in ClayGL contains vertex attributes of mesh. These vertex attributes will be finally provided to the {@link clay.Shader}. | ||
mat4.transpose(inverseTransposeMatrix, inverseTransposeMatrix); | ||
const normalMat = mat3.fromMat4(mat3.create(), inverseTransposeMatrix); | ||
const vec3ForEach = vec3.forEach; | ||
vec3ForEach(positions, 3, 0, undefined, vec3.transformMat4, matArr); | ||
if (normals) { | ||
vec3ForEach(normals, 3, 0, undefined, vec3.transformMat4, inverseTransposeMatrix); | ||
vec3ForEach(normals, 3, 0, undefined, vec3.transformMat3, normalMat); | ||
} | ||
if (tangents) { | ||
vec3ForEach(tangents, 4, 0, undefined, vec3.transformMat4, inverseTransposeMatrix); | ||
vec3ForEach(tangents, 4, 0, undefined, vec3.transformMat3, normalMat); | ||
} | ||
@@ -422,0 +424,0 @@ if (this.boundingBox) { |
@@ -18,2 +18,6 @@ class GLExtension { | ||
_createExtension(name) { | ||
// This is not used and will warn on chrome. | ||
if (name === 'WEBGL_polygon_mode') { | ||
return; | ||
} | ||
const gl = this.gl; | ||
@@ -20,0 +24,0 @@ if (gl.getExtension) { |
@@ -152,10 +152,2 @@ import Vector3 from './math/Vector3'; | ||
/** | ||
* Query descendant node by path | ||
* @param {string} path | ||
* @return {clay.Node} | ||
* @example | ||
* node.queryNode('root/parent/child'); | ||
*/ | ||
queryNode(path: string): ClayNode | undefined; | ||
/** | ||
* Get query path, relative to rootNode(default is scene) | ||
@@ -170,5 +162,5 @@ * @param {clay.Node} [rootNode] | ||
* **WARN** Don't do `add`, `remove` operation in the callback during traverse. | ||
* @param {Function} callback | ||
* @param {Function} callback Return true to stop traverse | ||
*/ | ||
traverse(callback: (node: ClayNode) => void): void; | ||
traverse(callback: (node: ClayNode) => boolean | void): void; | ||
/** | ||
@@ -175,0 +167,0 @@ * Traverse all children nodes. |
@@ -82,3 +82,5 @@ import Vector3 from './math/Vector3'; | ||
if (scene && scene !== node._scene) { | ||
node.traverse((child) => this._addSelfToScene(child)); | ||
node.traverse((child) => { | ||
this._addSelfToScene(child); | ||
}); | ||
} | ||
@@ -99,3 +101,5 @@ } | ||
if (this._scene) { | ||
node.traverse((child) => this._removeSelfFromScene(child)); | ||
node.traverse((child) => { | ||
this._removeSelfFromScene(child); | ||
}); | ||
} | ||
@@ -111,3 +115,5 @@ } | ||
if (this._scene) { | ||
children[idx].traverse((child) => this._removeSelfFromScene(child)); | ||
children[idx].traverse((child) => { | ||
this._removeSelfFromScene(child); | ||
}); | ||
} | ||
@@ -208,39 +214,2 @@ } | ||
/** | ||
* Query descendant node by path | ||
* @param {string} path | ||
* @return {clay.Node} | ||
* @example | ||
* node.queryNode('root/parent/child'); | ||
*/ | ||
queryNode(path) { | ||
if (!path) { | ||
return; | ||
} | ||
// TODO Name have slash ? | ||
const pathArr = path.split('/'); | ||
let current = this; | ||
for (let i = 0; i < pathArr.length; i++) { | ||
const name = pathArr[i]; | ||
// Skip empty | ||
if (!name) { | ||
continue; | ||
} | ||
let found = false; | ||
const children = current._children; | ||
for (let j = 0; j < children.length; j++) { | ||
const child = children[j]; | ||
if (child.name === name) { | ||
current = child; | ||
found = true; | ||
break; | ||
} | ||
} | ||
// Early return if not found | ||
if (!found) { | ||
return; | ||
} | ||
} | ||
return current; | ||
} | ||
/** | ||
* Get query path, relative to rootNode(default is scene) | ||
@@ -272,6 +241,8 @@ * @param {clay.Node} [rootNode] | ||
* **WARN** Don't do `add`, `remove` operation in the callback during traverse. | ||
* @param {Function} callback | ||
* @param {Function} callback Return true to stop traverse | ||
*/ | ||
traverse(callback) { | ||
callback(this); | ||
if (callback(this)) { | ||
return; | ||
} | ||
const children = this._children; | ||
@@ -278,0 +249,0 @@ for (let i = 0, len = children.length; i < len; i++) { |
@@ -130,4 +130,4 @@ /** | ||
resize(width, height) { | ||
this._width = width; | ||
this._height = height; | ||
this.width = width; | ||
this.height = height; | ||
} | ||
@@ -134,0 +134,0 @@ /** |
{ | ||
"name": "claygl-next", | ||
"version": "2.0.0-alpha.39", | ||
"version": "2.0.0-alpha.40", | ||
"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
7148737
122093