export function transform2mapbox(matrix) { const min = -WEBMERCATOR_EXTENT; const max = WEBMERCATOR_EXTENT; const scale = 1 / (2 * WEBMERCATOR_EXTENT); const result = matrix.slice(); // copy array result[12] = (matrix[12] - min) * scale; // x translation result[13] = (matrix[13] - max) * -scale; // y translation result[14] = matrix[14] * scale; // z translation return new THREE.Matrix4().fromArray(result).scale(new THREE.Vector3(scale, -scale, scale)); }
render(gl, viewProjectionMatrix) { this.viewProjectionMatrix = viewProjectionMatrix; const l = new THREE.Matrix4().fromArray(viewProjectionMatrix); this.renderer.state.reset(); // The root tile transform is applied to the camera while rendering // instead of to the root tile. This avoids precision errors. this.camera.projectionMatrix = l.multiply(this.rootTransform); this.renderer.render(this.scene, this.camera); if (this.loadStatus === 1) { // first render after root tile is loaded this.loadStatus = 2; const frustum = new THREE.Frustum(); frustum.setFromMatrix( new THREE.Matrix4().multiplyMatrices( this.camera.projectionMatrix, this.camera.matrixWorldInverse ) ); if (this.tileset) { this.tileset.update(frustum, this._getCameraPosition()); } } }
_initTraversal(json, parentRefine, isRoot) { this.refine = json.refine ? json.refine.toUpperCase() : parentRefine; this.geometricError = json.geometricError; this.transform = json.transform; if (this.transform && !isRoot) { // if not the root tile: apply the transform to the THREE js Group // the root tile transform is applied to the camera while rendering this.totalContent.applyMatrix(new THREE.Matrix4().fromArray(this.transform)); } this.content = json.content; this.children = []; if (json.children) { for (let i = 0; i < json.children.length; i++) { const child = new TileHeader( json.children[i], this.resourcePath, this.styleParams, this.refine, false ); this.childContent.add(child.totalContent); this.children.push(child); } } }
new THREE.Matrix4().fromArray(tileset.root.transform) );
mat.fromArray(skinEntry.inverseBindMatrices.array, j * 16);
undefined ) { mat.fromArray( skinEntry.inverseBindMatrices .array,