start updating to three.js 123
This commit is contained in:
parent
302cab5406
commit
88378c6dec
@ -18,7 +18,7 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
@ -42,10 +42,11 @@
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
viewer.setEDLEnabled(true);
|
||||
viewer.setEDLEnabled(false);
|
||||
viewer.setFOV(60);
|
||||
viewer.setPointBudget(1*1000*1000);
|
||||
viewer.setPointBudget(1_000_000);
|
||||
viewer.loadSettingsFromURL();
|
||||
viewer.setBackground("skybox");
|
||||
|
||||
viewer.setDescription("Point cloud courtesy of <a target='_blank' href='https://www.sigeom.ch/'>sigeom sa</a>");
|
||||
|
||||
|
||||
@ -170,13 +170,13 @@ MeshLine.prototype.process = function() {
|
||||
this.attributes.index.needsUpdate = true;
|
||||
}
|
||||
|
||||
this.geometry.addAttribute( 'position', this.attributes.position );
|
||||
this.geometry.addAttribute( 'previous', this.attributes.previous );
|
||||
this.geometry.addAttribute( 'next', this.attributes.next );
|
||||
this.geometry.addAttribute( 'side', this.attributes.side );
|
||||
this.geometry.addAttribute( 'width', this.attributes.width );
|
||||
this.geometry.addAttribute( 'uv', this.attributes.uv );
|
||||
this.geometry.addAttribute( 'counters', this.attributes.counters );
|
||||
this.geometry.setAttribute( 'position', this.attributes.position );
|
||||
this.geometry.setAttribute( 'previous', this.attributes.previous );
|
||||
this.geometry.setAttribute( 'next', this.attributes.next );
|
||||
this.geometry.setAttribute( 'side', this.attributes.side );
|
||||
this.geometry.setAttribute( 'width', this.attributes.width );
|
||||
this.geometry.setAttribute( 'uv', this.attributes.uv );
|
||||
this.geometry.setAttribute( 'counters', this.attributes.counters );
|
||||
|
||||
this.geometry.setIndex( this.attributes.index );
|
||||
|
||||
|
||||
@ -614,11 +614,11 @@ THREE.OBJLoader = ( function () {
|
||||
|
||||
var buffergeometry = new THREE.BufferGeometry();
|
||||
|
||||
buffergeometry.addAttribute( 'position', new THREE.Float32BufferAttribute( geometry.vertices, 3 ) );
|
||||
buffergeometry.setAttribute( 'position', new THREE.Float32BufferAttribute( geometry.vertices, 3 ) );
|
||||
|
||||
if ( geometry.normals.length > 0 ) {
|
||||
|
||||
buffergeometry.addAttribute( 'normal', new THREE.Float32BufferAttribute( geometry.normals, 3 ) );
|
||||
buffergeometry.setAttribute( 'normal', new THREE.Float32BufferAttribute( geometry.normals, 3 ) );
|
||||
|
||||
} else {
|
||||
|
||||
@ -628,13 +628,13 @@ THREE.OBJLoader = ( function () {
|
||||
|
||||
if ( geometry.colors.length > 0 ) {
|
||||
|
||||
buffergeometry.addAttribute( 'color', new THREE.Float32BufferAttribute( geometry.colors, 3 ) );
|
||||
buffergeometry.setAttribute( 'color', new THREE.Float32BufferAttribute( geometry.colors, 3 ) );
|
||||
|
||||
}
|
||||
|
||||
if ( geometry.uvs.length > 0 ) {
|
||||
|
||||
buffergeometry.addAttribute( 'uv', new THREE.Float32BufferAttribute( geometry.uvs, 2 ) );
|
||||
buffergeometry.setAttribute( 'uv', new THREE.Float32BufferAttribute( geometry.uvs, 2 ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -315,25 +315,25 @@ THREE.PLYLoader.prototype = {
|
||||
// mandatory buffer data
|
||||
|
||||
geometry.setIndex( new ( buffer.indices.length > 65535 ? THREE.Uint32BufferAttribute : THREE.Uint16BufferAttribute )( buffer.indices, 1 ) );
|
||||
geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( buffer.vertices, 3 ) );
|
||||
geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( buffer.vertices, 3 ) );
|
||||
|
||||
// optional buffer data
|
||||
|
||||
if ( buffer.normals.length > 0 ) {
|
||||
|
||||
geometry.addAttribute( 'normal', new THREE.Float32BufferAttribute( buffer.normals, 3 ) );
|
||||
geometry.setAttribute( 'normal', new THREE.Float32BufferAttribute( buffer.normals, 3 ) );
|
||||
|
||||
}
|
||||
|
||||
if ( buffer.uvs.length > 0 ) {
|
||||
|
||||
geometry.addAttribute( 'uv', new THREE.Float32BufferAttribute( buffer.uvs, 2 ) );
|
||||
geometry.setAttribute( 'uv', new THREE.Float32BufferAttribute( buffer.uvs, 2 ) );
|
||||
|
||||
}
|
||||
|
||||
if ( buffer.colors.length > 0 ) {
|
||||
|
||||
geometry.addAttribute( 'color', new THREE.Float32BufferAttribute( buffer.colors, 3 ) );
|
||||
geometry.setAttribute( 'color', new THREE.Float32BufferAttribute( buffer.colors, 3 ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
1010
libs/three.js/build/three.min.js
vendored
1010
libs/three.js/build/three.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -17,8 +17,8 @@ THREE.LineSegmentsGeometry = function () {
|
||||
var index = [ 0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3, 4, 6, 5, 6, 7, 5 ];
|
||||
|
||||
this.setIndex( index );
|
||||
this.addAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) );
|
||||
this.addAttribute( 'uv', new THREE.Float32BufferAttribute( uvs, 2 ) );
|
||||
this.setAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) );
|
||||
this.setAttribute( 'uv', new THREE.Float32BufferAttribute( uvs, 2 ) );
|
||||
|
||||
};
|
||||
|
||||
@ -75,8 +75,8 @@ THREE.LineSegmentsGeometry.prototype = Object.assign( Object.create( THREE.Insta
|
||||
|
||||
var instanceBuffer = new THREE.InstancedInterleavedBuffer( lineSegments, 6, 1 ); // xyz, xyz
|
||||
|
||||
this.addAttribute( 'instanceStart', new THREE.InterleavedBufferAttribute( instanceBuffer, 3, 0 ) ); // xyz
|
||||
this.addAttribute( 'instanceEnd', new THREE.InterleavedBufferAttribute( instanceBuffer, 3, 3 ) ); // xyz
|
||||
this.setAttribute( 'instanceStart', new THREE.InterleavedBufferAttribute( instanceBuffer, 3, 0 ) ); // xyz
|
||||
this.setAttribute( 'instanceEnd', new THREE.InterleavedBufferAttribute( instanceBuffer, 3, 3 ) ); // xyz
|
||||
|
||||
//
|
||||
|
||||
@ -103,8 +103,8 @@ THREE.LineSegmentsGeometry.prototype = Object.assign( Object.create( THREE.Insta
|
||||
|
||||
var instanceColorBuffer = new THREE.InstancedInterleavedBuffer( colors, 6, 1 ); // rgb, rgb
|
||||
|
||||
this.addAttribute( 'instanceColorStart', new THREE.InterleavedBufferAttribute( instanceColorBuffer, 3, 0 ) ); // rgb
|
||||
this.addAttribute( 'instanceColorEnd', new THREE.InterleavedBufferAttribute( instanceColorBuffer, 3, 3 ) ); // rgb
|
||||
this.setAttribute( 'instanceColorStart', new THREE.InterleavedBufferAttribute( instanceColorBuffer, 3, 0 ) ); // rgb
|
||||
this.setAttribute( 'instanceColorEnd', new THREE.InterleavedBufferAttribute( instanceColorBuffer, 3, 3 ) ); // rgb
|
||||
|
||||
return this;
|
||||
|
||||
@ -308,8 +308,8 @@ THREE.LineSegments2.prototype = Object.assign( Object.create( THREE.Mesh.prototy
|
||||
|
||||
var instanceDistanceBuffer = new THREE.InstancedInterleavedBuffer( lineDistances, 2, 1 ); // d0, d1
|
||||
|
||||
geometry.addAttribute( 'instanceDistanceStart', new THREE.InterleavedBufferAttribute( instanceDistanceBuffer, 1, 0 ) ); // d0
|
||||
geometry.addAttribute( 'instanceDistanceEnd', new THREE.InterleavedBufferAttribute( instanceDistanceBuffer, 1, 1 ) ); // d1
|
||||
geometry.setAttribute( 'instanceDistanceStart', new THREE.InterleavedBufferAttribute( instanceDistanceBuffer, 1, 0 ) ); // d0
|
||||
geometry.setAttribute( 'instanceDistanceEnd', new THREE.InterleavedBufferAttribute( instanceDistanceBuffer, 1, 1 ) ); // d1
|
||||
|
||||
return this;
|
||||
|
||||
|
||||
@ -45,8 +45,8 @@ THREE.LineSegments2.prototype = Object.assign( Object.create( THREE.Mesh.prototy
|
||||
|
||||
var instanceDistanceBuffer = new THREE.InstancedInterleavedBuffer( lineDistances, 2, 1 ); // d0, d1
|
||||
|
||||
geometry.addAttribute( 'instanceDistanceStart', new THREE.InterleavedBufferAttribute( instanceDistanceBuffer, 1, 0 ) ); // d0
|
||||
geometry.addAttribute( 'instanceDistanceEnd', new THREE.InterleavedBufferAttribute( instanceDistanceBuffer, 1, 1 ) ); // d1
|
||||
geometry.setAttribute( 'instanceDistanceStart', new THREE.InterleavedBufferAttribute( instanceDistanceBuffer, 1, 0 ) ); // d0
|
||||
geometry.setAttribute( 'instanceDistanceEnd', new THREE.InterleavedBufferAttribute( instanceDistanceBuffer, 1, 1 ) ); // d1
|
||||
|
||||
return this;
|
||||
|
||||
|
||||
@ -14,8 +14,8 @@ THREE.LineSegmentsGeometry = function () {
|
||||
var index = [ 0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3, 4, 6, 5, 6, 7, 5 ];
|
||||
|
||||
this.setIndex( index );
|
||||
this.addAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) );
|
||||
this.addAttribute( 'uv', new THREE.Float32BufferAttribute( uvs, 2 ) );
|
||||
this.setAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) );
|
||||
this.setAttribute( 'uv', new THREE.Float32BufferAttribute( uvs, 2 ) );
|
||||
|
||||
};
|
||||
|
||||
@ -72,8 +72,8 @@ THREE.LineSegmentsGeometry.prototype = Object.assign( Object.create( THREE.Insta
|
||||
|
||||
var instanceBuffer = new THREE.InstancedInterleavedBuffer( lineSegments, 6, 1 ); // xyz, xyz
|
||||
|
||||
this.addAttribute( 'instanceStart', new THREE.InterleavedBufferAttribute( instanceBuffer, 3, 0 ) ); // xyz
|
||||
this.addAttribute( 'instanceEnd', new THREE.InterleavedBufferAttribute( instanceBuffer, 3, 3 ) ); // xyz
|
||||
this.setAttribute( 'instanceStart', new THREE.InterleavedBufferAttribute( instanceBuffer, 3, 0 ) ); // xyz
|
||||
this.setAttribute( 'instanceEnd', new THREE.InterleavedBufferAttribute( instanceBuffer, 3, 3 ) ); // xyz
|
||||
|
||||
//
|
||||
|
||||
@ -100,8 +100,8 @@ THREE.LineSegmentsGeometry.prototype = Object.assign( Object.create( THREE.Insta
|
||||
|
||||
var instanceColorBuffer = new THREE.InstancedInterleavedBuffer( colors, 6, 1 ); // rgb, rgb
|
||||
|
||||
this.addAttribute( 'instanceColorStart', new THREE.InterleavedBufferAttribute( instanceColorBuffer, 3, 0 ) ); // rgb
|
||||
this.addAttribute( 'instanceColorEnd', new THREE.InterleavedBufferAttribute( instanceColorBuffer, 3, 3 ) ); // rgb
|
||||
this.setAttribute( 'instanceColorStart', new THREE.InterleavedBufferAttribute( instanceColorBuffer, 3, 0 ) ); // rgb
|
||||
this.setAttribute( 'instanceColorEnd', new THREE.InterleavedBufferAttribute( instanceColorBuffer, 3, 3 ) ); // rgb
|
||||
|
||||
return this;
|
||||
|
||||
|
||||
@ -45,8 +45,8 @@ THREE.Wireframe.prototype = Object.assign( Object.create( THREE.Mesh.prototype )
|
||||
|
||||
var instanceDistanceBuffer = new THREE.InstancedInterleavedBuffer( lineDistances, 2, 1 ); // d0, d1
|
||||
|
||||
geometry.addAttribute( 'instanceDistanceStart', new THREE.InterleavedBufferAttribute( instanceDistanceBuffer, 1, 0 ) ); // d0
|
||||
geometry.addAttribute( 'instanceDistanceEnd', new THREE.InterleavedBufferAttribute( instanceDistanceBuffer, 1, 1 ) ); // d1
|
||||
geometry.setAttribute( 'instanceDistanceStart', new THREE.InterleavedBufferAttribute( instanceDistanceBuffer, 1, 0 ) ); // d0
|
||||
geometry.setAttribute( 'instanceDistanceEnd', new THREE.InterleavedBufferAttribute( instanceDistanceBuffer, 1, 1 ) ); // d1
|
||||
|
||||
return this;
|
||||
|
||||
|
||||
@ -67,7 +67,7 @@ export class PointCloudOctreeNode extends PointCloudTreeNode {
|
||||
let stride = buffer.stride;
|
||||
let view = new DataView(buffer.data);
|
||||
|
||||
let worldToBox = new THREE.Matrix4().getInverse(boxNode.matrixWorld);
|
||||
let worldToBox = boxNode.matrixWorld.clone().invert();
|
||||
let objectToBox = new THREE.Matrix4().multiplyMatrices(worldToBox, this.sceneNode.matrixWorld);
|
||||
|
||||
let inBox = [];
|
||||
@ -426,7 +426,7 @@ export class PointCloudOctree extends PointCloudTree {
|
||||
|
||||
deepestNodeAt(position){
|
||||
|
||||
const toObjectSpace = new THREE.Matrix4().getInverse(this.matrixWorld);
|
||||
const toObjectSpace = this.matrixWorld.clone().invert();
|
||||
|
||||
const objPos = position.clone().applyMatrix4(toObjectSpace);
|
||||
|
||||
@ -462,8 +462,6 @@ export class PointCloudOctree extends PointCloudTree {
|
||||
let _ray = ray.clone();
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
let node = nodes[i];
|
||||
// let inverseWorld = new THREE.Matrix4().getInverse(node.matrixWorld);
|
||||
// let sphere = node.getBoundingSphere().clone().applyMatrix4(node.sceneNode.matrixWorld);
|
||||
let sphere = node.getBoundingSphere().clone().applyMatrix4(this.matrixWorld);
|
||||
|
||||
if (_ray.intersectsSphere(sphere)) {
|
||||
@ -706,7 +704,7 @@ export class PointCloudOctree extends PointCloudTree {
|
||||
const sdf = this.signedDistanceField;
|
||||
const boundingBox = this.boundingBox;
|
||||
|
||||
const toObjectSpace = new THREE.Matrix4().getInverse(this.matrixWorld);
|
||||
const toObjectSpace = this.matrixWorld.clone().invert();
|
||||
|
||||
const objPos = position.clone().applyMatrix4(toObjectSpace);
|
||||
|
||||
@ -1016,7 +1014,7 @@ export class PointCloudOctree extends PointCloudTree {
|
||||
let start = performance.now();
|
||||
|
||||
let shrinkedLocalBounds = new THREE.Box3();
|
||||
let worldToBox = new THREE.Matrix4().getInverse(boxNode.matrixWorld);
|
||||
let worldToBox = boxNode.matrixWorld.clone().invert();
|
||||
|
||||
for(let node of this.visibleNodes){
|
||||
if(!node.sceneNode){
|
||||
@ -1075,7 +1073,7 @@ export class PointCloudOctree extends PointCloudTree {
|
||||
let start = performance.now();
|
||||
|
||||
let shrinkedLocalBounds = new THREE.Box3();
|
||||
let worldToBox = new THREE.Matrix4().getInverse(boxNode.matrixWorld);
|
||||
let worldToBox = boxNode.matrixWorld.clone().invert();
|
||||
|
||||
for(let node of this.visibleNodes){
|
||||
if(!node.sceneNode || node.getLevel() > maxLevel){
|
||||
|
||||
@ -1037,8 +1037,8 @@ export class Renderer {
|
||||
let view = camera.matrixWorldInverse;
|
||||
let viewInv = camera.matrixWorld;
|
||||
let proj = camera.projectionMatrix;
|
||||
let projInv = new THREE.Matrix4().getInverse(proj);
|
||||
let worldView = new THREE.Matrix4();
|
||||
let projInv = proj.clone().invert();
|
||||
//let worldView = new THREE.Matrix4();
|
||||
|
||||
let shader = null;
|
||||
let visibilityTextureData = null;
|
||||
@ -1254,7 +1254,7 @@ export class Renderer {
|
||||
//let clipToWorld = new THREE.Matrix4().multiplyMatrices(mTranslate, mScale);
|
||||
let clipToWorld = clipSphere.matrixWorld;
|
||||
let viewToWorld = camera.matrixWorld
|
||||
let worldToClip = new THREE.Matrix4().getInverse(clipToWorld);
|
||||
let worldToClip = clipToWorld.clone().invert();
|
||||
|
||||
let viewToClip = new THREE.Matrix4().multiplyMatrices(worldToClip, viewToWorld);
|
||||
|
||||
@ -1443,7 +1443,9 @@ export class Renderer {
|
||||
|
||||
// CLEANUP
|
||||
gl.activeTexture(gl.TEXTURE1);
|
||||
gl.bindTexture(gl.TEXTURE_2D, null)
|
||||
gl.bindTexture(gl.TEXTURE_2D, null);
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
||||
gl.bindVertexArray(null);
|
||||
|
||||
this.threeRenderer.state.reset();
|
||||
}
|
||||
|
||||
@ -64,12 +64,12 @@ export function updateVisibilityStructures(pointclouds, camera, renderer) {
|
||||
let proj = camera.projectionMatrix;
|
||||
|
||||
let fm = new THREE.Matrix4().multiply(proj).multiply(viewI).multiply(world);
|
||||
frustum.setFromMatrix(fm);
|
||||
frustum.setFromProjectionMatrix(fm);
|
||||
frustums.push(frustum);
|
||||
|
||||
// camera position in object space
|
||||
let view = camera.matrixWorld;
|
||||
let worldI = new THREE.Matrix4().getInverse(world);
|
||||
let worldI = world.clone().invert();
|
||||
let camMatrixObject = new THREE.Matrix4().multiply(worldI).multiply(view);
|
||||
let camObjPos = new THREE.Vector3().setFromMatrixPosition(camMatrixObject);
|
||||
camObjPositions.push(camObjPos);
|
||||
@ -194,7 +194,7 @@ export function updateVisibility(pointclouds, camera, renderer){
|
||||
|
||||
for(let clipBox of clipBoxes){
|
||||
|
||||
let pcWorldInverse = new THREE.Matrix4().getInverse(pointcloud.matrixWorld);
|
||||
let pcWorldInverse = pointcloud.matrixWorld.clone().invert();
|
||||
let toPCObject = pcWorldInverse.multiply(clipBox.box.matrixWorld);
|
||||
|
||||
let px = new THREE.Vector3(+0.5, 0, 0).applyMatrix4(pcWorldInverse);
|
||||
|
||||
@ -141,14 +141,14 @@ Potree.PointCloudArena4DGeometryNode = class PointCloudArena4DGeometryNode{
|
||||
|
||||
let geometry = new THREE.BufferGeometry();
|
||||
|
||||
geometry.addAttribute('position', new THREE.BufferAttribute(position, 3));
|
||||
geometry.addAttribute('color', new THREE.BufferAttribute(color, 4, true));
|
||||
geometry.addAttribute('intensity', new THREE.BufferAttribute(intensities, 1));
|
||||
geometry.addAttribute('classification', new THREE.BufferAttribute(classifications, 1));
|
||||
geometry.setAttribute('position', new THREE.BufferAttribute(position, 3));
|
||||
geometry.setAttribute('color', new THREE.BufferAttribute(color, 4, true));
|
||||
geometry.setAttribute('intensity', new THREE.BufferAttribute(intensities, 1));
|
||||
geometry.setAttribute('classification', new THREE.BufferAttribute(classifications, 1));
|
||||
{
|
||||
let bufferAttribute = new THREE.BufferAttribute(new Uint8Array(indices), 4, true);
|
||||
//bufferAttribute.normalized = true;
|
||||
geometry.addAttribute('indices', bufferAttribute);
|
||||
geometry.setAttribute('indices', bufferAttribute);
|
||||
}
|
||||
|
||||
node.geometry = geometry;
|
||||
|
||||
@ -80,22 +80,22 @@ export class BinaryLoader{
|
||||
let batchAttribute = buffers[property].attribute;
|
||||
|
||||
if (property === "POSITION_CARTESIAN") {
|
||||
geometry.addAttribute('position', new THREE.BufferAttribute(new Float32Array(buffer), 3));
|
||||
geometry.setAttribute('position', new THREE.BufferAttribute(new Float32Array(buffer), 3));
|
||||
} else if (property === "rgba") {
|
||||
geometry.addAttribute("rgba", new THREE.BufferAttribute(new Uint8Array(buffer), 4, true));
|
||||
geometry.setAttribute("rgba", new THREE.BufferAttribute(new Uint8Array(buffer), 4, true));
|
||||
} else if (property === "NORMAL_SPHEREMAPPED") {
|
||||
geometry.addAttribute('normal', new THREE.BufferAttribute(new Float32Array(buffer), 3));
|
||||
geometry.setAttribute('normal', new THREE.BufferAttribute(new Float32Array(buffer), 3));
|
||||
} else if (property === "NORMAL_OCT16") {
|
||||
geometry.addAttribute('normal', new THREE.BufferAttribute(new Float32Array(buffer), 3));
|
||||
geometry.setAttribute('normal', new THREE.BufferAttribute(new Float32Array(buffer), 3));
|
||||
} else if (property === "NORMAL") {
|
||||
geometry.addAttribute('normal', new THREE.BufferAttribute(new Float32Array(buffer), 3));
|
||||
geometry.setAttribute('normal', new THREE.BufferAttribute(new Float32Array(buffer), 3));
|
||||
} else if (property === "INDICES") {
|
||||
let bufferAttribute = new THREE.BufferAttribute(new Uint8Array(buffer), 4);
|
||||
bufferAttribute.normalized = true;
|
||||
geometry.addAttribute('indices', bufferAttribute);
|
||||
geometry.setAttribute('indices', bufferAttribute);
|
||||
} else if (property === "SPACING") {
|
||||
let bufferAttribute = new THREE.BufferAttribute(new Float32Array(buffer), 1);
|
||||
geometry.addAttribute('spacing', bufferAttribute);
|
||||
geometry.setAttribute('spacing', bufferAttribute);
|
||||
} else {
|
||||
const bufferAttribute = new THREE.BufferAttribute(new Float32Array(buffer), 1);
|
||||
|
||||
@ -106,7 +106,7 @@ export class BinaryLoader{
|
||||
range: batchAttribute.range,
|
||||
};
|
||||
|
||||
geometry.addAttribute(property, bufferAttribute);
|
||||
geometry.setAttribute(property, bufferAttribute);
|
||||
|
||||
const attribute = pointAttributes.attributes.find(a => a.name === batchAttribute.name);
|
||||
attribute.range[0] = Math.min(attribute.range[0], batchAttribute.range[0]);
|
||||
|
||||
@ -142,14 +142,14 @@ export class LasLazBatcher{
|
||||
let pointSourceIDs = new Uint16Array(e.data.pointSourceID);
|
||||
let indices = new Uint8Array(e.data.indices);
|
||||
|
||||
geometry.addAttribute('position', new THREE.BufferAttribute(positions, 3));
|
||||
geometry.addAttribute('color', new THREE.BufferAttribute(colors, 4, true));
|
||||
geometry.addAttribute('intensity', new THREE.BufferAttribute(intensities, 1));
|
||||
geometry.addAttribute('classification', new THREE.BufferAttribute(classifications, 1));
|
||||
geometry.addAttribute('return number', new THREE.BufferAttribute(returnNumbers, 1));
|
||||
geometry.addAttribute('number of returns', new THREE.BufferAttribute(numberOfReturns, 1));
|
||||
geometry.addAttribute('source id', new THREE.BufferAttribute(pointSourceIDs, 1));
|
||||
geometry.addAttribute('indices', new THREE.BufferAttribute(indices, 4));
|
||||
geometry.setAttribute('position', new THREE.BufferAttribute(positions, 3));
|
||||
geometry.setAttribute('color', new THREE.BufferAttribute(colors, 4, true));
|
||||
geometry.setAttribute('intensity', new THREE.BufferAttribute(intensities, 1));
|
||||
geometry.setAttribute('classification', new THREE.BufferAttribute(classifications, 1));
|
||||
geometry.setAttribute('return number', new THREE.BufferAttribute(returnNumbers, 1));
|
||||
geometry.setAttribute('number of returns', new THREE.BufferAttribute(numberOfReturns, 1));
|
||||
geometry.setAttribute('source id', new THREE.BufferAttribute(pointSourceIDs, 1));
|
||||
geometry.setAttribute('indices', new THREE.BufferAttribute(indices, 4));
|
||||
geometry.attributes.indices.normalized = true;
|
||||
|
||||
for(const key in e.data.ranges){
|
||||
|
||||
@ -46,38 +46,38 @@ export class EptBinaryLoader {
|
||||
let numPoints = e.data.numPoints;
|
||||
|
||||
let position = new Float32Array(e.data.position);
|
||||
g.addAttribute('position', new THREE.BufferAttribute(position, 3));
|
||||
g.setAttribute('position', new THREE.BufferAttribute(position, 3));
|
||||
|
||||
let indices = new Uint8Array(e.data.indices);
|
||||
g.addAttribute('indices', new THREE.BufferAttribute(indices, 4));
|
||||
g.setAttribute('indices', new THREE.BufferAttribute(indices, 4));
|
||||
|
||||
if (e.data.color) {
|
||||
let color = new Uint8Array(e.data.color);
|
||||
g.addAttribute('color', new THREE.BufferAttribute(color, 4, true));
|
||||
g.setAttribute('color', new THREE.BufferAttribute(color, 4, true));
|
||||
}
|
||||
if (e.data.intensity) {
|
||||
let intensity = new Float32Array(e.data.intensity);
|
||||
g.addAttribute('intensity',
|
||||
g.setAttribute('intensity',
|
||||
new THREE.BufferAttribute(intensity, 1));
|
||||
}
|
||||
if (e.data.classification) {
|
||||
let classification = new Uint8Array(e.data.classification);
|
||||
g.addAttribute('classification',
|
||||
g.setAttribute('classification',
|
||||
new THREE.BufferAttribute(classification, 1));
|
||||
}
|
||||
if (e.data.returnNumber) {
|
||||
let returnNumber = new Uint8Array(e.data.returnNumber);
|
||||
g.addAttribute('return number',
|
||||
g.setAttribute('return number',
|
||||
new THREE.BufferAttribute(returnNumber, 1));
|
||||
}
|
||||
if (e.data.numberOfReturns) {
|
||||
let numberOfReturns = new Uint8Array(e.data.numberOfReturns);
|
||||
g.addAttribute('number of returns',
|
||||
g.setAttribute('number of returns',
|
||||
new THREE.BufferAttribute(numberOfReturns, 1));
|
||||
}
|
||||
if (e.data.pointSourceId) {
|
||||
let pointSourceId = new Uint16Array(e.data.pointSourceId);
|
||||
g.addAttribute('source id',
|
||||
g.setAttribute('source id',
|
||||
new THREE.BufferAttribute(pointSourceId, 1));
|
||||
}
|
||||
|
||||
|
||||
@ -121,23 +121,23 @@ export class EptLazBatcher {
|
||||
let indices = new Uint8Array(e.data.indices);
|
||||
let gpsTime = new Float32Array(e.data.gpsTime);
|
||||
|
||||
g.addAttribute('position',
|
||||
g.setAttribute('position',
|
||||
new THREE.BufferAttribute(positions, 3));
|
||||
g.addAttribute('rgba',
|
||||
g.setAttribute('rgba',
|
||||
new THREE.BufferAttribute(colors, 4, true));
|
||||
g.addAttribute('intensity',
|
||||
g.setAttribute('intensity',
|
||||
new THREE.BufferAttribute(intensities, 1));
|
||||
g.addAttribute('classification',
|
||||
g.setAttribute('classification',
|
||||
new THREE.BufferAttribute(classifications, 1));
|
||||
g.addAttribute('return number',
|
||||
g.setAttribute('return number',
|
||||
new THREE.BufferAttribute(returnNumbers, 1));
|
||||
g.addAttribute('number of returns',
|
||||
g.setAttribute('number of returns',
|
||||
new THREE.BufferAttribute(numberOfReturns, 1));
|
||||
g.addAttribute('source id',
|
||||
g.setAttribute('source id',
|
||||
new THREE.BufferAttribute(pointSourceIDs, 1));
|
||||
g.addAttribute('indices',
|
||||
g.setAttribute('indices',
|
||||
new THREE.BufferAttribute(indices, 4));
|
||||
g.addAttribute('gpsTime',
|
||||
g.setAttribute('gpsTime',
|
||||
new THREE.BufferAttribute(gpsTime, 1));
|
||||
this.node.gpsTime = e.data.gpsMeta;
|
||||
|
||||
|
||||
@ -199,7 +199,7 @@ export class OrientedImageControls extends EventDispatcher{
|
||||
|
||||
const proj = shearCam.projectionMatrix;
|
||||
proj.multiply(mShear);
|
||||
shearCam.projectionMatrixInverse.getInverse( proj );
|
||||
shearCam.projectionMatrixInverse.copy(proj).invert();
|
||||
|
||||
let total = shearCam.projectionMatrix.elements.reduce( (a, i) => a + i, 0);
|
||||
|
||||
|
||||
@ -78,16 +78,16 @@ export class NodeLoader{
|
||||
let buffer = buffers[property].buffer;
|
||||
|
||||
if(property === "position"){
|
||||
geometry.addAttribute('position', new THREE.BufferAttribute(new Float32Array(buffer), 3));
|
||||
geometry.setAttribute('position', new THREE.BufferAttribute(new Float32Array(buffer), 3));
|
||||
}else if(property === "rgba"){
|
||||
geometry.addAttribute('rgba', new THREE.BufferAttribute(new Uint8Array(buffer), 4, true));
|
||||
geometry.setAttribute('rgba', new THREE.BufferAttribute(new Uint8Array(buffer), 4, true));
|
||||
}else if(property === "NORMAL"){
|
||||
//geometry.addAttribute('rgba', new THREE.BufferAttribute(new Uint8Array(buffer), 4, true));
|
||||
geometry.addAttribute('normal', new THREE.BufferAttribute(new Float32Array(buffer), 3));
|
||||
//geometry.setAttribute('rgba', new THREE.BufferAttribute(new Uint8Array(buffer), 4, true));
|
||||
geometry.setAttribute('normal', new THREE.BufferAttribute(new Float32Array(buffer), 3));
|
||||
}else if (property === "INDICES") {
|
||||
let bufferAttribute = new THREE.BufferAttribute(new Uint8Array(buffer), 4);
|
||||
bufferAttribute.normalized = true;
|
||||
geometry.addAttribute('indices', bufferAttribute);
|
||||
geometry.setAttribute('indices', bufferAttribute);
|
||||
}else{
|
||||
const bufferAttribute = new THREE.BufferAttribute(new Float32Array(buffer), 1);
|
||||
|
||||
@ -99,7 +99,7 @@ export class NodeLoader{
|
||||
range: batchAttribute.range,
|
||||
};
|
||||
|
||||
geometry.addAttribute(property, bufferAttribute);
|
||||
geometry.setAttribute(property, bufferAttribute);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -673,17 +673,11 @@ export class InputHandler extends EventDispatcher {
|
||||
|
||||
let raycaster = new THREE.Raycaster();
|
||||
raycaster.ray.set(ray.origin, ray.direction);
|
||||
raycaster.linePrecision = 0.2;
|
||||
raycaster.params.Line.threshold = 0.2;
|
||||
|
||||
let intersections = raycaster.intersectObjects(interactables.filter(o => o.visible), false);
|
||||
|
||||
return intersections;
|
||||
|
||||
// if(intersections.length > 0){
|
||||
// return intersections[0];
|
||||
// }else{
|
||||
// return null;
|
||||
// }
|
||||
}
|
||||
|
||||
setScene (scene) {
|
||||
|
||||
@ -71,7 +71,7 @@ export class VRControlls{
|
||||
const geometry = new THREE.BufferGeometry();
|
||||
|
||||
geometry.setIndex( new THREE.BufferAttribute( indices, 1 ) );
|
||||
geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) );
|
||||
geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) );
|
||||
|
||||
geometry.computeBoundingSphere();
|
||||
|
||||
|
||||
@ -1059,7 +1059,7 @@ export class Utils {
|
||||
|
||||
Utils.screenPass = new function () {
|
||||
this.screenScene = new THREE.Scene();
|
||||
this.screenQuad = new THREE.Mesh(new THREE.PlaneBufferGeometry(2, 2, 0));
|
||||
this.screenQuad = new THREE.Mesh(new THREE.PlaneBufferGeometry(2, 2, 1));
|
||||
this.screenQuad.material.depthTest = true;
|
||||
this.screenQuad.material.depthWrite = true;
|
||||
this.screenQuad.material.transparent = true;
|
||||
|
||||
@ -26,7 +26,7 @@ export class Box3Helper extends THREE.LineSegments {
|
||||
|
||||
let geometry = new THREE.BufferGeometry();
|
||||
geometry.setIndex(new THREE.BufferAttribute(indices, 1));
|
||||
geometry.addAttribute('position', new THREE.BufferAttribute(positions, 3));
|
||||
geometry.setAttribute('position', new THREE.BufferAttribute(positions, 3));
|
||||
|
||||
let material = new THREE.LineBasicMaterial({ color: color });
|
||||
|
||||
|
||||
@ -244,7 +244,7 @@ export class ClipVolume extends THREE.Object3D{
|
||||
rotaxis = new THREE.Vector4(0, 0, 1, 0);
|
||||
}
|
||||
this.updateMatrixWorld();
|
||||
let invM = new THREE.Matrix4().getInverse(this.matrixWorld);
|
||||
let invM = newthis.matrixWorld.clone().invert();
|
||||
rotaxis = rotaxis.applyMatrix4(invM).normalize();
|
||||
rotaxis = new THREE.Vector3(rotaxis.x, rotaxis.y, rotaxis.z);
|
||||
this.rotateOnAxis(rotaxis, dir * this.clipRotOffset * Math.PI / 180);
|
||||
|
||||
@ -47,7 +47,7 @@ export class PointCloudSM{
|
||||
this.camera.updateProjectionMatrix();
|
||||
this.camera.updateMatrix();
|
||||
this.camera.updateMatrixWorld();
|
||||
this.camera.matrixWorldInverse.getInverse(this.camera.matrixWorld);
|
||||
this.camera.matrixWorldInverse.copy(this.camera.matrixWorld).invert();
|
||||
}
|
||||
|
||||
setSize(width, height){
|
||||
|
||||
@ -12,7 +12,7 @@ export class PolygonClipVolume extends THREE.Object3D{
|
||||
this.camera.rotation.order = camera.rotation.order;
|
||||
this.camera.updateMatrixWorld();
|
||||
this.camera.updateProjectionMatrix();
|
||||
this.camera.matrixWorldInverse.getInverse(this.camera.matrixWorld);
|
||||
this.camera.matrixWorldInverse.copy(this.camera.matrixWorld).invert();
|
||||
|
||||
this.viewMatrix = this.camera.matrixWorldInverse.clone();
|
||||
this.projMatrix = this.camera.projectionMatrix.clone();
|
||||
|
||||
@ -117,7 +117,7 @@ export class ScreenBoxSelectTool extends EventDispatcher{
|
||||
volCam.updateMatrix();
|
||||
volCam.updateMatrixWorld();
|
||||
volCam.updateProjectionMatrix();
|
||||
volCam.matrixWorldInverse.getInverse(volCam.matrixWorld);
|
||||
volCam.matrixWorldInverse.copy(volCam.matrixWorld).invert();
|
||||
|
||||
let ray = new THREE.Ray(volCam.getWorldPosition(new THREE.Vector3()), volCam.getWorldDirection(new THREE.Vector3()));
|
||||
let rayInverse = new THREE.Ray(
|
||||
@ -138,7 +138,7 @@ export class ScreenBoxSelectTool extends EventDispatcher{
|
||||
volCam.updateMatrix();
|
||||
volCam.updateMatrixWorld();
|
||||
volCam.updateProjectionMatrix();
|
||||
volCam.matrixWorldInverse.getInverse(volCam.matrixWorld);
|
||||
volCam.matrixWorldInverse.copy(volCam.matrixWorld).invert();
|
||||
let pointsFar = pointcloud.pick(viewer, volCam, rayInverse, pickerSettings);
|
||||
|
||||
allPointsNear.push(...pointsNear);
|
||||
|
||||
@ -37,7 +37,7 @@ export class SpotLightHelper extends THREE.Object3D{
|
||||
]);
|
||||
|
||||
let geometry = new THREE.BufferGeometry();
|
||||
geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
|
||||
geometry.setAttribute("position", new THREE.BufferAttribute(positions, 3));
|
||||
|
||||
let material = new THREE.LineBasicMaterial();
|
||||
|
||||
@ -73,26 +73,6 @@ export class SpotLightHelper extends THREE.Object3D{
|
||||
let coneWidth = coneLength * Math.tan( this.light.angle * 0.5 );
|
||||
|
||||
this.frustum.scale.set(coneWidth, coneWidth, coneLength);
|
||||
|
||||
|
||||
|
||||
//{
|
||||
// let fov = (180 * light.angle) / Math.PI;
|
||||
// let aspect = light.shadow.mapSize.width / light.shadow.mapSize.height;
|
||||
// let near = 0.1;
|
||||
// let far = light.distance === 0 ? 10000 : light.distance;
|
||||
// this.camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
|
||||
// this.camera.up.set(0, 0, 1);
|
||||
// this.camera.position.copy(light.position);
|
||||
|
||||
// let target = new THREE.Vector3().addVectors(light.position, light.getWorldDirection(new THREE.Vector3()));
|
||||
// this.camera.lookAt(target);
|
||||
|
||||
// this.camera.updateProjectionMatrix();
|
||||
// this.camera.updateMatrix();
|
||||
// this.camera.updateMatrixWorld();
|
||||
// this.camera.matrixWorldInverse.getInverse(this.camera.matrixWorld);
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -609,7 +609,7 @@ export class TransformationTool {
|
||||
let iOnLine = drag.line.closestPointToPoint(I, false, new THREE.Vector3());
|
||||
let direction = handle.alignment.reduce( (a, v) => a + v, 0);
|
||||
|
||||
let toObjectSpace = new THREE.Matrix4().getInverse( this.selection[0].matrixWorld);
|
||||
let toObjectSpace = this.selection[0].matrixWorld.clone().invert();
|
||||
let iOnLineOS = iOnLine.clone().applyMatrix4(toObjectSpace);
|
||||
let pivotOS = drag.pivot.clone().applyMatrix4(toObjectSpace);
|
||||
let diffOS = new THREE.Vector3().subVectors(iOnLineOS, pivotOS);
|
||||
@ -771,7 +771,7 @@ export class TransformationTool {
|
||||
let scale = new THREE.Vector3(s, s, s).divide(ws);
|
||||
|
||||
let rot = new THREE.Matrix4().makeRotationFromEuler(node.rotation);
|
||||
let rotInv = new THREE.Matrix4().getInverse(rot);
|
||||
let rotInv = rot.clone().invert();
|
||||
|
||||
scale.applyMatrix4(rotInv);
|
||||
scale.x = Math.abs(scale.x);
|
||||
@ -784,7 +784,7 @@ export class TransformationTool {
|
||||
// adjust rotation handles
|
||||
if(!this.dragging){
|
||||
let tWorld = this.scene.matrixWorld;
|
||||
let tObject = new THREE.Matrix4().getInverse(tWorld)
|
||||
let tObject = tWorld.clone().invert();
|
||||
let camObjectPos = camera.getWorldPosition(new THREE.Vector3()).applyMatrix4(tObject);
|
||||
|
||||
let x = this.rotationHandles["rotation.x"].node.rotation;
|
||||
|
||||
@ -177,7 +177,7 @@ export class EDLRenderer{
|
||||
}
|
||||
|
||||
viewer.shadowTestCam.updateMatrixWorld();
|
||||
viewer.shadowTestCam.matrixWorldInverse.getInverse(viewer.shadowTestCam.matrixWorld);
|
||||
viewer.shadowTestCam.matrixWorldInverse.copy(viewer.shadowTestCam.matrixWorld).invert();
|
||||
viewer.shadowTestCam.updateProjectionMatrix();
|
||||
}
|
||||
|
||||
|
||||
@ -1,9 +1,23 @@
|
||||
|
||||
|
||||
|
||||
|
||||
export class PotreeRenderer {
|
||||
|
||||
constructor (viewer) {
|
||||
this.viewer = viewer;
|
||||
this.renderer = viewer.renderer;
|
||||
|
||||
{
|
||||
let dummyScene = new THREE.Scene();
|
||||
let geometry = new THREE.SphereGeometry(0.001, 2, 2);
|
||||
let mesh = new THREE.Mesh(geometry, new THREE.MeshBasicMaterial());
|
||||
mesh.position.set(36453, 35163, 764712);
|
||||
dummyScene.add(mesh);
|
||||
|
||||
this.dummyMesh = mesh;
|
||||
this.dummyScene = dummyScene;
|
||||
}
|
||||
}
|
||||
|
||||
clearTargets(){
|
||||
@ -13,23 +27,21 @@ export class PotreeRenderer {
|
||||
clear(){
|
||||
let {viewer, renderer} = this;
|
||||
|
||||
|
||||
// render skybox
|
||||
if(viewer.background === "skybox"){
|
||||
renderer.setClearColor(0x000000, 0);
|
||||
renderer.clear(true, true, false);
|
||||
renderer.setClearColor(0xff0000, 1);
|
||||
}else if(viewer.background === "gradient"){
|
||||
renderer.setClearColor(0x000000, 0);
|
||||
renderer.clear(true, true, false);
|
||||
renderer.setClearColor(0x00ff00, 1);
|
||||
}else if(viewer.background === "black"){
|
||||
renderer.setClearColor(0x000000, 1);
|
||||
renderer.clear(true, true, false);
|
||||
}else if(viewer.background === "white"){
|
||||
renderer.setClearColor(0xFFFFFF, 1);
|
||||
renderer.clear(true, true, false);
|
||||
}else{
|
||||
renderer.setClearColor(0x000000, 0);
|
||||
renderer.clear(true, true, false);
|
||||
}
|
||||
|
||||
renderer.clear();
|
||||
}
|
||||
|
||||
render(params){
|
||||
@ -43,6 +55,17 @@ export class PotreeRenderer {
|
||||
const width = params.viewport ? params.viewport[2] : renderAreaSize.x;
|
||||
const height = params.viewport ? params.viewport[3] : renderAreaSize.y;
|
||||
|
||||
{
|
||||
// workaround for https://github.com/mrdoob/three.js/issues/20549
|
||||
// make sure vertex array object states get reset by rendering a dummy scene.
|
||||
|
||||
// that would be the nice version, but bindingStates is private
|
||||
renderer.bindingStates.reset()
|
||||
|
||||
// render dummy scene to reset vertex array object state
|
||||
//this.dummyMesh.position.copy(camera.position);
|
||||
//renderer.render(this.dummyScene, viewer.scene.cameraBG);
|
||||
}
|
||||
|
||||
// render skybox
|
||||
if(viewer.background === "skybox"){
|
||||
@ -54,11 +77,12 @@ export class PotreeRenderer {
|
||||
}else if(viewer.background === "gradient"){
|
||||
renderer.render(viewer.scene.sceneBG, viewer.scene.cameraBG);
|
||||
}
|
||||
|
||||
|
||||
|
||||
for(let pointcloud of this.viewer.scene.pointclouds){
|
||||
const {material} = pointcloud;
|
||||
material.useEDL = false;
|
||||
//material.updateShaderSource();
|
||||
}
|
||||
|
||||
viewer.pRenderer.render(viewer.scene.scenePointCloud, camera, null, {
|
||||
@ -92,14 +116,6 @@ export class PotreeRenderer {
|
||||
renderer.render(viewer.navigationCube, viewer.navigationCube.camera);
|
||||
renderer.setViewport(0, 0, width, height);
|
||||
|
||||
// renderer.render(viewer.transformationTool.scene, camera);
|
||||
|
||||
// renderer.setViewport(renderer.domElement.clientWidth - viewer.navigationCube.width,
|
||||
// renderer.domElement.clientHeight - viewer.navigationCube.width,
|
||||
// viewer.navigationCube.width, viewer.navigationCube.width);
|
||||
// renderer.render(viewer.navigationCube, viewer.navigationCube.camera);
|
||||
// renderer.setViewport(0, 0, renderer.domElement.clientWidth, renderer.domElement.clientHeight);
|
||||
|
||||
viewer.dispatchEvent({type: "render.pass.end",viewer: viewer});
|
||||
}
|
||||
|
||||
|
||||
@ -381,7 +381,7 @@ export class Scene extends EventDispatcher{
|
||||
texture.minFilter = texture.magFilter = THREE.NearestFilter;
|
||||
texture.minFilter = texture.magFilter = THREE.LinearFilter;
|
||||
let bg = new THREE.Mesh(
|
||||
new THREE.PlaneBufferGeometry(2, 2, 0),
|
||||
new THREE.PlaneBufferGeometry(2, 2, 1),
|
||||
new THREE.MeshBasicMaterial({
|
||||
map: texture
|
||||
})
|
||||
|
||||
@ -197,7 +197,7 @@ class ProfileFakeOctree extends PointCloudTree{
|
||||
range: [0, 1],
|
||||
};
|
||||
|
||||
geometry.addAttribute(attributeName, bufferAttribute);
|
||||
geometry.setAttribute(attributeName, bufferAttribute);
|
||||
}
|
||||
|
||||
geometry.drawRange.start = 0;
|
||||
@ -631,14 +631,17 @@ export class ProfileWindow extends EventDispatcher {
|
||||
{
|
||||
let gl = this.renderer.getContext();
|
||||
|
||||
let extVAO = gl.getExtension('OES_vertex_array_object');
|
||||
if(gl.createVertexArray == null){
|
||||
let extVAO = gl.getExtension('OES_vertex_array_object');
|
||||
|
||||
if(!extVAO){
|
||||
throw new Error("OES_vertex_array_object extension not supported");
|
||||
if(!extVAO){
|
||||
throw new Error("OES_vertex_array_object extension not supported");
|
||||
}
|
||||
|
||||
gl.createVertexArray = extVAO.createVertexArrayOES.bind(extVAO);
|
||||
gl.bindVertexArray = extVAO.bindVertexArrayOES.bind(extVAO);
|
||||
}
|
||||
|
||||
gl.createVertexArray = extVAO.createVertexArrayOES.bind(extVAO);
|
||||
gl.bindVertexArray = extVAO.bindVertexArrayOES.bind(extVAO);
|
||||
|
||||
}
|
||||
|
||||
this.camera = new THREE.OrthographicCamera(-1000, 1000, 1000, -1000, -1000, 1000);
|
||||
|
||||
@ -1339,7 +1339,7 @@ export class Viewer extends EventDispatcher{
|
||||
gl.getExtension('WEBGL_depth_texture');
|
||||
gl.getExtension('WEBGL_color_buffer_float'); // Enable explicitly for more portability, EXT_color_buffer_float is the proper name in WebGL 2
|
||||
|
||||
//if(gl instanceof WebGLRenderingContext){
|
||||
if(gl.createVertexArray == null){
|
||||
let extVAO = gl.getExtension('OES_vertex_array_object');
|
||||
|
||||
if(!extVAO){
|
||||
@ -1348,9 +1348,7 @@ export class Viewer extends EventDispatcher{
|
||||
|
||||
gl.createVertexArray = extVAO.createVertexArrayOES.bind(extVAO);
|
||||
gl.bindVertexArray = extVAO.bindVertexArrayOES.bind(extVAO);
|
||||
//}else if(gl instanceof WebGL2RenderingContext){
|
||||
// gl.getExtension("EXT_color_buffer_float");
|
||||
//}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1728,12 +1726,12 @@ export class Viewer extends EventDispatcher{
|
||||
|
||||
camera.updateMatrix();
|
||||
camera.updateMatrixWorld();
|
||||
camera.matrixWorldInverse.getInverse(camera.matrixWorld);
|
||||
camera.matrixWorldInverse.copy(camera.matrixWorld).invert();
|
||||
|
||||
{
|
||||
if(this._previousCamera === undefined){
|
||||
this._previousCamera = this.scene.getActiveCamera().clone();
|
||||
this._previousCamera.rotation.copy(this.scene.getActiveCamera());
|
||||
this._previousCamera.rotation.copy(this.scene.getActiveCamera().rotation);
|
||||
}
|
||||
|
||||
if(!this._previousCamera.matrixWorld.equals(camera.matrixWorld)){
|
||||
@ -1751,7 +1749,7 @@ export class Viewer extends EventDispatcher{
|
||||
}
|
||||
|
||||
this._previousCamera = this.scene.getActiveCamera().clone();
|
||||
this._previousCamera.rotation.copy(this.scene.getActiveCamera());
|
||||
this._previousCamera.rotation.copy(this.scene.getActiveCamera().rotation);
|
||||
|
||||
}
|
||||
|
||||
@ -1773,7 +1771,7 @@ export class Viewer extends EventDispatcher{
|
||||
let clipBoxes = boxes.filter(degenerate).map( box => {
|
||||
box.updateMatrixWorld();
|
||||
|
||||
let boxInverse = new THREE.Matrix4().getInverse(box.matrixWorld);
|
||||
let boxInverse = box.matrixWorld.clone().invert();
|
||||
let boxPosition = box.getWorldPosition(new THREE.Vector3());
|
||||
|
||||
return {box: box, inverse: boxInverse, position: boxPosition};
|
||||
@ -1894,7 +1892,7 @@ export class Viewer extends EventDispatcher{
|
||||
0, -1, 0, 0,
|
||||
0, 0, 0, 1
|
||||
]);
|
||||
const flipView = new THREE.Matrix4().getInverse(flipWorld);
|
||||
const flipView = flipWorld.clone().invert();
|
||||
|
||||
vr.node.updateMatrixWorld();
|
||||
|
||||
@ -1903,12 +1901,12 @@ export class Viewer extends EventDispatcher{
|
||||
|
||||
const leftView = new THREE.Matrix4().fromArray(frameData.leftViewMatrix);
|
||||
const view = new THREE.Matrix4().multiplyMatrices(leftView, flipView);
|
||||
const world = new THREE.Matrix4().getInverse(view);
|
||||
const world = view.clone().invert();
|
||||
|
||||
{
|
||||
const tmp = new THREE.Matrix4().multiplyMatrices(vr.node.matrixWorld, world);
|
||||
world.copy(tmp);
|
||||
view.getInverse(world);
|
||||
view.copy(world).invert();
|
||||
}
|
||||
|
||||
camera.matrixWorldInverse.copy(view);
|
||||
@ -1927,12 +1925,12 @@ export class Viewer extends EventDispatcher{
|
||||
|
||||
const rightView = new THREE.Matrix4().fromArray(frameData.rightViewMatrix);
|
||||
const view = new THREE.Matrix4().multiplyMatrices(rightView, flipView);
|
||||
const world = new THREE.Matrix4().getInverse(view);
|
||||
const world = view.clone().invert();
|
||||
|
||||
{
|
||||
const tmp = new THREE.Matrix4().multiplyMatrices(vr.node.matrixWorld, world);
|
||||
world.copy(tmp);
|
||||
view.getInverse(world);
|
||||
view.copy(world).invert;
|
||||
}
|
||||
|
||||
camera.matrixWorldInverse.copy(view);
|
||||
@ -1961,12 +1959,12 @@ export class Viewer extends EventDispatcher{
|
||||
}
|
||||
|
||||
const view = new THREE.Matrix4().multiplyMatrices(centerView, flipView);
|
||||
const world = new THREE.Matrix4().getInverse(view);
|
||||
const world = view.clone().invert();
|
||||
|
||||
{
|
||||
const tmp = new THREE.Matrix4().multiplyMatrices(vr.node.matrixWorld, world);
|
||||
world.copy(tmp);
|
||||
view.getInverse(world);
|
||||
view.copy(world).invert;
|
||||
}
|
||||
|
||||
camera.matrixWorldInverse.copy(view);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user