diff --git a/examples/heidentor.html b/examples/heidentor.html
index db356af3..b55d7219 100644
--- a/examples/heidentor.html
+++ b/examples/heidentor.html
@@ -55,10 +55,11 @@
viewer.setEDLEnabled(false);
viewer.setFOV(60);
- viewer.setPointBudget(3_000_000);
+ viewer.setPointBudget(1_000_000);
viewer.setMinNodeSize(0);
viewer.loadSettingsFromURL();
viewer.setBackground("skybox");
+ viewer.setShowBoundingBox(false);
viewer.setDescription(`Heidentor point cloud courtesy of Ludwig Boltzmann Institute - Archeological Prospection and Virtual Archeology (26M points)`);
@@ -103,13 +104,12 @@
// }
// }
- // {
- // let geometry = new THREE.PlaneBufferGeometry(10, 10, 10, 10);
- // let material = new THREE.MeshNormalMaterial();
- // let plane = new THREE.Mesh(geometry, material);
- // viewer.scene.scene.add(plane);
- // }
-
+ {
+ let geometry = new THREE.PlaneBufferGeometry(10, 10, 10, 10);
+ let material = new THREE.MeshNormalMaterial();
+ let plane = new THREE.Mesh(geometry, material);
+ viewer.scene.scene.add(plane);
+ }
{
let sg = new THREE.SphereGeometry(0.1, 32, 32);
@@ -124,7 +124,7 @@
{
let sm = new THREE.MeshBasicMaterial({color: 0xff0000});
let sphere = new THREE.Mesh(sg, sm);
- sphere.position.set(1, 0, 0);
+ sphere.position.set(2, 0, 0);
viewer.scene.scene.add(sphere);
}
@@ -132,7 +132,7 @@
{
let sm = new THREE.MeshBasicMaterial({color: 0x00ff00});
let sphere = new THREE.Mesh(sg, sm);
- sphere.position.set(0, 1, 0);
+ sphere.position.set(0, 2, 0);
viewer.scene.scene.add(sphere);
}
@@ -140,44 +140,122 @@
{
let sm = new THREE.MeshBasicMaterial({color: 0x0000ff});
let sphere = new THREE.Mesh(sg, sm);
- sphere.position.set(0, 0, 1);
+ sphere.position.set(0, 0, 2);
viewer.scene.scene.add(sphere);
}
}
- viewer.addEventListener("vr_start", () => {
- //console.log("vr start listener!!");
+ let controllers = [];
- let controller1 = viewer.renderer.xr.getController( 0 );
+ {
+ let controller = viewer.renderer.xr.getController( 0 );
let sg = new THREE.SphereGeometry(0.02, 32, 32);
let sm = new THREE.MeshNormalMaterial();
let sphere = new THREE.Mesh(sg, sm);
- controller1.add(sphere);
- controller1.visible = true;
-
- // controller1.addEventListener( 'selectstart', onSelectStart );
- // controller1.addEventListener( 'selectend', onSelectEnd );
+ controller.add(sphere);
+ controller.visible = true;
- viewer.sceneVR.add(controller1);
+ viewer.sceneVR.add(controller);
- controller1.addEventListener( 'connected', function ( event ) {
+ controller.addEventListener( 'connected', function ( event ) {
+ const xrInputSource = event.data;
+ controller.inputSource = xrInputSource;
});
- controller1.addEventListener( 'disconnected', function ( event ) {
- //viewer.scene.scene.remove(controller1);
+ controller.addEventListener( 'disconnected', function ( event ) {
+
});
- window.controller1 = controller1;
+ controller.addEventListener("selectstart", (event) => {
+ console.log(event);
+ });
+ controller.addEventListener("select", (event) => {
+ console.log("select!");
+ });
+
+ window.controller1 = controller;
+ controllers.push(controller);
+ }
+
+ {
+ let controller = viewer.renderer.xr.getController(1);
+
+ let sg = new THREE.SphereGeometry(0.02, 32, 32);
+ let sm = new THREE.MeshBasicMaterial({color: 0x00ff00});
+ let sphere = new THREE.Mesh(sg, sm);
+
+ controller.add(sphere);
+ controller.visible = true;
+ viewer.sceneVR.add(controller);
+ controller.addEventListener( 'connected', function ( event ) {
+ const xrInputSource = event.data;
+ controller.inputSource = xrInputSource;
+ });
+ controller.addEventListener( 'disconnected', function ( event ) {
+
+ });
+ window.controller2 = controller;
+ controllers.push(controller);
+ }
+
+ viewer.addEventListener("vr_start", () => {
});
+
+ // viewer.addEventListener("update_start", (event) => {
+
+ // //let left = controllers.find(c => c.inputSources?.handedness === "left");
+ // //let right = controllers.find(c => c.inputSources?.handedness === "right");
+
+ // let primary = viewer.renderer.xr.getController(0);
+ // let secondary = viewer.renderer.xr.getController(1);
+
+ // let computeMove = (controller) => {
+
+ // if(controller?.inputSource?.gamepad == null){
+ // return null;
+ // }
+
+ // let pad = controller.inputSource.gamepad;
+
+ // let axes = pad.axes;
+ // let opos = controller.position;
+ // let rotation = new THREE.Quaternion().setFromEuler(controller.rotation);
+
+ // const dir = new THREE.Vector3(0, 0, -1);
+ // dir.applyQuaternion(rotation);
+
+ // const amount = axes[1] * viewer.getMoveSpeed();
+
+ // const move = dir.clone().multiplyScalar(amount);
+
+ // return move;
+ // };
+
+ // let move = computeMove(primary);
+
+ // if(move){
+ // move.multiplyScalar(event.delta * 0.1);
+
+ // let pos = viewer.scene.view.position;
+ // let dir = viewer.scene.view.direction;
+
+ // viewer.scene.view.translate(move.x, move.y, move.z);
+ // console.log(`translate`, move);
+ // //pos.add(move);
+ // //viewer.sceneVR.position.add(move);
+ // }
+
+ // });
+
diff --git a/src/PointCloudOctree.js b/src/PointCloudOctree.js
index 57fa2408..ee6f6c19 100644
--- a/src/PointCloudOctree.js
+++ b/src/PointCloudOctree.js
@@ -316,37 +316,7 @@ export class PointCloudOctree extends PointCloudTree {
};
nodes.sort(sort);
- // code sample taken from three.js src/math/Ray.js
- let v1 = new THREE.Vector3();
- let intersectSphereBack = (ray, sphere) => {
- v1.subVectors( sphere.center, ray.origin );
- let tca = v1.dot( ray.direction );
- let d2 = v1.dot( v1 ) - tca * tca;
- let radius2 = sphere.radius * sphere.radius;
-
- if(d2 > radius2){
- return null;
- }
-
- let thc = Math.sqrt( radius2 - d2 );
-
- // t1 = second intersect point - exit point on back of sphere
- let t1 = tca + thc;
-
- if(t1 < 0 ){
- return null;
- }
-
- return t1;
- };
-
- let lodRanges = new Map();
- let leafNodeLodRanges = new Map();
-
- let bBox = new THREE.Box3();
- let bSphere = new THREE.Sphere();
let worldDir = new THREE.Vector3();
- let cameraRay = new THREE.Ray(camera.position, camera.getWorldDirection(worldDir));
let nodeMap = new Map();
let offsetsToChild = new Array(nodes.length).fill(Infinity);
@@ -372,9 +342,6 @@ export class PointCloudOctree extends PointCloudTree {
data[parentOffset * 4 + 2] = (offsetsToChild[parentOffset] % 256);
}
- // data[i * 4 + 3] = node.geometryNode.nodeType === 1 ? 1 : 0;
- // data[i * 4 + 3] = node.name.length - 1;
-
let density = node.geometryNode.density;
if(typeof density === "number"){
@@ -389,8 +356,6 @@ export class PointCloudOctree extends PointCloudTree {
}
- var a = 10;
-
if(Potree.measureTimings){
performance.mark("computeVisibilityTextureData-end");
performance.measure("render.computeVisibilityTextureData", "computeVisibilityTextureData-start", "computeVisibilityTextureData-end");
diff --git a/src/materials/shaders/pointcloud.vs b/src/materials/shaders/pointcloud.vs
index 06c8deb1..0d29a3ce 100644
--- a/src/materials/shaders/pointcloud.vs
+++ b/src/materials/shaders/pointcloud.vs
@@ -130,731 +130,733 @@ varying float vRadius;
varying float vPointSize;
-// float round(float number){
-// return floor(number + 0.5);
-// }
+float round(float number){
+ return floor(number + 0.5);
+}
-// //
-// // ### ######## ### ######## ######## #### ## ## ######## ###### #### ######## ######## ######
-// // ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
-// // ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
-// // ## ## ## ## ## ## ######## ## ## ## ## ###### ###### ## ## ###### ######
-// // ######### ## ## ######### ## ## ## ## ## ## ## ## ## ## ##
-// // ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
-// // ## ## ######## ## ## ## ## #### ### ######## ###### #### ######## ######## ######
-// //
+//
+// ### ######## ### ######## ######## #### ## ## ######## ###### #### ######## ######## ######
+// ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
+// ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
+// ## ## ## ## ## ## ######## ## ## ## ## ###### ###### ## ## ###### ######
+// ######### ## ## ######### ## ## ## ## ## ## ## ## ## ## ##
+// ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
+// ## ## ######## ## ## ## ## #### ### ######## ###### #### ######## ######## ######
+//
-// // ---------------------
-// // OCTREE
-// // ---------------------
+// ---------------------
+// OCTREE
+// ---------------------
-// #if (defined(adaptive_point_size) || defined(color_type_level_of_detail)) && defined(tree_type_octree)
-// /**
-// * number of 1-bits up to inclusive index position
-// * number is treated as if it were an integer in the range 0-255
-// *
-// */
-// int numberOfOnes(int number, int index){
-// int numOnes = 0;
-// int tmp = 128;
-// for(int i = 7; i >= 0; i--){
+#if (defined(adaptive_point_size) || defined(color_type_level_of_detail)) && defined(tree_type_octree)
+/**
+ * number of 1-bits up to inclusive index position
+ * number is treated as if it were an integer in the range 0-255
+ *
+ */
+int numberOfOnes(int number, int index){
+ int numOnes = 0;
+ int tmp = 128;
+ for(int i = 7; i >= 0; i--){
-// if(number >= tmp){
-// number = number - tmp;
+ if(number >= tmp){
+ number = number - tmp;
-// if(i <= index){
-// numOnes++;
-// }
-// }
+ if(i <= index){
+ numOnes++;
+ }
+ }
-// tmp = tmp / 2;
-// }
+ tmp = tmp / 2;
+ }
-// return numOnes;
-// }
+ return numOnes;
+}
-// /**
-// * checks whether the bit at index is 1
-// * number is treated as if it were an integer in the range 0-255
-// *
-// */
-// bool isBitSet(int number, int index){
+/**
+ * checks whether the bit at index is 1
+ * number is treated as if it were an integer in the range 0-255
+ *
+ */
+bool isBitSet(int number, int index){
-// // weird multi else if due to lack of proper array, int and bitwise support in WebGL 1.0
-// int powi = 1;
-// if(index == 0){
-// powi = 1;
-// }else if(index == 1){
-// powi = 2;
-// }else if(index == 2){
-// powi = 4;
-// }else if(index == 3){
-// powi = 8;
-// }else if(index == 4){
-// powi = 16;
-// }else if(index == 5){
-// powi = 32;
-// }else if(index == 6){
-// powi = 64;
-// }else if(index == 7){
-// powi = 128;
-// }else{
-// return false;
-// }
+ // weird multi else if due to lack of proper array, int and bitwise support in WebGL 1.0
+ int powi = 1;
+ if(index == 0){
+ powi = 1;
+ }else if(index == 1){
+ powi = 2;
+ }else if(index == 2){
+ powi = 4;
+ }else if(index == 3){
+ powi = 8;
+ }else if(index == 4){
+ powi = 16;
+ }else if(index == 5){
+ powi = 32;
+ }else if(index == 6){
+ powi = 64;
+ }else if(index == 7){
+ powi = 128;
+ }else{
+ return false;
+ }
-// int ndp = number / powi;
+ int ndp = number / powi;
-// return mod(float(ndp), 2.0) != 0.0;
-// }
+ return mod(float(ndp), 2.0) != 0.0;
+}
-// /**
-// * find the LOD at the point position
-// */
-// float getLOD(){
+/**
+ * find the LOD at the point position
+ */
+float getLOD(){
-// vec3 offset = vec3(0.0, 0.0, 0.0);
-// int iOffset = int(uVNStart);
-// float depth = uLevel;
-// for(float i = 0.0; i <= 30.0; i++){
-// float nodeSizeAtLevel = uOctreeSize / pow(2.0, i + uLevel + 0.0);
+ vec3 offset = vec3(0.0, 0.0, 0.0);
+ int iOffset = int(uVNStart);
+ float depth = uLevel;
+ for(float i = 0.0; i <= 30.0; i++){
+ float nodeSizeAtLevel = uOctreeSize / pow(2.0, i + uLevel + 0.0);
-// vec3 index3d = (position-offset) / nodeSizeAtLevel;
-// index3d = floor(index3d + 0.5);
-// int index = int(round(4.0 * index3d.x + 2.0 * index3d.y + index3d.z));
+ vec3 index3d = (position-offset) / nodeSizeAtLevel;
+ index3d = floor(index3d + 0.5);
+ int index = int(round(4.0 * index3d.x + 2.0 * index3d.y + index3d.z));
-// vec4 value = texture2D(visibleNodes, vec2(float(iOffset) / 2048.0, 0.0));
-// int mask = int(round(value.r * 255.0));
+ vec4 value = texture2D(visibleNodes, vec2(float(iOffset) / 2048.0, 0.0));
+ int mask = int(round(value.r * 255.0));
-// if(isBitSet(mask, index)){
-// // there are more visible child nodes at this position
-// int advanceG = int(round(value.g * 255.0)) * 256;
-// int advanceB = int(round(value.b * 255.0));
-// int advanceChild = numberOfOnes(mask, index - 1);
-// int advance = advanceG + advanceB + advanceChild;
+ if(isBitSet(mask, index)){
+ // there are more visible child nodes at this position
+ int advanceG = int(round(value.g * 255.0)) * 256;
+ int advanceB = int(round(value.b * 255.0));
+ int advanceChild = numberOfOnes(mask, index - 1);
+ int advance = advanceG + advanceB + advanceChild;
-// iOffset = iOffset + advance;
+ iOffset = iOffset + advance;
-// depth++;
-// }else{
-// // no more visible child nodes at this position
-// //return value.a * 255.0;
+ depth++;
+ }else{
+ // no more visible child nodes at this position
+ //return value.a * 255.0;
-// float lodOffset = (255.0 * value.a) / 10.0 - 10.0;
+ float lodOffset = (255.0 * value.a) / 10.0 - 10.0;
-// return depth + lodOffset;
-// }
+ return depth + lodOffset;
+ }
-// offset = offset + (vec3(1.0, 1.0, 1.0) * nodeSizeAtLevel * 0.5) * index3d;
-// }
+ offset = offset + (vec3(1.0, 1.0, 1.0) * nodeSizeAtLevel * 0.5) * index3d;
+ }
-// return depth;
-// }
+ return depth;
+}
-// float getSpacing(){
-// vec3 offset = vec3(0.0, 0.0, 0.0);
-// int iOffset = int(uVNStart);
-// float depth = uLevel;
-// float spacing = uNodeSpacing;
-// for(float i = 0.0; i <= 30.0; i++){
-// float nodeSizeAtLevel = uOctreeSize / pow(2.0, i + uLevel + 0.0);
+float getSpacing(){
+ vec3 offset = vec3(0.0, 0.0, 0.0);
+ int iOffset = int(uVNStart);
+ float depth = uLevel;
+ float spacing = uNodeSpacing;
+ for(float i = 0.0; i <= 30.0; i++){
+ float nodeSizeAtLevel = uOctreeSize / pow(2.0, i + uLevel + 0.0);
-// vec3 index3d = (position-offset) / nodeSizeAtLevel;
-// index3d = floor(index3d + 0.5);
-// int index = int(round(4.0 * index3d.x + 2.0 * index3d.y + index3d.z));
+ vec3 index3d = (position-offset) / nodeSizeAtLevel;
+ index3d = floor(index3d + 0.5);
+ int index = int(round(4.0 * index3d.x + 2.0 * index3d.y + index3d.z));
-// vec4 value = texture2D(visibleNodes, vec2(float(iOffset) / 2048.0, 0.0));
-// int mask = int(round(value.r * 255.0));
-// float spacingFactor = value.a;
+ vec4 value = texture2D(visibleNodes, vec2(float(iOffset) / 2048.0, 0.0));
+ int mask = int(round(value.r * 255.0));
+ float spacingFactor = value.a;
-// if(i > 0.0){
-// spacing = spacing / (255.0 * spacingFactor);
-// }
+ if(i > 0.0){
+ spacing = spacing / (255.0 * spacingFactor);
+ }
-// if(isBitSet(mask, index)){
-// // there are more visible child nodes at this position
-// int advanceG = int(round(value.g * 255.0)) * 256;
-// int advanceB = int(round(value.b * 255.0));
-// int advanceChild = numberOfOnes(mask, index - 1);
-// int advance = advanceG + advanceB + advanceChild;
+ if(isBitSet(mask, index)){
+ // there are more visible child nodes at this position
+ int advanceG = int(round(value.g * 255.0)) * 256;
+ int advanceB = int(round(value.b * 255.0));
+ int advanceChild = numberOfOnes(mask, index - 1);
+ int advance = advanceG + advanceB + advanceChild;
-// iOffset = iOffset + advance;
+ iOffset = iOffset + advance;
-// //spacing = spacing / (255.0 * spacingFactor);
-// //spacing = spacing / 3.0;
+ //spacing = spacing / (255.0 * spacingFactor);
+ //spacing = spacing / 3.0;
-// depth++;
-// }else{
-// // no more visible child nodes at this position
-// return spacing;
-// }
+ depth++;
+ }else{
+ // no more visible child nodes at this position
+ return spacing;
+ }
-// offset = offset + (vec3(1.0, 1.0, 1.0) * nodeSizeAtLevel * 0.5) * index3d;
-// }
+ offset = offset + (vec3(1.0, 1.0, 1.0) * nodeSizeAtLevel * 0.5) * index3d;
+ }
-// return spacing;
-// }
+ return spacing;
+}
-// float getPointSizeAttenuation(){
-// return pow(2.0, getLOD());
-// }
+float getPointSizeAttenuation(){
+ return pow(2.0, getLOD());
+}
-// #endif
+#endif
-// // ---------------------
-// // KD-TREE
-// // ---------------------
+// ---------------------
+// KD-TREE
+// ---------------------
-// #if (defined(adaptive_point_size) || defined(color_type_level_of_detail)) && defined(tree_type_kdtree)
+#if (defined(adaptive_point_size) || defined(color_type_level_of_detail)) && defined(tree_type_kdtree)
-// float getLOD(){
-// vec3 offset = vec3(0.0, 0.0, 0.0);
-// float iOffset = 0.0;
-// float depth = 0.0;
+float getLOD(){
+ vec3 offset = vec3(0.0, 0.0, 0.0);
+ float iOffset = 0.0;
+ float depth = 0.0;
-// vec3 size = uBBSize;
-// vec3 pos = position;
+ vec3 size = uBBSize;
+ vec3 pos = position;
-// for(float i = 0.0; i <= 1000.0; i++){
+ for(float i = 0.0; i <= 1000.0; i++){
-// vec4 value = texture2D(visibleNodes, vec2(iOffset / 2048.0, 0.0));
+ vec4 value = texture2D(visibleNodes, vec2(iOffset / 2048.0, 0.0));
-// int children = int(value.r * 255.0);
-// float next = value.g * 255.0;
-// int split = int(value.b * 255.0);
+ int children = int(value.r * 255.0);
+ float next = value.g * 255.0;
+ int split = int(value.b * 255.0);
-// if(next == 0.0){
-// return depth;
-// }
+ if(next == 0.0){
+ return depth;
+ }
-// vec3 splitv = vec3(0.0, 0.0, 0.0);
-// if(split == 1){
-// splitv.x = 1.0;
-// }else if(split == 2){
-// splitv.y = 1.0;
-// }else if(split == 4){
-// splitv.z = 1.0;
-// }
+ vec3 splitv = vec3(0.0, 0.0, 0.0);
+ if(split == 1){
+ splitv.x = 1.0;
+ }else if(split == 2){
+ splitv.y = 1.0;
+ }else if(split == 4){
+ splitv.z = 1.0;
+ }
-// iOffset = iOffset + next;
+ iOffset = iOffset + next;
-// float factor = length(pos * splitv / size);
-// if(factor < 0.5){
-// // left
-// if(children == 0 || children == 2){
-// return depth;
-// }
-// }else{
-// // right
-// pos = pos - size * splitv * 0.5;
-// if(children == 0 || children == 1){
-// return depth;
-// }
-// if(children == 3){
-// iOffset = iOffset + 1.0;
-// }
-// }
-// size = size * ((1.0 - (splitv + 1.0) / 2.0) + 0.5);
+ float factor = length(pos * splitv / size);
+ if(factor < 0.5){
+ // left
+ if(children == 0 || children == 2){
+ return depth;
+ }
+ }else{
+ // right
+ pos = pos - size * splitv * 0.5;
+ if(children == 0 || children == 1){
+ return depth;
+ }
+ if(children == 3){
+ iOffset = iOffset + 1.0;
+ }
+ }
+ size = size * ((1.0 - (splitv + 1.0) / 2.0) + 0.5);
-// depth++;
-// }
+ depth++;
+ }
-// return depth;
-// }
+ return depth;
+}
-// float getPointSizeAttenuation(){
-// return 0.5 * pow(1.3, getLOD());
-// }
+float getPointSizeAttenuation(){
+ return 0.5 * pow(1.3, getLOD());
+}
-// #endif
+#endif
-// //
-// // ### ######## ######## ######## #### ######## ## ## ######## ######## ######
-// // ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
-// // ## ## ## ## ## ## ## ## ## ## ## ## ## ##
-// // ## ## ## ## ######## ## ######## ## ## ## ###### ######
-// // ######### ## ## ## ## ## ## ## ## ## ## ## ##
-// // ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
-// // ## ## ## ## ## ## #### ######## ####### ## ######## ######
-// //
+//
+// ### ######## ######## ######## #### ######## ## ## ######## ######## ######
+// ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
+// ## ## ## ## ## ## ## ## ## ## ## ## ## ##
+// ## ## ## ## ######## ## ######## ## ## ## ###### ######
+// ######### ## ## ## ## ## ## ## ## ## ## ## ##
+// ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
+// ## ## ## ## ## ## #### ######## ####### ## ######## ######
+//
-// // formula adapted from: http://www.dfstudios.co.uk/articles/programming/image-programming-algorithms/image-processing-algorithms-part-5-contrast-adjustment/
-// float getContrastFactor(float contrast){
-// return (1.0158730158730156 * (contrast + 1.0)) / (1.0158730158730156 - contrast);
-// }
+// formula adapted from: http://www.dfstudios.co.uk/articles/programming/image-programming-algorithms/image-processing-algorithms-part-5-contrast-adjustment/
+float getContrastFactor(float contrast){
+ return (1.0158730158730156 * (contrast + 1.0)) / (1.0158730158730156 - contrast);
+}
-// vec3 getRGB(){
-// vec3 rgb = color;
+vec3 getRGB(){
+ vec3 rgb = color;
-// rgb = pow(rgb, vec3(uRGB_gbc.x));
-// rgb = rgb + uRGB_gbc.y;
-// rgb = (rgb - 0.5) * getContrastFactor(uRGB_gbc.z) + 0.5;
-// rgb = clamp(rgb, 0.0, 1.0);
+ rgb = pow(rgb, vec3(uRGB_gbc.x));
+ rgb = rgb + uRGB_gbc.y;
+ rgb = (rgb - 0.5) * getContrastFactor(uRGB_gbc.z) + 0.5;
+ rgb = clamp(rgb, 0.0, 1.0);
-// return rgb;
-// }
+ return rgb;
+}
-// float getIntensity(){
-// float w = (intensity - intensityRange.x) / (intensityRange.y - intensityRange.x);
-// w = pow(w, uIntensity_gbc.x);
-// w = w + uIntensity_gbc.y;
-// w = (w - 0.5) * getContrastFactor(uIntensity_gbc.z) + 0.5;
-// w = clamp(w, 0.0, 1.0);
+float getIntensity(){
+ float w = (intensity - intensityRange.x) / (intensityRange.y - intensityRange.x);
+ w = pow(w, uIntensity_gbc.x);
+ w = w + uIntensity_gbc.y;
+ w = (w - 0.5) * getContrastFactor(uIntensity_gbc.z) + 0.5;
+ w = clamp(w, 0.0, 1.0);
-// return w;
-// }
+ return w;
+}
-// vec3 getGpsTime(){
+vec3 getGpsTime(){
-// float w = (gpsTime + uGpsOffset) * uGpsScale;
+ float w = (gpsTime + uGpsOffset) * uGpsScale;
-// vec3 c = texture2D(gradient, vec2(w, 1.0 - w)).rgb;
+ vec3 c = texture2D(gradient, vec2(w, 1.0 - w)).rgb;
-// // vec2 r = uNormalizedGpsBufferRange;
-// // float w = gpsTime * (r.y - r.x) + r.x;
-// // w = clamp(w, 0.0, 1.0);
-// // vec3 c = texture2D(gradient, vec2(w,1.0-w)).rgb;
+ // vec2 r = uNormalizedGpsBufferRange;
+ // float w = gpsTime * (r.y - r.x) + r.x;
+ // w = clamp(w, 0.0, 1.0);
+ // vec3 c = texture2D(gradient, vec2(w,1.0-w)).rgb;
-// return c;
-// }
+ return c;
+}
-// vec3 getElevation(){
-// vec4 world = modelMatrix * vec4( position, 1.0 );
-// float w = (world.z - elevationRange.x) / (elevationRange.y - elevationRange.x);
-// vec3 cElevation = texture2D(gradient, vec2(w,1.0-w)).rgb;
+vec3 getElevation(){
+ vec4 world = modelMatrix * vec4( position, 1.0 );
+ float w = (world.z - elevationRange.x) / (elevationRange.y - elevationRange.x);
+ vec3 cElevation = texture2D(gradient, vec2(w,1.0-w)).rgb;
-// return cElevation;
-// }
+ return cElevation;
+}
-// vec4 getClassification(){
-// vec2 uv = vec2(classification / 255.0, 0.5);
-// vec4 classColor = texture2D(classificationLUT, uv);
+vec4 getClassification(){
+ vec2 uv = vec2(classification / 255.0, 0.5);
+ vec4 classColor = texture2D(classificationLUT, uv);
-// return classColor;
-// }
+ return classColor;
+}
-// vec3 getReturns(){
+vec3 getReturns(){
-// // 0b 00_000_111
-// float rn = mod(returnNumber, 8.0);
-// // 0b 00_111_000
-// float nr = mod(returnNumber / 8.0, 8.0);
+ // 0b 00_000_111
+ float rn = mod(returnNumber, 8.0);
+ // 0b 00_111_000
+ float nr = mod(returnNumber / 8.0, 8.0);
-// if(nr <= 1.0){
-// return vec3(1.0, 0.0, 0.0);
-// }else{
-// return vec3(0.0, 1.0, 0.0);
-// }
+ if(nr <= 1.0){
+ return vec3(1.0, 0.0, 0.0);
+ }else{
+ return vec3(0.0, 1.0, 0.0);
+ }
-// // return vec3(nr / 4.0, 0.0, 0.0);
+ // return vec3(nr / 4.0, 0.0, 0.0);
-// // if(nr == 1.0){
-// // return vec3(1.0, 1.0, 0.0);
-// // }else{
-// // if(rn == 1.0){
-// // return vec3(1.0, 0.0, 0.0);
-// // }else if(rn == nr){
-// // return vec3(0.0, 0.0, 1.0);
-// // }else{
-// // return vec3(0.0, 1.0, 0.0);
-// // }
-// // }
+ // if(nr == 1.0){
+ // return vec3(1.0, 1.0, 0.0);
+ // }else{
+ // if(rn == 1.0){
+ // return vec3(1.0, 0.0, 0.0);
+ // }else if(rn == nr){
+ // return vec3(0.0, 0.0, 1.0);
+ // }else{
+ // return vec3(0.0, 1.0, 0.0);
+ // }
+ // }
-// // if(numberOfReturns == 1.0){
-// // return vec3(1.0, 1.0, 0.0);
-// // }else{
-// // if(returnNumber == 1.0){
-// // return vec3(1.0, 0.0, 0.0);
-// // }else if(returnNumber == numberOfReturns){
-// // return vec3(0.0, 0.0, 1.0);
-// // }else{
-// // return vec3(0.0, 1.0, 0.0);
-// // }
-// // }
-// }
+ // if(numberOfReturns == 1.0){
+ // return vec3(1.0, 1.0, 0.0);
+ // }else{
+ // if(returnNumber == 1.0){
+ // return vec3(1.0, 0.0, 0.0);
+ // }else if(returnNumber == numberOfReturns){
+ // return vec3(0.0, 0.0, 1.0);
+ // }else{
+ // return vec3(0.0, 1.0, 0.0);
+ // }
+ // }
+}
-// vec3 getReturnNumber(){
-// if(numberOfReturns == 1.0){
-// return vec3(1.0, 1.0, 0.0);
-// }else{
-// if(returnNumber == 1.0){
-// return vec3(1.0, 0.0, 0.0);
-// }else if(returnNumber == numberOfReturns){
-// return vec3(0.0, 0.0, 1.0);
-// }else{
-// return vec3(0.0, 1.0, 0.0);
-// }
-// }
-// }
+vec3 getReturnNumber(){
+ if(numberOfReturns == 1.0){
+ return vec3(1.0, 1.0, 0.0);
+ }else{
+ if(returnNumber == 1.0){
+ return vec3(1.0, 0.0, 0.0);
+ }else if(returnNumber == numberOfReturns){
+ return vec3(0.0, 0.0, 1.0);
+ }else{
+ return vec3(0.0, 1.0, 0.0);
+ }
+ }
+}
-// vec3 getNumberOfReturns(){
-// float value = numberOfReturns;
+vec3 getNumberOfReturns(){
+ float value = numberOfReturns;
-// float w = value / 6.0;
+ float w = value / 6.0;
-// vec3 color = texture2D(gradient, vec2(w, 1.0 - w)).rgb;
+ vec3 color = texture2D(gradient, vec2(w, 1.0 - w)).rgb;
-// return color;
-// }
+ return color;
+}
-// vec3 getSourceID(){
-// float w = mod(pointSourceID, 10.0) / 10.0;
-// return texture2D(gradient, vec2(w,1.0 - w)).rgb;
-// }
+vec3 getSourceID(){
+ float w = mod(pointSourceID, 10.0) / 10.0;
+ return texture2D(gradient, vec2(w,1.0 - w)).rgb;
+}
-// vec3 getCompositeColor(){
-// vec3 c;
-// float w;
+vec3 getCompositeColor(){
+ vec3 c;
+ float w;
-// c += wRGB * getRGB();
-// w += wRGB;
+ c += wRGB * getRGB();
+ w += wRGB;
-// c += wIntensity * getIntensity() * vec3(1.0, 1.0, 1.0);
-// w += wIntensity;
+ c += wIntensity * getIntensity() * vec3(1.0, 1.0, 1.0);
+ w += wIntensity;
-// c += wElevation * getElevation();
-// w += wElevation;
+ c += wElevation * getElevation();
+ w += wElevation;
-// c += wReturnNumber * getReturnNumber();
-// w += wReturnNumber;
+ c += wReturnNumber * getReturnNumber();
+ w += wReturnNumber;
-// c += wSourceID * getSourceID();
-// w += wSourceID;
+ c += wSourceID * getSourceID();
+ w += wSourceID;
-// vec4 cl = wClassification * getClassification();
-// c += cl.a * cl.rgb;
-// w += wClassification * cl.a;
+ vec4 cl = wClassification * getClassification();
+ c += cl.a * cl.rgb;
+ w += wClassification * cl.a;
-// c = c / w;
+ c = c / w;
-// if(w == 0.0){
-// //c = color;
-// gl_Position = vec4(100.0, 100.0, 100.0, 0.0);
-// }
+ if(w == 0.0){
+ //c = color;
+ gl_Position = vec4(100.0, 100.0, 100.0, 0.0);
+ }
-// return c;
-// }
+ return c;
+}
-// vec3 getNormal(){
-// //vec3 n_hsv = vec3( modelMatrix * vec4( normal, 0.0 )) * 0.5 + 0.5; // (n_world.xyz + vec3(1.,1.,1.)) / 2.;
-// vec3 n_view = normalize( vec3(modelViewMatrix * vec4( normal, 0.0 )) );
-// return n_view;
-// }
-// bool applyBackfaceCulling() {
-// // Black not facing vertices / Backface culling
-// vec3 e = normalize(vec3(modelViewMatrix * vec4( position, 1. )));
-// vec3 n = getNormal(); // normalize( vec3(modelViewMatrix * vec4( normal, 0.0 )) );
+vec3 getNormal(){
+ //vec3 n_hsv = vec3( modelMatrix * vec4( normal, 0.0 )) * 0.5 + 0.5; // (n_world.xyz + vec3(1.,1.,1.)) / 2.;
+ vec3 n_view = normalize( vec3(modelViewMatrix * vec4( normal, 0.0 )) );
+ return n_view;
+}
+bool applyBackfaceCulling() {
+ // Black not facing vertices / Backface culling
+ vec3 e = normalize(vec3(modelViewMatrix * vec4( position, 1. )));
+ vec3 n = getNormal(); // normalize( vec3(modelViewMatrix * vec4( normal, 0.0 )) );
-// if((uUseOrthographicCamera && n.z <= 0.) || (!uUseOrthographicCamera && dot( n, e ) >= 0.)) {
-// return true;
-// } else {
-// return false;
-// }
-// }
+ if((uUseOrthographicCamera && n.z <= 0.) || (!uUseOrthographicCamera && dot( n, e ) >= 0.)) {
+ return true;
+ } else {
+ return false;
+ }
+}
-// #if defined(color_type_matcap)
-// // Matcap Material
-// vec3 getMatcap(){
-// vec3 eye = normalize( vec3( modelViewMatrix * vec4( position, 1. ) ) );
-// if(uUseOrthographicCamera) {
-// eye = vec3(0., 0., -1.);
-// }
-// vec3 r_en = reflect( eye, getNormal() ); // or r_en = e - 2. * dot( n, e ) * n;
-// float m = 2. * sqrt(pow( r_en.x, 2. ) + pow( r_en.y, 2. ) + pow( r_en.z + 1., 2. ));
-// vec2 vN = r_en.xy / m + .5;
-// return texture2D(matcapTextureUniform, vN).rgb;
-// }
-// #endif
+#if defined(color_type_matcap)
+// Matcap Material
+vec3 getMatcap(){
+ vec3 eye = normalize( vec3( modelViewMatrix * vec4( position, 1. ) ) );
+ if(uUseOrthographicCamera) {
+ eye = vec3(0., 0., -1.);
+ }
+ vec3 r_en = reflect( eye, getNormal() ); // or r_en = e - 2. * dot( n, e ) * n;
+ float m = 2. * sqrt(pow( r_en.x, 2. ) + pow( r_en.y, 2. ) + pow( r_en.z + 1., 2. ));
+ vec2 vN = r_en.xy / m + .5;
+ return texture2D(matcapTextureUniform, vN).rgb;
+}
+#endif
-// vec3 getExtra(){
+vec3 getExtra(){
-// float w = (aExtra + uExtraOffset) * uExtraScale;
-// w = clamp(w, 0.0, 1.0);
+ float w = (aExtra + uExtraOffset) * uExtraScale;
+ w = clamp(w, 0.0, 1.0);
-// vec3 color = texture2D(gradient, vec2(w,1.0-w)).rgb;
+ vec3 color = texture2D(gradient, vec2(w,1.0-w)).rgb;
-// // vec2 r = uExtraNormalizedRange;
+ // vec2 r = uExtraNormalizedRange;
-// // float w = aExtra * (r.y - r.x) + r.x;
+ // float w = aExtra * (r.y - r.x) + r.x;
-// // w = (w - uExtraRange.x) / (uExtraRange.y - uExtraRange.x);
+ // w = (w - uExtraRange.x) / (uExtraRange.y - uExtraRange.x);
-// // w = clamp(w, 0.0, 1.0);
+ // w = clamp(w, 0.0, 1.0);
-// // vec3 color = texture2D(gradient, vec2(w,1.0-w)).rgb;
+ // vec3 color = texture2D(gradient, vec2(w,1.0-w)).rgb;
-// return color;
-// }
+ return color;
+}
-// vec3 getColor(){
-// vec3 color;
+vec3 getColor(){
+ vec3 color;
-// #ifdef color_type_rgba
-// color = getRGB();
-// #elif defined color_type_height || defined color_type_elevation
-// color = getElevation();
-// #elif defined color_type_rgb_height
-// vec3 cHeight = getElevation();
-// color = (1.0 - uTransition) * getRGB() + uTransition * cHeight;
-// #elif defined color_type_depth
-// float linearDepth = gl_Position.w;
-// float expDepth = (gl_Position.z / gl_Position.w) * 0.5 + 0.5;
-// color = vec3(linearDepth, expDepth, 0.0);
-// //color = vec3(1.0, 0.5, 0.3);
-// #elif defined color_type_intensity
-// float w = getIntensity();
-// color = vec3(w, w, w);
-// #elif defined color_type_gps_time
-// color = getGpsTime();
-// #elif defined color_type_intensity_gradient
-// float w = getIntensity();
-// color = texture2D(gradient, vec2(w,1.0-w)).rgb;
-// #elif defined color_type_color
-// color = uColor;
-// #elif defined color_type_level_of_detail
-// float depth = getLOD();
-// float w = depth / 10.0;
-// color = texture2D(gradient, vec2(w,1.0-w)).rgb;
-// #elif defined color_type_indices
-// color = indices.rgb;
-// #elif defined color_type_classification
-// vec4 cl = getClassification();
-// color = cl.rgb;
-// #elif defined color_type_return_number
-// color = getReturnNumber();
-// #elif defined color_type_returns
-// color = getReturns();
-// #elif defined color_type_number_of_returns
-// color = getNumberOfReturns();
-// #elif defined color_type_source_id
-// color = getSourceID();
-// #elif defined color_type_point_source_id
-// color = getSourceID();
-// #elif defined color_type_normal
-// color = (modelMatrix * vec4(normal, 0.0)).xyz;
-// #elif defined color_type_phong
-// color = color;
-// #elif defined color_type_composite
-// color = getCompositeColor();
-// #elif defined color_type_matcap
-// color = getMatcap();
-// #else
-// color = getExtra();
-// #endif
+ #ifdef color_type_rgba
+ color = getRGB();
+ #elif defined color_type_height || defined color_type_elevation
+ color = getElevation();
+ #elif defined color_type_rgb_height
+ vec3 cHeight = getElevation();
+ color = (1.0 - uTransition) * getRGB() + uTransition * cHeight;
+ #elif defined color_type_depth
+ float linearDepth = gl_Position.w;
+ float expDepth = (gl_Position.z / gl_Position.w) * 0.5 + 0.5;
+ color = vec3(linearDepth, expDepth, 0.0);
+ //color = vec3(1.0, 0.5, 0.3);
+ #elif defined color_type_intensity
+ float w = getIntensity();
+ color = vec3(w, w, w);
+ #elif defined color_type_gps_time
+ color = getGpsTime();
+ #elif defined color_type_intensity_gradient
+ float w = getIntensity();
+ color = texture2D(gradient, vec2(w,1.0-w)).rgb;
+ #elif defined color_type_color
+ color = uColor;
+ #elif defined color_type_level_of_detail
+ float depth = getLOD();
+ float w = depth / 10.0;
+ color = texture2D(gradient, vec2(w,1.0-w)).rgb;
+ #elif defined color_type_indices
+ color = indices.rgb;
+ #elif defined color_type_classification
+ vec4 cl = getClassification();
+ color = cl.rgb;
+ #elif defined color_type_return_number
+ color = getReturnNumber();
+ #elif defined color_type_returns
+ color = getReturns();
+ #elif defined color_type_number_of_returns
+ color = getNumberOfReturns();
+ #elif defined color_type_source_id
+ color = getSourceID();
+ #elif defined color_type_point_source_id
+ color = getSourceID();
+ #elif defined color_type_normal
+ color = (modelMatrix * vec4(normal, 0.0)).xyz;
+ #elif defined color_type_phong
+ color = color;
+ #elif defined color_type_composite
+ color = getCompositeColor();
+ #elif defined color_type_matcap
+ color = getMatcap();
+ #else
+ color = getExtra();
+ #endif
-// if (backfaceCulling && applyBackfaceCulling()) {
-// color = vec3(0.);
-// }
+ if (backfaceCulling && applyBackfaceCulling()) {
+ color = vec3(0.);
+ }
-// return color;
-// }
+ return color;
+}
-// float getPointSize(){
-// float pointSize = 1.0;
+float getPointSize(){
+ float pointSize = 1.0;
-// float slope = tan(fov / 2.0);
-// float projFactor = -0.5 * uScreenHeight / (slope * vViewPosition.z);
+ float slope = tan(fov / 2.0);
+ float projFactor = -0.5 * uScreenHeight / (slope * vViewPosition.z);
+ float scale = (modelViewMatrix * vec4(0, 0, 0, 1) - modelViewMatrix * vec4(1, 0, 0, 1)).x;
+ projFactor = projFactor * scale;
-// float r = uOctreeSpacing * 1.7;
-// vRadius = r;
-// #if defined fixed_point_size
-// pointSize = size;
-// #elif defined attenuated_point_size
-// if(uUseOrthographicCamera){
-// pointSize = size;
-// }else{
-// pointSize = size * spacing * projFactor;
-// //pointSize = pointSize * projFactor;
-// }
-// #elif defined adaptive_point_size
-// if(uUseOrthographicCamera) {
-// float worldSpaceSize = 1.0 * size * r / getPointSizeAttenuation();
-// pointSize = (worldSpaceSize / uOrthoWidth) * uScreenWidth;
-// } else {
+ float r = uOctreeSpacing * 1.7;
+ vRadius = r;
+ #if defined fixed_point_size
+ pointSize = size;
+ #elif defined attenuated_point_size
+ if(uUseOrthographicCamera){
+ pointSize = size;
+ }else{
+ pointSize = size * spacing * projFactor;
+ //pointSize = pointSize * projFactor;
+ }
+ #elif defined adaptive_point_size
+ if(uUseOrthographicCamera) {
+ float worldSpaceSize = 1.0 * size * r / getPointSizeAttenuation();
+ pointSize = (worldSpaceSize / uOrthoWidth) * uScreenWidth;
+ } else {
-// // float leafSpacing = 0.122069092 * 8.0;
+ // float leafSpacing = 0.122069092 * 8.0;
-// // bool isLeafNode = getLOD() == 1000.0;
-// // if(isLeafNode){
-// // // pointSize = size * spacing * projFactor;
+ // bool isLeafNode = getLOD() == 1000.0;
+ // if(isLeafNode){
+ // // pointSize = size * spacing * projFactor;
-// // float worldSpaceSize = size * leafSpacing;
-// // pointSize = worldSpaceSize * projFactor;
-// // }else{
-// float worldSpaceSize = 1.0 * size * r / getPointSizeAttenuation();
+ // float worldSpaceSize = size * leafSpacing;
+ // pointSize = worldSpaceSize * projFactor;
+ // }else{
+ float worldSpaceSize = 1.0 * size * r / getPointSizeAttenuation();
-// // minimum world space size
-// // worldSpaceSize = max(worldSpaceSize, leafSpacing);
+ // minimum world space size
+ // worldSpaceSize = max(worldSpaceSize, leafSpacing);
-// pointSize = worldSpaceSize * projFactor;
-// // }
-// }
-// #endif
+ pointSize = worldSpaceSize * projFactor;
+ // }
+ }
+ #endif
-// pointSize = max(minSize, pointSize);
-// pointSize = min(maxSize, pointSize);
+ pointSize = max(minSize, pointSize);
+ pointSize = min(maxSize, pointSize);
-// vRadius = pointSize / projFactor;
+ vRadius = pointSize / projFactor;
-// return pointSize;
-// }
+ return pointSize;
+}
-// #if defined(num_clippolygons) && num_clippolygons > 0
-// bool pointInClipPolygon(vec3 point, int polyIdx) {
+#if defined(num_clippolygons) && num_clippolygons > 0
+bool pointInClipPolygon(vec3 point, int polyIdx) {
-// mat4 wvp = uClipPolygonWVP[polyIdx];
-// //vec4 screenClipPos = uClipPolygonVP[polyIdx] * modelMatrix * vec4(point, 1.0);
-// //screenClipPos.xy = screenClipPos.xy / screenClipPos.w * 0.5 + 0.5;
+ mat4 wvp = uClipPolygonWVP[polyIdx];
+ //vec4 screenClipPos = uClipPolygonVP[polyIdx] * modelMatrix * vec4(point, 1.0);
+ //screenClipPos.xy = screenClipPos.xy / screenClipPos.w * 0.5 + 0.5;
-// vec4 pointNDC = wvp * vec4(point, 1.0);
-// pointNDC.xy = pointNDC.xy / pointNDC.w;
+ vec4 pointNDC = wvp * vec4(point, 1.0);
+ pointNDC.xy = pointNDC.xy / pointNDC.w;
-// int j = uClipPolygonVCount[polyIdx] - 1;
-// bool c = false;
-// for(int i = 0; i < 8; i++) {
-// if(i == uClipPolygonVCount[polyIdx]) {
-// break;
-// }
+ int j = uClipPolygonVCount[polyIdx] - 1;
+ bool c = false;
+ for(int i = 0; i < 8; i++) {
+ if(i == uClipPolygonVCount[polyIdx]) {
+ break;
+ }
-// //vec4 verti = wvp * vec4(uClipPolygonVertices[polyIdx * 8 + i], 1);
-// //vec4 vertj = wvp * vec4(uClipPolygonVertices[polyIdx * 8 + j], 1);
+ //vec4 verti = wvp * vec4(uClipPolygonVertices[polyIdx * 8 + i], 1);
+ //vec4 vertj = wvp * vec4(uClipPolygonVertices[polyIdx * 8 + j], 1);
-// //verti.xy = verti.xy / verti.w;
-// //vertj.xy = vertj.xy / vertj.w;
+ //verti.xy = verti.xy / verti.w;
+ //vertj.xy = vertj.xy / vertj.w;
-// //verti.xy = verti.xy / verti.w * 0.5 + 0.5;
-// //vertj.xy = vertj.xy / vertj.w * 0.5 + 0.5;
+ //verti.xy = verti.xy / verti.w * 0.5 + 0.5;
+ //vertj.xy = vertj.xy / vertj.w * 0.5 + 0.5;
-// vec3 verti = uClipPolygonVertices[polyIdx * 8 + i];
-// vec3 vertj = uClipPolygonVertices[polyIdx * 8 + j];
+ vec3 verti = uClipPolygonVertices[polyIdx * 8 + i];
+ vec3 vertj = uClipPolygonVertices[polyIdx * 8 + j];
-// if( ((verti.y > pointNDC.y) != (vertj.y > pointNDC.y)) &&
-// (pointNDC.x < (vertj.x-verti.x) * (pointNDC.y-verti.y) / (vertj.y-verti.y) + verti.x) ) {
-// c = !c;
-// }
-// j = i;
-// }
+ if( ((verti.y > pointNDC.y) != (vertj.y > pointNDC.y)) &&
+ (pointNDC.x < (vertj.x-verti.x) * (pointNDC.y-verti.y) / (vertj.y-verti.y) + verti.x) ) {
+ c = !c;
+ }
+ j = i;
+ }
-// return c;
-// }
-// #endif
+ return c;
+}
+#endif
-// void doClipping(){
+void doClipping(){
-// {
-// vec4 cl = getClassification();
-// if(cl.a == 0.0){
-// gl_Position = vec4(100.0, 100.0, 100.0, 0.0);
+ {
+ vec4 cl = getClassification();
+ if(cl.a == 0.0){
+ gl_Position = vec4(100.0, 100.0, 100.0, 0.0);
-// return;
-// }
-// }
+ return;
+ }
+ }
-// #if defined(clip_return_number_enabled)
-// { // return number filter
-// vec2 range = uFilterReturnNumberRange;
-// if(returnNumber < range.x || returnNumber > range.y){
-// gl_Position = vec4(100.0, 100.0, 100.0, 0.0);
+ #if defined(clip_return_number_enabled)
+ { // return number filter
+ vec2 range = uFilterReturnNumberRange;
+ if(returnNumber < range.x || returnNumber > range.y){
+ gl_Position = vec4(100.0, 100.0, 100.0, 0.0);
-// return;
-// }
-// }
-// #endif
+ return;
+ }
+ }
+ #endif
-// #if defined(clip_number_of_returns_enabled)
-// { // number of return filter
-// vec2 range = uFilterNumberOfReturnsRange;
-// if(numberOfReturns < range.x || numberOfReturns > range.y){
-// gl_Position = vec4(100.0, 100.0, 100.0, 0.0);
+ #if defined(clip_number_of_returns_enabled)
+ { // number of return filter
+ vec2 range = uFilterNumberOfReturnsRange;
+ if(numberOfReturns < range.x || numberOfReturns > range.y){
+ gl_Position = vec4(100.0, 100.0, 100.0, 0.0);
-// return;
-// }
-// }
-// #endif
+ return;
+ }
+ }
+ #endif
-// #if defined(clip_gps_enabled)
-// { // GPS time filter
-// float time = (gpsTime + uGpsOffset) * uGpsScale;
-// vec2 range = uFilterGPSTimeClipRange;
+ #if defined(clip_gps_enabled)
+ { // GPS time filter
+ float time = (gpsTime + uGpsOffset) * uGpsScale;
+ vec2 range = uFilterGPSTimeClipRange;
-// if(time < range.x || time > range.y){
-// gl_Position = vec4(100.0, 100.0, 100.0, 0.0);
+ if(time < range.x || time > range.y){
+ gl_Position = vec4(100.0, 100.0, 100.0, 0.0);
-// return;
-// }
-// }
-// #endif
+ return;
+ }
+ }
+ #endif
-// #if defined(clip_point_source_id_enabled)
-// { // point source id filter
-// vec2 range = uFilterPointSourceIDClipRange;
-// if(pointSourceID < range.x || pointSourceID > range.y){
-// gl_Position = vec4(100.0, 100.0, 100.0, 0.0);
+ #if defined(clip_point_source_id_enabled)
+ { // point source id filter
+ vec2 range = uFilterPointSourceIDClipRange;
+ if(pointSourceID < range.x || pointSourceID > range.y){
+ gl_Position = vec4(100.0, 100.0, 100.0, 0.0);
-// return;
-// }
-// }
-// #endif
+ return;
+ }
+ }
+ #endif
-// int clipVolumesCount = 0;
-// int insideCount = 0;
+ int clipVolumesCount = 0;
+ int insideCount = 0;
-// #if defined(num_clipboxes) && num_clipboxes > 0
-// for(int i = 0; i < num_clipboxes; i++){
-// vec4 clipPosition = clipBoxes[i] * modelMatrix * vec4( position, 1.0 );
-// bool inside = -0.5 <= clipPosition.x && clipPosition.x <= 0.5;
-// inside = inside && -0.5 <= clipPosition.y && clipPosition.y <= 0.5;
-// inside = inside && -0.5 <= clipPosition.z && clipPosition.z <= 0.5;
+ #if defined(num_clipboxes) && num_clipboxes > 0
+ for(int i = 0; i < num_clipboxes; i++){
+ vec4 clipPosition = clipBoxes[i] * modelMatrix * vec4( position, 1.0 );
+ bool inside = -0.5 <= clipPosition.x && clipPosition.x <= 0.5;
+ inside = inside && -0.5 <= clipPosition.y && clipPosition.y <= 0.5;
+ inside = inside && -0.5 <= clipPosition.z && clipPosition.z <= 0.5;
-// insideCount = insideCount + (inside ? 1 : 0);
-// clipVolumesCount++;
-// }
-// #endif
+ insideCount = insideCount + (inside ? 1 : 0);
+ clipVolumesCount++;
+ }
+ #endif
-// #if defined(num_clippolygons) && num_clippolygons > 0
-// for(int i = 0; i < num_clippolygons; i++) {
-// bool inside = pointInClipPolygon(position, i);
+ #if defined(num_clippolygons) && num_clippolygons > 0
+ for(int i = 0; i < num_clippolygons; i++) {
+ bool inside = pointInClipPolygon(position, i);
-// insideCount = insideCount + (inside ? 1 : 0);
-// clipVolumesCount++;
-// }
-// #endif
+ insideCount = insideCount + (inside ? 1 : 0);
+ clipVolumesCount++;
+ }
+ #endif
-// bool insideAny = insideCount > 0;
-// bool insideAll = (clipVolumesCount > 0) && (clipVolumesCount == insideCount);
+ bool insideAny = insideCount > 0;
+ bool insideAll = (clipVolumesCount > 0) && (clipVolumesCount == insideCount);
-// if(clipMethod == CLIPMETHOD_INSIDE_ANY){
-// if(insideAny && clipTask == CLIPTASK_HIGHLIGHT){
-// vColor.r += 0.5;
-// }else if(!insideAny && clipTask == CLIPTASK_SHOW_INSIDE){
-// gl_Position = vec4(100.0, 100.0, 100.0, 1.0);
-// }else if(insideAny && clipTask == CLIPTASK_SHOW_OUTSIDE){
-// gl_Position = vec4(100.0, 100.0, 100.0, 1.0);
-// }
-// }else if(clipMethod == CLIPMETHOD_INSIDE_ALL){
-// if(insideAll && clipTask == CLIPTASK_HIGHLIGHT){
-// vColor.r += 0.5;
-// }else if(!insideAll && clipTask == CLIPTASK_SHOW_INSIDE){
-// gl_Position = vec4(100.0, 100.0, 100.0, 1.0);
-// }else if(insideAll && clipTask == CLIPTASK_SHOW_OUTSIDE){
-// gl_Position = vec4(100.0, 100.0, 100.0, 1.0);
-// }
-// }
-// }
+ if(clipMethod == CLIPMETHOD_INSIDE_ANY){
+ if(insideAny && clipTask == CLIPTASK_HIGHLIGHT){
+ vColor.r += 0.5;
+ }else if(!insideAny && clipTask == CLIPTASK_SHOW_INSIDE){
+ gl_Position = vec4(100.0, 100.0, 100.0, 1.0);
+ }else if(insideAny && clipTask == CLIPTASK_SHOW_OUTSIDE){
+ gl_Position = vec4(100.0, 100.0, 100.0, 1.0);
+ }
+ }else if(clipMethod == CLIPMETHOD_INSIDE_ALL){
+ if(insideAll && clipTask == CLIPTASK_HIGHLIGHT){
+ vColor.r += 0.5;
+ }else if(!insideAll && clipTask == CLIPTASK_SHOW_INSIDE){
+ gl_Position = vec4(100.0, 100.0, 100.0, 1.0);
+ }else if(insideAll && clipTask == CLIPTASK_SHOW_OUTSIDE){
+ gl_Position = vec4(100.0, 100.0, 100.0, 1.0);
+ }
+ }
+}
@@ -874,117 +876,117 @@ void main() {
gl_Position = projectionMatrix * mvPosition;
vLogDepth = log2(-mvPosition.z);
+ //gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
+ //gl_PointSize = 5.0;
+
// POINT SIZE
- //float pointSize = getPointSize();
- float pointSize = 2.0;
+ float pointSize = getPointSize();
+ //float pointSize = 2.0;
gl_PointSize = pointSize;
vPointSize = pointSize;
// COLOR
- // vColor = getColor();
- vColor = vec3(1.0, 0.0, 0.0);
+ vColor = getColor();
+ // vColor = vec3(1.0, 0.0, 0.0);
+
+ //gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
+ //gl_Position = vec4(position.xzy / 1000.0, 1.0 );
+
+ //gl_PointSize = 5.0;
+ //vColor = vec3(1.0, 1.0, 1.0);
+
+ // only for "replacing" approaches
+ // if(getLOD() != uLevel){
+ // gl_Position = vec4(10.0, 10.0, 10.0, 1.0);
+ // }
- // return;
+ #if defined hq_depth_pass
+ float originalDepth = gl_Position.w;
+ float adjustedDepth = originalDepth + 2.0 * vRadius;
+ float adjust = adjustedDepth / originalDepth;
- // //gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
- // //gl_Position = vec4(position.xzy / 1000.0, 1.0 );
-
- // //gl_PointSize = 5.0;
- // //vColor = vec3(1.0, 1.0, 1.0);
-
- // // only for "replacing" approaches
- // // if(getLOD() != uLevel){
- // // gl_Position = vec4(10.0, 10.0, 10.0, 1.0);
- // // }
+ mvPosition.xyz = mvPosition.xyz * adjust;
+ gl_Position = projectionMatrix * mvPosition;
+ #endif
- // #if defined hq_depth_pass
- // float originalDepth = gl_Position.w;
- // float adjustedDepth = originalDepth + 2.0 * vRadius;
- // float adjust = adjustedDepth / originalDepth;
+ // CLIPPING
+ doClipping();
- // mvPosition.xyz = mvPosition.xyz * adjust;
- // gl_Position = projectionMatrix * mvPosition;
- // #endif
+ #if defined(num_clipspheres) && num_clipspheres > 0
+ for(int i = 0; i < num_clipspheres; i++){
+ vec4 sphereLocal = uClipSpheres[i] * mvPosition;
+ float distance = length(sphereLocal.xyz);
- // // CLIPPING
- // doClipping();
-
- // #if defined(num_clipspheres) && num_clipspheres > 0
- // for(int i = 0; i < num_clipspheres; i++){
- // vec4 sphereLocal = uClipSpheres[i] * mvPosition;
-
- // float distance = length(sphereLocal.xyz);
-
- // if(distance < 1.0){
- // float w = distance;
- // vec3 cGradient = texture2D(gradient, vec2(w, 1.0 - w)).rgb;
+ if(distance < 1.0){
+ float w = distance;
+ vec3 cGradient = texture2D(gradient, vec2(w, 1.0 - w)).rgb;
- // vColor = cGradient;
- // //vColor = cGradient * 0.7 + vColor * 0.3;
- // }
- // }
- // #endif
+ vColor = cGradient;
+ //vColor = cGradient * 0.7 + vColor * 0.3;
+ }
+ }
+ #endif
- // #if defined(num_shadowmaps) && num_shadowmaps > 0
+ #if defined(num_shadowmaps) && num_shadowmaps > 0
- // const float sm_near = 0.1;
- // const float sm_far = 10000.0;
+ const float sm_near = 0.1;
+ const float sm_far = 10000.0;
- // for(int i = 0; i < num_shadowmaps; i++){
- // vec3 viewPos = (uShadowWorldView[i] * vec4(position, 1.0)).xyz;
- // float distanceToLight = abs(viewPos.z);
+ for(int i = 0; i < num_shadowmaps; i++){
+ vec3 viewPos = (uShadowWorldView[i] * vec4(position, 1.0)).xyz;
+ float distanceToLight = abs(viewPos.z);
- // vec4 projPos = uShadowProj[i] * uShadowWorldView[i] * vec4(position, 1);
- // vec3 nc = projPos.xyz / projPos.w;
+ vec4 projPos = uShadowProj[i] * uShadowWorldView[i] * vec4(position, 1);
+ vec3 nc = projPos.xyz / projPos.w;
- // float u = nc.x * 0.5 + 0.5;
- // float v = nc.y * 0.5 + 0.5;
+ float u = nc.x * 0.5 + 0.5;
+ float v = nc.y * 0.5 + 0.5;
- // vec2 sampleStep = vec2(1.0 / (2.0*1024.0), 1.0 / (2.0*1024.0)) * 1.5;
- // vec2 sampleLocations[9];
- // sampleLocations[0] = vec2(0.0, 0.0);
- // sampleLocations[1] = sampleStep;
- // sampleLocations[2] = -sampleStep;
- // sampleLocations[3] = vec2(sampleStep.x, -sampleStep.y);
- // sampleLocations[4] = vec2(-sampleStep.x, sampleStep.y);
+ vec2 sampleStep = vec2(1.0 / (2.0*1024.0), 1.0 / (2.0*1024.0)) * 1.5;
+ vec2 sampleLocations[9];
+ sampleLocations[0] = vec2(0.0, 0.0);
+ sampleLocations[1] = sampleStep;
+ sampleLocations[2] = -sampleStep;
+ sampleLocations[3] = vec2(sampleStep.x, -sampleStep.y);
+ sampleLocations[4] = vec2(-sampleStep.x, sampleStep.y);
- // sampleLocations[5] = vec2(0.0, sampleStep.y);
- // sampleLocations[6] = vec2(0.0, -sampleStep.y);
- // sampleLocations[7] = vec2(sampleStep.x, 0.0);
- // sampleLocations[8] = vec2(-sampleStep.x, 0.0);
+ sampleLocations[5] = vec2(0.0, sampleStep.y);
+ sampleLocations[6] = vec2(0.0, -sampleStep.y);
+ sampleLocations[7] = vec2(sampleStep.x, 0.0);
+ sampleLocations[8] = vec2(-sampleStep.x, 0.0);
- // float visibleSamples = 0.0;
- // float numSamples = 0.0;
+ float visibleSamples = 0.0;
+ float numSamples = 0.0;
- // float bias = vRadius * 2.0;
+ float bias = vRadius * 2.0;
- // for(int j = 0; j < 9; j++){
- // vec4 depthMapValue = texture2D(uShadowMap[i], vec2(u, v) + sampleLocations[j]);
+ for(int j = 0; j < 9; j++){
+ vec4 depthMapValue = texture2D(uShadowMap[i], vec2(u, v) + sampleLocations[j]);
- // float linearDepthFromSM = depthMapValue.x + bias;
- // float linearDepthFromViewer = distanceToLight;
+ float linearDepthFromSM = depthMapValue.x + bias;
+ float linearDepthFromViewer = distanceToLight;
- // if(linearDepthFromSM > linearDepthFromViewer){
- // visibleSamples += 1.0;
- // }
+ if(linearDepthFromSM > linearDepthFromViewer){
+ visibleSamples += 1.0;
+ }
- // numSamples += 1.0;
- // }
+ numSamples += 1.0;
+ }
- // float visibility = visibleSamples / numSamples;
+ float visibility = visibleSamples / numSamples;
- // if(u < 0.0 || u > 1.0 || v < 0.0 || v > 1.0 || nc.x < -1.0 || nc.x > 1.0 || nc.y < -1.0 || nc.y > 1.0 || nc.z < -1.0 || nc.z > 1.0){
- // //vColor = vec3(0.0, 0.0, 0.2);
- // }else{
- // //vColor = vec3(1.0, 1.0, 1.0) * visibility + vec3(1.0, 1.0, 1.0) * vec3(0.5, 0.0, 0.0) * (1.0 - visibility);
- // vColor = vColor * visibility + vColor * uShadowColor * (1.0 - visibility);
- // }
+ if(u < 0.0 || u > 1.0 || v < 0.0 || v > 1.0 || nc.x < -1.0 || nc.x > 1.0 || nc.y < -1.0 || nc.y > 1.0 || nc.z < -1.0 || nc.z > 1.0){
+ //vColor = vec3(0.0, 0.0, 0.2);
+ }else{
+ //vColor = vec3(1.0, 1.0, 1.0) * visibility + vec3(1.0, 1.0, 1.0) * vec3(0.5, 0.0, 0.0) * (1.0 - visibility);
+ vColor = vColor * visibility + vColor * uShadowColor * (1.0 - visibility);
+ }
- // }
+ }
- // #endif
+ #endif
}
diff --git a/src/navigation/VRControls.js b/src/navigation/VRControls.js
index 26817bdd..51940eba 100644
--- a/src/navigation/VRControls.js
+++ b/src/navigation/VRControls.js
@@ -8,186 +8,114 @@ export class VRControls extends EventDispatcher{
this.viewer = viewer;
- this.previousPads = [];
+ viewer.addEventListener("vr_start", this.onStart.bind(this));
+ viewer.addEventListener("vr_end", this.onEnd.bind(this));
- this.selection = [];
+ this.node = new THREE.Object3D();
+ this.node.up.set(0, 0, 1);
- this.triggerStarts = [];
+ let xr = viewer.renderer.xr;
+ this.cPrimary = xr.getController(0);
+ this.cSecondary = xr.getController(1);
+ }
- this.scaleState = null;
+ onStart(){
- this.selectionBox = this.createBox();
- this.viewer.scene.scene.add(this.selectionBox);
+ let position = this.viewer.scene.view.position.clone();
+ let direction = this.viewer.scene.view.direction;
+ direction.multiplyScalar(-1);
- this.dbgBox = this.createBox();
- this.viewer.scene.scene.add(this.dbgBox);
+ let target = position.clone().add(direction);
+ target.z = position.z;
- this.speed = 1;
- this.speedModificationFactor = 50;
+ let scale = this.viewer.getMoveSpeed();
- this.snLeft = this.createControllerModel();
- this.snRight = this.createControllerModel();
+ this.node.position.copy(position);
+ this.node.lookAt(target);
+ this.node.scale.set(scale, scale, scale);
+ this.node.updateMatrix();
+ this.node.updateMatrixWorld();
+ }
+
+ onEnd(){
- this.viewer.scene.scene.add(this.snLeft.node);
- this.viewer.scene.scene.add(this.snRight.node);
+ }
+
+ computeMove(controller){
+
+ if(!controller || !controller.inputSource || !controller.inputSource.gamepad){
+ return null;
+ }
+
+ let pad = controller.inputSource.gamepad;
+
+ let axes = pad.axes;
+ let scale = this.node.scale.x;
+ let amount = axes[1] * viewer.getMoveSpeed() / scale;
+
+ let rotation = new THREE.Quaternion().setFromEuler(controller.rotation);
+ let dir = new THREE.Vector3(0, 0, -1);
+ dir.applyQuaternion(rotation);
+
+ let move = dir.clone().multiplyScalar(amount);
+
+ let p1 = controller.position.clone().applyMatrix4(this.node.matrixWorld);
+ let m1 = move.clone().add(controller.position).applyMatrix4(this.node.matrixWorld);
+
+ move = m1.clone().sub(p1);
+
+
+ return move;
}
setScene(scene){
this.scene = scene;
}
- createControllerModel(){
- const geometry = new THREE.SphereGeometry(1, 32, 32);
- const material = new THREE.MeshLambertMaterial( { color: 0xff0000, side: THREE.DoubleSide, flatShading: true } );
- const node = new THREE.Mesh(geometry, material);
+ getCamera(){
+ let camera = new THREE.PerspectiveCamera();
+ camera.near = 0.01;
+ camera.far = 10000;
+ camera.up.set(0, 0, 1);
+ camera.lookAt(new THREE.Vector3(0, -1, 0));
+ camera.updateMatrix();
+ camera.updateMatrixWorld();
- node.position.set(0, 0, 0.5);
- node.scale.set(0.02, 0.02, 0.02);
- node.visible = false;
+ let scale = this.viewer.getMoveSpeed();
+ camera.position.copy(this.node.position);
+ camera.position.z -= 0.6 * scale;
+ camera.rotation.copy(this.node.rotation);
+ camera.scale.set(scale, scale, scale);
+ camera.updateMatrix();
+ camera.updateMatrixWorld();
+ camera.matrixAutoUpdate = false;
+ camera.parent = camera;
- this.viewer.scene.scene.add(node);
-
- const debug = new THREE.Mesh(geometry, new THREE.MeshNormalMaterial());
- debug.position.set(0, 0, 0.5);
- debug.scale.set(0.01, 0.01, 0.01);
- debug.visible = false;
-
-
- const controller = {
- node: node,
- debug: debug,
- };
- //viewer.scene.scene.add(node);
-
- return controller;
+ return camera;
}
- createBox(){
- const color = 0xffff00;
-
- const indices = new Uint16Array( [ 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7 ] );
- const positions = [
- 1, 1, 1,
- 0, 1, 1,
- 0, 0, 1,
- 1, 0, 1,
- 1, 1, 0,
- 0, 1, 0,
- 0, 0, 0,
- 1, 0, 0
- ];
- const geometry = new THREE.BufferGeometry();
-
- geometry.setIndex( new THREE.BufferAttribute( indices, 1 ) );
- geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) );
-
- geometry.computeBoundingSphere();
-
- const mesh = new THREE.LineSegments(geometry, new THREE.LineBasicMaterial( { color: color } ) );
- mesh.visible = false;
-
- return mesh;
- }
-
- debugLine(start, end, index, color){
-
- if(typeof this.debugLines === "undefined"){
-
- const geometry = new THREE.SphereGeometry(1, 8, 8);
-
- this.debugLines = {
- geometry: geometry,
- };
- }
-
- const n = 100;
-
- if(!this.debugLines[index]){
- const geometry = this.debugLines.geometry;
- const material = new THREE.MeshBasicMaterial({color: color});
- const nodes = [];
-
- for(let i = 0; i <= n; i++){
- const u = i / n;
-
- const node = new THREE.Mesh(geometry, material);
-
- const position = new THREE.Vector3().addVectors(
- start.clone().multiplyScalar(1-u),
- end.clone().multiplyScalar(u)
- );
-
- node.position.copy(position);
- node.scale.set(0.002, 0.002, 0.002);
- this.viewer.scene.scene.add(node);
- nodes.push(node);
- }
-
- const debugLine = {
- material: material,
- nodes: nodes,
- };
-
- this.debugLines[index] = debugLine;
- }else{
- const debugLine = this.debugLines[index];
-
- for(let i = 0; i <= n; i++){
- const node = debugLine.nodes[i];
- const u = i / n;
-
- const position = new THREE.Vector3().addVectors(
- start.clone().multiplyScalar(1-u),
- end.clone().multiplyScalar(u)
- );
-
- node.position.copy(position);
- }
- }
-
-
- }
-
- getPointcloudsAt(pointclouds, position){
-
- const I = [];
- for(const pointcloud of pointclouds){
-
- const intersects = pointcloud.intersectsPoint(position);
-
- if(intersects){
- I.push(pointcloud);
- }
- }
-
- return I;
- }
update(delta){
let {renderer} = this.viewer;
- let cameraVR = renderer.xr.cameraVR;
- let view = this.scene.view;
+ let move = this.computeMove(this.cPrimary);
- if(cameraVR == null){
- return;
+ if(move){
+ move.multiplyScalar(-delta);
+
+ this.node.position.add(move);
}
- let vrPos = new THREE.Vector3();
- let vrDir = new THREE.Vector3();
- cameraVR.getWorldPosition(vrPos);
- cameraVR.getWorldDirection(vrDir);
-
- vrDir.normalize().multiplyScalar(this.viewer.getMoveSpeed());
-
- let target = vrPos.clone().add(vrDir);
-
- view.position.copy(vrPos);
- view.lookAt(target);
+ let scale = this.node.scale.x;
+ let camVR = this.viewer.renderer.xr.cameraVR;
+ let vrPos = camVR.getWorldPosition(new THREE.Vector3());
+ let vrDir = camVR.getWorldDirection(new THREE.Vector3());
+ let vrTarget = vrPos.clone().add(vrDir.multiplyScalar(scale));
+
+ this.viewer.scene.view.setView(vrPos, vrTarget);
- // console.log("update vr controls");
}
};
\ No newline at end of file
diff --git a/src/viewer/viewer.js b/src/viewer/viewer.js
index 1d15faa7..edd59164 100644
--- a/src/viewer/viewer.js
+++ b/src/viewer/viewer.js
@@ -1593,6 +1593,11 @@ export class Viewer extends EventDispatcher{
if(Potree.measureTimings) performance.mark("update-start");
+ this.dispatchEvent({
+ type: 'update_start',
+ delta: delta,
+ timestamp: timestamp});
+
const scene = this.scene;
const camera = scene.getActiveCamera();
@@ -1898,8 +1903,6 @@ export class Viewer extends EventDispatcher{
renderer.setClearColor(0x550000, 0);
renderer.clear();
- let camera = this.scene.getActiveCamera();
-
let xr = renderer.xr;
let xrCameras = xr.cameraVR;
@@ -1907,25 +1910,12 @@ export class Viewer extends EventDispatcher{
return;
}
- let copyCam = () => {
- let ctmp = camera.clone();
- ctmp.position.set(0, 0, 0);
- ctmp.up.set(0, 0, 1);
- ctmp.lookAt(new THREE.Vector3(0, -1, 0));
- ctmp.updateMatrix();
- ctmp.updateMatrixWorld();
- ctmp.matrixAutoUpdate = false;
- ctmp.parent = ctmp;
-
- return ctmp;
- };
-
-
- let ctmp = copyCam();
+ let makeCam = this.vrControls.getCamera.bind(this.vrControls);
{ // SKYBOX
let {skybox} = this;
+ let ctmp = makeCam();
skybox.camera.rotation.copy(ctmp.rotation);
skybox.camera.fov = ctmp.fov;
skybox.camera.aspect = ctmp.aspect;
@@ -1935,17 +1925,19 @@ export class Viewer extends EventDispatcher{
}
{
-
- let cam = camera.clone();
+ let cam = makeCam();
cam.up.set(0, 1, 0);
- ctmp.updateMatrix();
- ctmp.updateMatrixWorld();
+ cam.updateMatrix();
+ cam.updateMatrixWorld();
+ cam.parent = null;
renderer.render(this.sceneVR, cam);
}
- ctmp = copyCam();
- renderer.render(this.scene.scene, ctmp);
+ {
+ let ctmp = makeCam();
+ renderer.render(this.scene.scene, ctmp);
+ }
for(let xrCamera of xrCameras.cameras){