From 18a6ed6554e73b67e4f24f0ce425d52fc9f11936 Mon Sep 17 00:00:00 2001 From: j-devel Date: Wed, 2 Mar 2022 16:39:59 +0700 Subject: [PATCH] Bump version to 1.2.3 --- dist/three-laser-pointer.esm.compat.js | 2 +- dist/three-laser-pointer.esm.js | 2 +- dist/three-laser-pointer.min.js | 2 +- examples/demo-terrains/dist/app.esm.js | 2 +- examples/demo-terrains/dist/index.html | 4 ++-- package-lock.json | 2 +- package.json | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dist/three-laser-pointer.esm.compat.js b/dist/three-laser-pointer.esm.compat.js index 060014c..dc3194f 100644 --- a/dist/three-laser-pointer.esm.compat.js +++ b/dist/three-laser-pointer.esm.compat.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Laser={})}(this,(function(t){"use strict";var e;e=(()=>{var t={901:(t,e,r)=>{r.d(e,{default:()=>d});const n=THREE;function o(t){return function(t){if(Array.isArray(t))return i(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r0&&void 0!==arguments[0]?arguments[0]:{};u(this,r);var i={color:16711680,maxPoints:256,infLength:9999},a=Object.assign({},i,o);return t=e.call(this,a.maxPoints,a.color),console.info("Laser ".concat(v," with THREE r").concat(n.REVISION)),t.version=v,t._src=new n.Vector3(0,0,0),t._raycaster=new n.Raycaster,t._infLen=a.infLength,t._meshes=[],t}return s(r,[{key:"setSource",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this._src=e?t.clone().applyMatrix4(e.matrixWorld):t.clone()}},{key:"getSource",value:function(){return this._src.clone()}},{key:"_raycast",value:function(t,e,r){var n=this._raycaster.intersectObjects(t,e);if(r){for(var o=0;o0?n[0]:null}},{key:"raycast",value:function(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return this._raycaster.set(t,e),this._raycast(r,o,n)}},{key:"raycastFromCamera",value:function(t,e,r,o,i,a){var u=arguments.length>6&&void 0!==arguments[6]&&arguments[6],c=new n.Vector2(t/r*2-1,-e/o*2+1);return this._raycaster.setFromCamera(c,i),this._raycast(a,u,null)}},{key:"getMeshesHit",value:function(){return this._meshes}},{key:"point",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.updatePoints([this._src.x,this._src.y,this._src.z,t.x,t.y,t.z],!0),this._meshes.length=0,e&&this.material.color.setHex(e)}},{key:"pointWithRaytrace",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:16;if(this.point(t,n),!(i<1)){var a=this.getSource(),u=r.direct(a,t),c=this.raycast(a,u,e);if(c){var s=this.computeReflections(t,u,c,e,i);this.updatePoints([a.x,a.y,a.z,t.x,t.y,t.z].concat(o(s)),!0)}}}},{key:"_computeReflectionsRecursive",value:function(t,e,o,i,a){var u=[],c=this;return function t(e,o,s){var l=(new n.Matrix3).getNormalMatrix(s.object.matrixWorld),f=s.face.normal.clone().applyMatrix3(l).normalize(),y=r.reflect(o,f),h=c.raycast(e,y,i,s.face);if(h){var p=h.point;u.push(p.x,p.y,p.z),u.length/31&&void 0!==arguments[1]?arguments[1]:16711680;u(this,r);var a=new n.BufferGeometry,c=new Float32Array(3*t);a.setAttribute("position",new n.BufferAttribute(c,3));var s=new n.LineBasicMaterial({color:i});return(o=e.call(this,a,s))._maxPoints=t,o._numPoints=0,o}return s(r,[{key:"_frustumCullingWorkaround",value:function(){this.geometry.computeBoundingSphere()}},{key:"setColor",value:function(t){this.material.color.setHex(t)}},{key:"getColor",value:function(){return this.material.color}},{key:"getPoints",value:function(){for(var t=this.geometry.attributes.position.array,e=[],r=0;r1&&void 0!==arguments[1]&&arguments[1];e||(t=m.flattenPoints(t));var r=this.geometry.attributes.position,n=r.count,o=t.length/3;o>n&&(o=n);for(var i=0;i{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r(901)})().default,t.default=e,Object.defineProperty(t,"__esModule",{value:!0})})); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Laser={})}(this,(function(t){"use strict";var e,r,n,o;r=(t,e,r)=>{r.d(e,{default:()=>b});const n=THREE;function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}function i(t){return function(t){if(Array.isArray(t))return a(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return a(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r1&&void 0!==arguments[1]?arguments[1]:16711680;u(this,r);var a=new n.BufferGeometry;return a.setAttribute("position",new n.BufferAttribute(new Float32Array(3*t),3)),(o=e.call(this,a,new n.LineBasicMaterial({color:i})))._maxPoints=t,o._numPoints=0,o}return l(r,[{key:"setColor",value:function(t){this.material.color.setHex(t)}},{key:"getColor",value:function(){return this.material.color}},{key:"getPoints",value:function(){for(var t=this.geometry.attributes.position.array,e=[],r=0;r1&&void 0!==arguments[1]&&arguments[1];e||(t=d.flattenPoints(t));var r=this.geometry.attributes.position,n=r.count,o=t.length/3;o>n&&(o=n);for(var i=0;i0&&void 0!==arguments[0]?arguments[0]:{};u(this,r);var i={color:16711680,maxPoints:256,infLength:9999},a=Object.assign({},i,o);return t=e.call(this,a.maxPoints,a.color),console.info("Laser ".concat(v," with THREE r").concat(n.REVISION)),t.version=v,t._src=new n.Vector3(0,0,0),t._raycaster=new n.Raycaster,t._infLen=a.infLength,t._meshes=[],t}return l(r,[{key:"setSource",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this._src=e?t.clone().applyMatrix4(e.matrixWorld):t.clone()}},{key:"getSource",value:function(){return this._src.clone()}},{key:"_raycast",value:function(t,e,r){var n=this._raycaster.intersectObjects(t,e);if(r){for(var o=0;o0?n[0]:null}},{key:"raycast",value:function(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return this._raycaster.set(t,e),this._raycast(r,o,n)}},{key:"raycastFromCamera",value:function(t,e,r,o,i,a){var u=arguments.length>6&&void 0!==arguments[6]&&arguments[6],c=new n.Vector2(t/r*2-1,-e/o*2+1);return this._raycaster.setFromCamera(c,i),this._raycast(a,u,null)}},{key:"getMeshesHit",value:function(){return this._meshes}},{key:"point",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.updatePoints([this._src.x,this._src.y,this._src.z,t.x,t.y,t.z],!0),this._meshes.length=0,e&&this.material.color.setHex(e)}},{key:"pointWithRaytrace",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:16;if(this.point(t,n),!(o<1)){var a=this.getSource(),u=r.direct(a,t),c=this.raycast(a,u,e);if(c){var l=this.computeReflections(t,u,c,e,o);this.updatePoints([a.x,a.y,a.z,t.x,t.y,t.z].concat(i(l)),!0)}}}},{key:"_computeReflectionsRecursive",value:function(t,e,o,i,a){var u=[],c=this;return function t(e,o,l){var s=(new n.Matrix3).getNormalMatrix(l.object.matrixWorld),f=l.face.normal.clone().applyMatrix3(s).normalize(),y=r.reflect(o,f),h=c.raycast(e,y,i,l.face);if(h){var p=h.point;u.push(p.x,p.y,p.z),u.length/3{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},r(0,o={},n),e=o.default,t.default=e,Object.defineProperty(t,"__esModule",{value:!0})})); \ No newline at end of file diff --git a/dist/three-laser-pointer.esm.js b/dist/three-laser-pointer.esm.js index 5802446..3f85414 100644 --- a/dist/three-laser-pointer.esm.js +++ b/dist/three-laser-pointer.esm.js @@ -1 +1 @@ -var Laser;Laser=(()=>{"use strict";var t={901:(t,e,r)=>{r.d(e,{default:()=>d});const n=THREE;function o(t){return function(t){if(Array.isArray(t))return i(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r0&&void 0!==arguments[0]?arguments[0]:{};u(this,r);var i={color:16711680,maxPoints:256,infLength:9999},a=Object.assign({},i,o);return t=e.call(this,a.maxPoints,a.color),console.info("Laser ".concat(v," with THREE r").concat(n.REVISION)),t.version=v,t._src=new n.Vector3(0,0,0),t._raycaster=new n.Raycaster,t._infLen=a.infLength,t._meshes=[],t}return s(r,[{key:"setSource",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this._src=e?t.clone().applyMatrix4(e.matrixWorld):t.clone()}},{key:"getSource",value:function(){return this._src.clone()}},{key:"_raycast",value:function(t,e,r){var n=this._raycaster.intersectObjects(t,e);if(r){for(var o=0;o0?n[0]:null}},{key:"raycast",value:function(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return this._raycaster.set(t,e),this._raycast(r,o,n)}},{key:"raycastFromCamera",value:function(t,e,r,o,i,a){var u=arguments.length>6&&void 0!==arguments[6]&&arguments[6],c=new n.Vector2(t/r*2-1,-e/o*2+1);return this._raycaster.setFromCamera(c,i),this._raycast(a,u,null)}},{key:"getMeshesHit",value:function(){return this._meshes}},{key:"point",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.updatePoints([this._src.x,this._src.y,this._src.z,t.x,t.y,t.z],!0),this._meshes.length=0,e&&this.material.color.setHex(e)}},{key:"pointWithRaytrace",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:16;if(this.point(t,n),!(i<1)){var a=this.getSource(),u=r.direct(a,t),c=this.raycast(a,u,e);if(c){var s=this.computeReflections(t,u,c,e,i);this.updatePoints([a.x,a.y,a.z,t.x,t.y,t.z].concat(o(s)),!0)}}}},{key:"_computeReflectionsRecursive",value:function(t,e,o,i,a){var u=[],c=this;return function t(e,o,s){var l=(new n.Matrix3).getNormalMatrix(s.object.matrixWorld),f=s.face.normal.clone().applyMatrix3(l).normalize(),y=r.reflect(o,f),h=c.raycast(e,y,i,s.face);if(h){var p=h.point;u.push(p.x,p.y,p.z),u.length/31&&void 0!==arguments[1]?arguments[1]:16711680;u(this,r);var a=new n.BufferGeometry,c=new Float32Array(3*t);a.setAttribute("position",new n.BufferAttribute(c,3));var s=new n.LineBasicMaterial({color:i});return(o=e.call(this,a,s))._maxPoints=t,o._numPoints=0,o}return s(r,[{key:"_frustumCullingWorkaround",value:function(){this.geometry.computeBoundingSphere()}},{key:"setColor",value:function(t){this.material.color.setHex(t)}},{key:"getColor",value:function(){return this.material.color}},{key:"getPoints",value:function(){for(var t=this.geometry.attributes.position.array,e=[],r=0;r1&&void 0!==arguments[1]&&arguments[1];e||(t=m.flattenPoints(t));var r=this.geometry.attributes.position,n=r.count,o=t.length/3;o>n&&(o=n);for(var i=0;i{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r(901)})().default;export default Laser; \ No newline at end of file +var Laser;(()=>{"use strict";var t=(t,e,r)=>{r.d(e,{default:()=>d});const n=THREE;function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}function i(t){return function(t){if(Array.isArray(t))return a(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return a(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return a(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r0&&void 0!==arguments[0]?arguments[0]:{};u(this,r);var i={color:16711680,maxPoints:256,infLength:9999},a=Object.assign({},i,o);return t=e.call(this,a.maxPoints,a.color),console.info("Laser ".concat(v," with THREE r").concat(n.REVISION)),t.version=v,t._src=new n.Vector3(0,0,0),t._raycaster=new n.Raycaster,t._infLen=a.infLength,t._meshes=[],t}return l(r,[{key:"setSource",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this._src=e?t.clone().applyMatrix4(e.matrixWorld):t.clone()}},{key:"getSource",value:function(){return this._src.clone()}},{key:"_raycast",value:function(t,e,r){var n=this._raycaster.intersectObjects(t,e);if(r){for(var o=0;o0?n[0]:null}},{key:"raycast",value:function(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return this._raycaster.set(t,e),this._raycast(r,o,n)}},{key:"raycastFromCamera",value:function(t,e,r,o,i,a){var u=arguments.length>6&&void 0!==arguments[6]&&arguments[6],c=new n.Vector2(t/r*2-1,-e/o*2+1);return this._raycaster.setFromCamera(c,i),this._raycast(a,u,null)}},{key:"getMeshesHit",value:function(){return this._meshes}},{key:"point",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.updatePoints([this._src.x,this._src.y,this._src.z,t.x,t.y,t.z],!0),this._meshes.length=0,e&&this.material.color.setHex(e)}},{key:"pointWithRaytrace",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:16;if(this.point(t,n),!(o<1)){var a=this.getSource(),u=r.direct(a,t),c=this.raycast(a,u,e);if(c){var l=this.computeReflections(t,u,c,e,o);this.updatePoints([a.x,a.y,a.z,t.x,t.y,t.z].concat(i(l)),!0)}}}},{key:"_computeReflectionsRecursive",value:function(t,e,o,i,a){var u=[],c=this;return function t(e,o,l){var s=(new n.Matrix3).getNormalMatrix(l.object.matrixWorld),f=l.face.normal.clone().applyMatrix3(s).normalize(),y=r.reflect(o,f),h=c.raycast(e,y,i,l.face);if(h){var p=h.point;u.push(p.x,p.y,p.z),u.length/31&&void 0!==arguments[1]?arguments[1]:16711680;u(this,r);var a=new n.BufferGeometry;return a.setAttribute("position",new n.BufferAttribute(new Float32Array(3*t),3)),(o=e.call(this,a,new n.LineBasicMaterial({color:i})))._maxPoints=t,o._numPoints=0,o}return l(r,[{key:"setColor",value:function(t){this.material.color.setHex(t)}},{key:"getColor",value:function(){return this.material.color}},{key:"getPoints",value:function(){for(var t=this.geometry.attributes.position.array,e=[],r=0;r1&&void 0!==arguments[1]&&arguments[1];e||(t=m.flattenPoints(t));var r=this.geometry.attributes.position,n=r.count,o=t.length/3;o>n&&(o=n);for(var i=0;i{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},r={};t(0,r,e),Laser=r.default})();export default Laser; \ No newline at end of file diff --git a/dist/three-laser-pointer.min.js b/dist/three-laser-pointer.min.js index 1ffdece..8a430ea 100644 --- a/dist/three-laser-pointer.min.js +++ b/dist/three-laser-pointer.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("THREE")):"function"==typeof define&&define.amd?define(["THREE"],e):"object"==typeof exports?exports.Laser=e(require("THREE")):t.Laser=e(t.THREE)}("undefined"!=typeof self?self:this,(function(t){return(()=>{"use strict";var e={252:(t,e,r)=>{r.d(e,{default:()=>d});var n=r(428);function o(t){return function(t){if(Array.isArray(t))return i(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r0&&void 0!==arguments[0]?arguments[0]:{};u(this,r);var i={color:16711680,maxPoints:256,infLength:9999},a=Object.assign({},i,o);return t=e.call(this,a.maxPoints,a.color),console.info("Laser ".concat(v," with THREE r").concat(n.REVISION)),t.version=v,t._src=new n.Vector3(0,0,0),t._raycaster=new n.Raycaster,t._infLen=a.infLength,t._meshes=[],t}return s(r,[{key:"setSource",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this._src=e?t.clone().applyMatrix4(e.matrixWorld):t.clone()}},{key:"getSource",value:function(){return this._src.clone()}},{key:"_raycast",value:function(t,e,r){var n=this._raycaster.intersectObjects(t,e);if(r){for(var o=0;o0?n[0]:null}},{key:"raycast",value:function(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return this._raycaster.set(t,e),this._raycast(r,o,n)}},{key:"raycastFromCamera",value:function(t,e,r,o,i,a){var u=arguments.length>6&&void 0!==arguments[6]&&arguments[6],c=new n.Vector2(t/r*2-1,-e/o*2+1);return this._raycaster.setFromCamera(c,i),this._raycast(a,u,null)}},{key:"getMeshesHit",value:function(){return this._meshes}},{key:"point",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.updatePoints([this._src.x,this._src.y,this._src.z,t.x,t.y,t.z],!0),this._meshes.length=0,e&&this.material.color.setHex(e)}},{key:"pointWithRaytrace",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:16;if(this.point(t,n),!(i<1)){var a=this.getSource(),u=r.direct(a,t),c=this.raycast(a,u,e);if(c){var s=this.computeReflections(t,u,c,e,i);this.updatePoints([a.x,a.y,a.z,t.x,t.y,t.z].concat(o(s)),!0)}}}},{key:"_computeReflectionsRecursive",value:function(t,e,o,i,a){var u=[],c=this;return function t(e,o,s){var l=(new n.Matrix3).getNormalMatrix(s.object.matrixWorld),f=s.face.normal.clone().applyMatrix3(l).normalize(),y=r.reflect(o,f),p=c.raycast(e,y,i,s.face);if(p){var h=p.point;u.push(h.x,h.y,h.z),u.length/31&&void 0!==arguments[1]?arguments[1]:16711680;u(this,r);var a=new n.BufferGeometry,c=new Float32Array(3*t);a.setAttribute("position",new n.BufferAttribute(c,3));var s=new n.LineBasicMaterial({color:i});return(o=e.call(this,a,s))._maxPoints=t,o._numPoints=0,o}return s(r,[{key:"_frustumCullingWorkaround",value:function(){this.geometry.computeBoundingSphere()}},{key:"setColor",value:function(t){this.material.color.setHex(t)}},{key:"getColor",value:function(){return this.material.color}},{key:"getPoints",value:function(){for(var t=this.geometry.attributes.position.array,e=[],r=0;r1&&void 0!==arguments[1]&&arguments[1];e||(t=m.flattenPoints(t));var r=this.geometry.attributes.position,n=r.count,o=t.length/3;o>n&&(o=n);for(var i=0;i{e.exports=t}},r={};function n(t){if(r[t])return r[t].exports;var o=r[t]={exports:{}};return e[t](o,o.exports,n),o.exports}return n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n(252)})().default})); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("THREE")):"function"==typeof define&&define.amd?define(["THREE"],e):"object"==typeof exports?exports.Laser=e(require("THREE")):t.Laser=e(t.THREE)}("undefined"!=typeof self?self:this,(function(t){return(()=>{"use strict";var e={458:(t,e,r)=>{r.d(e,{default:()=>b});var n=r(824);function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}function i(t){return function(t){if(Array.isArray(t))return a(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return a(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return a(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r1&&void 0!==arguments[1]?arguments[1]:16711680;u(this,r);var a=new n.BufferGeometry;return a.setAttribute("position",new n.BufferAttribute(new Float32Array(3*t),3)),(o=e.call(this,a,new n.LineBasicMaterial({color:i})))._maxPoints=t,o._numPoints=0,o}return l(r,[{key:"setColor",value:function(t){this.material.color.setHex(t)}},{key:"getColor",value:function(){return this.material.color}},{key:"getPoints",value:function(){for(var t=this.geometry.attributes.position.array,e=[],r=0;r1&&void 0!==arguments[1]&&arguments[1];e||(t=d.flattenPoints(t));var r=this.geometry.attributes.position,n=r.count,o=t.length/3;o>n&&(o=n);for(var i=0;i0&&void 0!==arguments[0]?arguments[0]:{};u(this,r);var i={color:16711680,maxPoints:256,infLength:9999},a=Object.assign({},i,o);return t=e.call(this,a.maxPoints,a.color),console.info("Laser ".concat(v," with THREE r").concat(n.REVISION)),t.version=v,t._src=new n.Vector3(0,0,0),t._raycaster=new n.Raycaster,t._infLen=a.infLength,t._meshes=[],t}return l(r,[{key:"setSource",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this._src=e?t.clone().applyMatrix4(e.matrixWorld):t.clone()}},{key:"getSource",value:function(){return this._src.clone()}},{key:"_raycast",value:function(t,e,r){var n=this._raycaster.intersectObjects(t,e);if(r){for(var o=0;o0?n[0]:null}},{key:"raycast",value:function(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return this._raycaster.set(t,e),this._raycast(r,o,n)}},{key:"raycastFromCamera",value:function(t,e,r,o,i,a){var u=arguments.length>6&&void 0!==arguments[6]&&arguments[6],c=new n.Vector2(t/r*2-1,-e/o*2+1);return this._raycaster.setFromCamera(c,i),this._raycast(a,u,null)}},{key:"getMeshesHit",value:function(){return this._meshes}},{key:"point",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.updatePoints([this._src.x,this._src.y,this._src.z,t.x,t.y,t.z],!0),this._meshes.length=0,e&&this.material.color.setHex(e)}},{key:"pointWithRaytrace",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:16;if(this.point(t,n),!(o<1)){var a=this.getSource(),u=r.direct(a,t),c=this.raycast(a,u,e);if(c){var l=this.computeReflections(t,u,c,e,o);this.updatePoints([a.x,a.y,a.z,t.x,t.y,t.z].concat(i(l)),!0)}}}},{key:"_computeReflectionsRecursive",value:function(t,e,o,i,a){var u=[],c=this;return function t(e,o,l){var s=(new n.Matrix3).getNormalMatrix(l.object.matrixWorld),f=l.face.normal.clone().applyMatrix3(s).normalize(),y=r.reflect(o,f),p=c.raycast(e,y,i,l.face);if(p){var h=p.point;u.push(h.x,h.y,h.z),u.length/3{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var o=n(458);return o=o.default})()})); \ No newline at end of file diff --git a/examples/demo-terrains/dist/app.esm.js b/examples/demo-terrains/dist/app.esm.js index 25fc87c..7cd6dbc 100644 --- a/examples/demo-terrains/dist/app.esm.js +++ b/examples/demo-terrains/dist/app.esm.js @@ -1,2 +1,2 @@ /*! For license information please see app.esm.js.LICENSE.txt */ -var NoPkgName;NoPkgName=(()=>{"use strict";var e={486:(e,t,r)=>{r.d(t,{default:()=>G});const n=THREE,a=DatGuiDefaults;var i=r.n(a);const o=Stats;var s=r.n(o);const u=$;var c=r.n(u);function f(e){return function(e){if(Array.isArray(e))return h(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return h(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return h(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r0&&void 0!==arguments[0]?arguments[0]:{};l(this,r);var i={color:16711680,maxPoints:256,infLength:9999},o=Object.assign({},i,a);return e=t.call(this,o.maxPoints,o.color),console.info("Laser ".concat(M," with THREE r").concat(n.REVISION)),e.version=M,e._src=new n.Vector3(0,0,0),e._raycaster=new n.Raycaster,e._infLen=o.infLength,e._meshes=[],e}return g(r,[{key:"setSource",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this._src=t?e.clone().applyMatrix4(t.matrixWorld):e.clone()}},{key:"getSource",value:function(){return this._src.clone()}},{key:"_raycast",value:function(e,t,r){var n=this._raycaster.intersectObjects(e,t);if(r){for(var a=0;a0?n[0]:null}},{key:"raycast",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return this._raycaster.set(e,t),this._raycast(r,a,n)}},{key:"raycastFromCamera",value:function(e,t,r,a,i,o){var s=arguments.length>6&&void 0!==arguments[6]&&arguments[6],u=new n.Vector2(e/r*2-1,-t/a*2+1);return this._raycaster.setFromCamera(u,i),this._raycast(o,s,null)}},{key:"getMeshesHit",value:function(){return this._meshes}},{key:"point",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.updatePoints([this._src.x,this._src.y,this._src.z,e.x,e.y,e.z],!0),this._meshes.length=0,t&&this.material.color.setHex(t)}},{key:"pointWithRaytrace",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:16;if(this.point(e,n),!(a<1)){var i=this.getSource(),o=r.direct(i,e),s=this.raycast(i,o,t);if(s){var u=this.computeReflections(e,o,s,t,a);this.updatePoints([i.x,i.y,i.z,e.x,e.y,e.z].concat(f(u)),!0)}}}},{key:"_computeReflectionsRecursive",value:function(e,t,a,i,o){var s=[],u=this;return function e(t,a,c){var f=(new n.Matrix3).getNormalMatrix(c.object.matrixWorld),h=c.face.normal.clone().applyMatrix3(f).normalize(),m=r.reflect(a,h),l=u.raycast(t,m,i,c.face);if(l){var d=l.point;s.push(d.x,d.y,d.z),s.length/31&&void 0!==arguments[1]?arguments[1]:16711680;l(this,r);var o=new n.BufferGeometry,s=new Float32Array(3*e);o.setAttribute("position",new n.BufferAttribute(s,3));var u=new n.LineBasicMaterial({color:i});return(a=t.call(this,o,u))._maxPoints=e,a._numPoints=0,a}return g(r,[{key:"_frustumCullingWorkaround",value:function(){this.geometry.computeBoundingSphere()}},{key:"setColor",value:function(e){this.material.color.setHex(e)}},{key:"getColor",value:function(){return this.material.color}},{key:"getPoints",value:function(){for(var e=this.geometry.attributes.position.array,t=[],r=0;r1&&void 0!==arguments[1]&&arguments[1];t||(e=w.flattenPoints(e));var r=this.geometry.attributes.position,n=r.count,a=e.length/3;a>n&&(a=n);for(var i=0;i="125"},H=function(e,t){var r=e.attributes.position,n=r.array,a=r.count,i=new Array(a).fill().map((function(e,t){return new _.Vector3(n[3*t],n[3*t+1],n[3*t+2])}));t(i),i.forEach((function(e,t){n[3*t]=e.x,n[3*t+1]=e.y,n[3*t+2]=e.z}))};!function(e){var t=e.noise={};function r(e,t,r){this.x=e,this.y=t,this.z=r}r.prototype.dot2=function(e,t){return this.x*e+this.y*t},r.prototype.dot3=function(e,t,r){return this.x*e+this.y*t+this.z*r};var n=[new r(1,1,0),new r(-1,1,0),new r(1,-1,0),new r(-1,-1,0),new r(1,0,1),new r(-1,0,1),new r(1,0,-1),new r(-1,0,-1),new r(0,1,1),new r(0,-1,1),new r(0,1,-1),new r(0,-1,-1)],a=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180],i=new Array(512),o=new Array(512);t.seed=function(e){e>0&&e<1&&(e*=65536),(e=Math.floor(e))<256&&(e|=e<<8);for(var t=0;t<256;t++){var r;r=1&t?a[t]^255&e:a[t]^e>>8&255,i[t]=i[t+256]=r,o[t]=o[t+256]=n[r%12]}},t.seed(Math.random());var s=.5*(Math.sqrt(3)-1),u=(3-Math.sqrt(3))/6;function c(e){return e*e*e*(e*(6*e-15)+10)}function f(e,t,r){return(1-r)*e+r*t}t.simplex=function(e,t){var r,n,a=(e+t)*s,c=Math.floor(e+a),f=Math.floor(t+a),h=(c+f)*u,m=e-c+h,l=t-f+h;m>l?(r=1,n=0):(r=0,n=1);var d=m-r+u,g=l-n+u,v=m-1+2*u,y=l-1+2*u,p=o[(c&=255)+i[f&=255]],S=o[c+r+i[f+n]],x=o[c+1+i[f+1]],M=.5-m*m-l*l,w=.5-d*d-g*g,b=.5-v*v-y*y;return 70*((M<0?0:(M*=M)*M*p.dot2(m,l))+(w<0?0:(w*=w)*w*S.dot2(d,g))+(b<0?0:(b*=b)*b*x.dot2(v,y)))},t.perlin=function(e,t){var r=Math.floor(e),n=Math.floor(t);e-=r,t-=n;var a=o[(r&=255)+i[n&=255]].dot2(e,t),s=o[r+i[n+1]].dot2(e,t-1),u=o[r+1+i[n]].dot2(e-1,t),h=o[r+1+i[n+1]].dot2(e-1,t-1),m=c(e);return f(f(a,u,m),f(s,h,m),c(t))}}(_.Terrain),_.Terrain=function(e){var t={after:null,easing:_.Terrain.Linear,heightmap:_.Terrain.DiamondSquare,material:null,maxHeight:100,minHeight:-100,optimization:_.Terrain.NONE,frequency:2.5,steps:1,stretch:!0,turbulent:!1,useBufferGeometry:!1,xSegments:63,xSize:1024,ySegments:63,ySize:1024,_mesh:null};for(var r in e=e||{},t)t.hasOwnProperty(r)&&(e[r]=void 0===e[r]?t[r]:e[r]);e.material=e.material||new _.MeshBasicMaterial({color:15623731});var n=new _.Object3D;n.rotation.x=-.5*Math.PI;var a=e._mesh;if(a&&"PlaneGeometry"===a.geometry.type&&a.geometry.parameters.widthSegments===e.xSegments&&a.geometry.parameters.heightSegments===e.ySegments){a.material=e.material,a.scale.x=e.xSize/a.geometry.parameters.width,a.scale.y=e.ySize/a.geometry.parameters.height;for(var i=0,o=a.geometry.vertices.length;i1&&(_.Terrain.Step(e,t.steps),_.Terrain.Smooth(e,t)),_.Terrain.Clamp(e,t),"function"==typeof t.after&&t.after(e,t)}));else{var r=e.geometry.vertices;t.turbulent&&_.Terrain.Turbulence(r,t),t.steps>1&&(_.Terrain.Step(r,t.steps),_.Terrain.Smooth(r,t)),_.Terrain.Clamp(r,t),"function"==typeof t.after&&t.after(r,t)}e.geometry.verticesNeedUpdate=!0,e.geometry.normalsNeedUpdate=!0,e.geometry.computeBoundingSphere(),e.geometry.computeFaceNormals(),e.geometry.computeVertexNormals()},_.Terrain.NONE=0,_.Terrain.GEOMIPMAP=1,_.Terrain.GEOCLIPMAP=2,_.Terrain.POLYGONREDUCTION=3,_.Terrain.toArray2D=function(e,t){var r,n,a=new Array(t.xSegments),i=t.xSegments+1,o=t.ySegments+1;for(r=0;ro&&(o=e[u].z),e[u].za&&(a=e[r].z);var o=a-n,s="number"!=typeof t.maxHeight?a:t.maxHeight,u="number"!=typeof t.minHeight?n:t.minHeight,c=t.stretch?s:au?n:u,h=c-f;for(c=0&&s+f>=0&&a+h=0&&c+f>=0&&o+h=0&&s+f>=0&&a+hu&&(u=e[m].z))}var l=s*i+a;if("number"==typeof r){var d=.5*(u-c),g=c+d;u=g+d*r,c=g-d*r}n[l]=e[l].z>u?u:e[l].z=s[n].min&&h<=s[n].max){e[r].z=s[n].avg;break}}},_.Terrain.Turbulence=function(e,t){for(var r=t.maxHeight-t.minHeight,n=0,a=e.length;n=2;f/=2){var h,m,l,d,g=Math.round(.5*f),v=Math.round(f);for(s/=2,h=0;hi?e[l*m+h].z+=a:g<-i?e[l*m+h].z-=a:e[l*m+h].z+=Math.cos(g/i*Math.PI*2)*a}},_.Terrain.Hill=function(e,t,r,n){var a=2*t.frequency,i=a*a*10,o=t.maxHeight-t.minHeight,s=o/(a*a),u=o/a,c=Math.min(t.xSize,t.ySize),f=c/(a*a),h=c/a;r=r||_.Terrain.Influences.Hill;for(var m={x:0,y:0},l=0;ln)){var o=0,s=0,u=n,c=n,f=Math.floor(n/r),h=-f,m=-f;for(o=0;o<=u;o+=f){for(s=0;s<=c;s+=f){var l=s*u+o;if(i[l]=Math.random()*a,!(h<0&&m<0)){for(var d=i[l],g=i[s*u+(o-f)]||d,v=i[(s-f)*u+o]||d,y=i[(s-f)*u+(o-f)]||d,p=h;pMath.random())}else H=t.spread(h[T.a],z,T,d,v);if(H){if(T.normal.angleTo(l)>t.maxSlope)continue;var C=t.mesh.clone();if(C.position.copy(h[T.a]).add(h[T.b]).add(h[T.c]).divideScalar(3),t.maxTilt>0){var I=C.position.clone().add(T.normal);C.lookAt(I);var L=T.normal.angleTo(l);if(L>t.maxTilt){var O=t.maxTilt/L;C.rotation.x*=O,C.rotation.y*=O,C.rotation.z*=O}}if(C.rotation.x+=.5*Math.PI,C.rotateY(2*Math.random()*Math.PI),t.sizeVariance){var R=Math.random()*f-t.sizeVariance;C.scale.x=C.scale.z=1+R,C.scale.y+=R}m.push(C)}}if(!k()&&t.mesh.geometry instanceof _.Geometry){var E=new _.Geometry;for(o=0,s=m.length;on)&&(o[s]=1);return function(){return o}},_.Terrain.Influences={Mesa:function(e){return 1.25*Math.min(.8,Math.exp(-e*e))},Hole:function(e){return-_.Terrain.Influences.Mesa(e)},Hill:function(e){return e<0?(e+1)*(e+1)*(3-2*(e+1)):1-e*e*(3-2*e)},Valley:function(e){return-_.Terrain.Influences.Hill(e)},Dome:function(e){return-(e+1)*(e-1)},Flat:function(e){return 0},Volcano:function(e){return.94-.32*(Math.abs(2*e)+Math.cos(2*Math.PI*Math.abs(e)+.4))}},_.Terrain.Influence=function(e,t,r,n,a,i,o,s,u){r=r||_.Terrain.Influences.Hill,n=void 0===n?.5:n,a=void 0===a?.5:a,i=void 0===i?64:i,o=void 0===o?64:o,s=void 0===s?_.NormalBlending:s,u=u||_.Terrain.EaseIn;for(var c=t.xSegments+1,f=c*n,h=(t.ySegments+1)*a,m=t.xSize/t.xSegments,l=t.ySize/t.ySegments,d=i/m,g=i/l,v=1/i,y=Math.ceil(f-d),p=Math.floor(f+d),S=Math.ceil(h-g),x=Math.floor(h+g),M=y;Mi||void 0===e[b]||(s===_.AdditiveBlending?e[b].z+=I:s===_.SubtractiveBlending?e[b].z-=I:s===_.MultiplyBlending?e[b].z*=I:s===_.NoBlending?e[b].z=I:s===_.NormalBlending?e[b].z=u(H,P,C)*e[b].z+I:"function"==typeof s&&(e[b].z=s(e[b].z,I,H,P,C)))}};function P(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function C(e,t){for(var r=0;r="125"};console.warn("@@ __ge125():",L());const O=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};P(this,e);var r={xSize:1,ySize:1,maxHeight:.1,minHeight:-.1,xS:63,yS:63},n=Object.assign({},r,t);this.xSize=n.xSize,this.ySize=n.ySize,this.maxHeight=n.maxHeight,this.minHeight=n.minHeight,this.xS=n.xS,this.yS=n.yS}var t,r,a;return t=e,a=[{key:"loadHeightmapImage",value:function(e,t){var r=new Image;r.onload=function(){t(r)},r.src=e}},{key:"getBlendedMaterial",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.01,r=new n.TextureLoader;r.load("./sand1.jpg",(function(a){a.wrapS=a.wrapT=n.RepeatWrapping,r.load("./grass1.jpg",(function(n){r.load("./stone1.jpg",(function(i){r.load("./snow1.jpg",(function(r){var o=I.generateBlendedMaterial([{texture:a},{texture:n,levels:[-80*t,-35*t,20*t,50*t]},{texture:i,levels:[20*t,50*t,60*t,85*t]},{texture:r,glsl:"1.0 - smoothstep(".concat(65*t," + smoothstep(-256.0, 256.0, vPosition.x) * ").concat(10*t,", ").concat(80*t,", vPosition.z)")},{texture:i,glsl:"slope > 0.7853981633974483 ? 0.2 : 1.0 - smoothstep(0.47123889803846897, 0.7853981633974483, slope) + 0.2"}]);e(o)}))}))}))}))}},{key:"buildTree",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.001,t=[new n.MeshLambertMaterial({color:4007959}),new n.MeshLambertMaterial({color:2968606})],r=new n.Mesh(new n.CylinderGeometry(2*e,2*e,12*e,6*e,1*e,!0));r.position.y=6*e;var a=new n.Mesh(new n.CylinderGeometry(0*e,10*e,14*e,8*e));a.position.y=18*e;var i=new n.Mesh(new n.CylinderGeometry(0*e,9*e,13*e,8*e));i.position.y=25*e;var o=new n.Mesh(new n.CylinderGeometry(0*e,8*e,12*e,8*e));o.position.y=32*e;var s=new n.Geometry;r.updateMatrix(),a.updateMatrix(),i.updateMatrix(),o.updateMatrix(),s.merge(r.geometry,r.matrix),s.merge(a.geometry,a.matrix),s.merge(i.geometry,i.matrix),s.merge(o.geometry,o.matrix);for(var u=r.geometry.faces.length,c=0,f=s.faces.length;c1&&void 0!==arguments[1]?arguments[1]:I.DiamondSquare;return I({easing:I.Linear,frequency:2.5,heightmap:t,material:e,steps:1,useBufferGeometry:!1,xSize:this.xSize,ySize:this.ySize,maxHeight:this.maxHeight,minHeight:this.minHeight,xSegments:this.xS,ySegments:this.yS})}},{key:"getScatterMeshesScene",value:function(t){var r,a=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.001,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.02;return r=L()?new n.Mesh(new n.CylinderGeometry(10*i,10*i,60*i,5),new n.MeshBasicMaterial({color:13421568})):e.buildTree(i),a||L()||(r.geometry=(new n.BufferGeometry).fromGeometry(r.geometry)),{scene:I.ScatterMeshes(t,{mesh:r,w:this.xS,h:this.yS,spread:o,randomness:Math.random}),material:r.material}}}])&&C(t.prototype,r),a&&C(t,a),e}();function R(e){return(R="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function E(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function D(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,n=new Array(t);r0&&void 0!==arguments[0]&&arguments[0],n=t.clientWidth,i=t.clientHeight;(e||t.width!=n||t.height!=i)&&(a.setSize(n,i,!1),r.aspect=n/i,r.updateProjectionMatrix())};u(!0);var f=function(){var e=new n.Scene,i=function(){a.render(e,r)};e.add(new n.AxesHelper(1));var o=new n.Mesh(new n.BoxGeometry(1,1,1),new n.MeshPhongMaterial({color:12640448,side:n.BackSide,wireframe:!0,opacity:1,transparent:!0}));o.name="walls",e.add(o);var s=new b({color:16711680});e.add(s);var u=new O({xSize:1,ySize:1,maxHeight:.1,minHeight:-.1}),f=[];O.getBlendedMaterial((function(t){O.loadHeightmapImage("./heightmapMods.png",(function(r){var n=u.getTerrainScene(t,r),a=n.children[0];a.name="terrain",f.push(a);var o=u.getScatterMeshesScene(a.geometry,!1).scene;n.add(o),f=f.concat(o.children),e.add(n),i()}))})),O.getSkyDome((function(t){e.add(t),i()})),e.add(O.getWater()),e.add(O.getSunLight()),e.add(O.getSkyLight());var h=new n.MeshBasicMaterial({color:5596842,wireframe:!0}),m=c()("#msg"),d=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3;return"(".concat(e.x.toFixed(t),", ").concat(e.y.toFixed(t),", ").concat(e.z.toFixed(t),")")},g=function(e){var t=e.getPoints(),r=t.shift();t.pop();m.empty(),t.length>0&&(m.append("
laser source: ".concat(d(r),"
")),m.append("
# reflections: ".concat(t.length,"
")),m.append("
reflection points: ".concat(t.map((function(e){return d(e)})).join(", "),"
")))},v=function(e){if(m.empty(),1===e.length)m.append("
points: ".concat(d(e[0])," ->
"));else if(2===e.length){var t=N(e,2),r=t[0],n=t[1];m.append("
points: ".concat(d(r)," -> ").concat(d(n),"
")),m.append("
length: ".concat(r.distanceTo(n).toFixed(3),"
"))}},y=new b({maxPoints:2});e.add(y);var S,x=[];return{scene:e,render:i,mark:function(n,a){if("Measure"===p.laserMode){var i=s.raycastFromCamera(n,a,t.width,t.height,r,f);if(null!==i){var o=i.point;if(1===x.length){x.push(o);var u=new b({maxPoints:2,color:S});u.updatePoints(x),e.add(u)}else x=[o],S=Math.floor(16777215*Math.random())}p.evRender&&l(),v(x)}},markCancel:function(){v(x=[]),y.visible=!1,p.evRender&&l()},pick:function(e,a){if("None"!==p.laserMode){var i=s.raycastFromCamera(e,a,t.width,t.height,r,f);if(null!==i){var o=i.point,u=new n.Vector3(.003,-.004,.002);if("Raytrace"===p.laserMode)s.setSource(u,r),s.pointWithRaytrace(o,f,65535,16),s.getMeshesHit().forEach((function(e){"terrain"!==e.name&&(e.material=h)}));else"Measure"===p.laserMode&&(s.setSource(u,r),s.point(o,16777215),1===x.length?(y.setSource(x[0]),y.point(o,S),y.visible=!0):y.visible=!1)}else s.clearPoints();p.evRender&&l(),"Raytrace"===p.laserMode&&g(s)}else s.clearPoints()}}}(),h=function(e){f.scene.traverse((function(t){if(!(!t instanceof n.Mesh)&&t.name&&"terrain"===t.name)switch(e){case"Textured":t.material.wireframe=!1,t.material.needsUpdate=!0,t.visible=!0;break;case"Wireframe":t.material.wireframe=!0,t.material.needsUpdate=!0,t.visible=!0;break;case"None":t.visible=!1}})),f.render()},m=new(s());m.showPanel(1),document.body.appendChild(m.dom);var l=function(){m.update(),u(),f.render()},d=!0,g=function e(){d||(requestAnimationFrame(e),l())},v=function(e){e?d=!0:(d=!1,g())},y=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&A(e,t)}(i,e);var t,r,n,a=j(i);function i(){return E(this,i),a.apply(this,arguments)}return t=i,(r=[{key:"initGui",value:function(e,t,r){var n=this;e.add(r,"laserMode",["Raytrace","Measure","None"]).name("Laser Mode").onChange((function(e){t.laserMode=e})),e.add(r,"vis",["Textured","Wireframe","None"]).name("Terrain").onChange((function(e){h(e),t.vis=e})),e.add(r,"evRender").name("Passive Render").onChange((function(e){v(e),t.evRender=e})),e.add(r,"reset").name("Reset").onChange((function(e){n.applyDefaults(),h(r.vis),r.laserMode,v(r.evRender),Object.assign(t,r)})),e.add(r,"sourceCode").name("Source Code").onChange((function(e){window.location.href="https://github.com/w3reality/three-laser-pointer/tree/master/examples/demo-terrains"}))}}])&&D(t.prototype,r),n&&D(t,n),i}(i()),p={vis:"Textured",laserMode:"Raytrace",evRender:!0};new y(p).setDefaults({vis:p.vis,laserMode:p.laserMode,evRender:p.evRender,reset:function(){},sourceCode:function(){}});var S=function(e){var r=t.getBoundingClientRect();return[e.clientX-r.left,e.clientY-r.top]},x=!1;a.domElement.addEventListener("mousedown",(function(e){x=!1}),!1),a.domElement.addEventListener("mousemove",(function(e){x=!0;var t=S(e);f.pick(t[0],t[1])}),!1),a.domElement.addEventListener("mouseup",(function(e){if(x);else if(0===e.button){var t=S(e);f.mark(t[0],t[1])}else 2===e.button&&f.markCancel()}),!1),p.evRender&&(l(),o.addEventListener("change",l))}}},t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={exports:{}};return e[n](a,a.exports,r),a.exports}return r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r(486)})().default;export default NoPkgName; \ No newline at end of file +var NoPkgName;(()=>{"use strict";var e=(e,t,r)=>{r.d(t,{default:()=>U});const n=THREE,a=DatGuiDefaults;var o=r.n(a);const i=Threelet;var s=r.n(i);function u(e){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u(e)}function c(e){return function(e){if(Array.isArray(e))return h(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return h(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return h(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r0&&void 0!==arguments[0]?arguments[0]:{};f(this,r);var o={color:16711680,maxPoints:256,infLength:9999},i=Object.assign({},o,a);return e=t.call(this,i.maxPoints,i.color),console.info("Laser ".concat(S," with THREE r").concat(n.REVISION)),e.version=S,e._src=new n.Vector3(0,0,0),e._raycaster=new n.Raycaster,e._infLen=i.infLength,e._meshes=[],e}return m(r,[{key:"setSource",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this._src=t?e.clone().applyMatrix4(t.matrixWorld):e.clone()}},{key:"getSource",value:function(){return this._src.clone()}},{key:"_raycast",value:function(e,t,r){var n=this._raycaster.intersectObjects(e,t);if(r){for(var a=0;a0?n[0]:null}},{key:"raycast",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return this._raycaster.set(e,t),this._raycast(r,a,n)}},{key:"raycastFromCamera",value:function(e,t,r,a,o,i){var s=arguments.length>6&&void 0!==arguments[6]&&arguments[6],u=new n.Vector2(e/r*2-1,-t/a*2+1);return this._raycaster.setFromCamera(u,o),this._raycast(i,s,null)}},{key:"getMeshesHit",value:function(){return this._meshes}},{key:"point",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.updatePoints([this._src.x,this._src.y,this._src.z,e.x,e.y,e.z],!0),this._meshes.length=0,t&&this.material.color.setHex(t)}},{key:"pointWithRaytrace",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:16;if(this.point(e,n),!(a<1)){var o=this.getSource(),i=r.direct(o,e),s=this.raycast(o,i,t);if(s){var u=this.computeReflections(e,i,s,t,a);this.updatePoints([o.x,o.y,o.z,e.x,e.y,e.z].concat(c(u)),!0)}}}},{key:"_computeReflectionsRecursive",value:function(e,t,a,o,i){var s=[],u=this;return function e(t,a,c){var h=(new n.Matrix3).getNormalMatrix(c.object.matrixWorld),f=c.face.normal.clone().applyMatrix3(h).normalize(),l=r.reflect(a,f),m=u.raycast(t,l,o,c.face);if(m){var d=m.point;s.push(d.x,d.y,d.z),s.length/31&&void 0!==arguments[1]?arguments[1]:16711680;f(this,r);var i=new n.BufferGeometry;return i.setAttribute("position",new n.BufferAttribute(new Float32Array(3*e),3)),(a=t.call(this,i,new n.LineBasicMaterial({color:o})))._maxPoints=e,a._numPoints=0,a}return m(r,[{key:"setColor",value:function(e){this.material.color.setHex(e)}},{key:"getColor",value:function(){return this.material.color}},{key:"getPoints",value:function(){for(var e=this.geometry.attributes.position.array,t=[],r=0;r1&&void 0!==arguments[1]&&arguments[1];t||(e=x.flattenPoints(e));var r=this.geometry.attributes.position,n=r.count,a=e.length/3;a>n&&(a=n);for(var o=0;o="125"},k=function(e,t){var r=e.attributes.position,n=r.array,a=r.count,o=new Array(a).fill().map((function(e,t){return new T.Vector3(n[3*t],n[3*t+1],n[3*t+2])}));t(o),o.forEach((function(e,t){n[3*t]=e.x,n[3*t+1]=e.y,n[3*t+2]=e.z}))};!function(e){var t=e.noise={};function r(e,t,r){this.x=e,this.y=t,this.z=r}r.prototype.dot2=function(e,t){return this.x*e+this.y*t},r.prototype.dot3=function(e,t,r){return this.x*e+this.y*t+this.z*r};var n=[new r(1,1,0),new r(-1,1,0),new r(1,-1,0),new r(-1,-1,0),new r(1,0,1),new r(-1,0,1),new r(1,0,-1),new r(-1,0,-1),new r(0,1,1),new r(0,-1,1),new r(0,1,-1),new r(0,-1,-1)],a=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180],o=new Array(512),i=new Array(512);t.seed=function(e){e>0&&e<1&&(e*=65536),(e=Math.floor(e))<256&&(e|=e<<8);for(var t=0;t<256;t++){var r;r=1&t?a[t]^255&e:a[t]^e>>8&255,o[t]=o[t+256]=r,i[t]=i[t+256]=n[r%12]}},t.seed(Math.random());var s=.5*(Math.sqrt(3)-1),u=(3-Math.sqrt(3))/6;function c(e){return e*e*e*(e*(6*e-15)+10)}function h(e,t,r){return(1-r)*e+r*t}t.simplex=function(e,t){var r,n,a=(e+t)*s,c=Math.floor(e+a),h=Math.floor(t+a),f=(c+h)*u,l=e-c+f,m=t-h+f;l>m?(r=1,n=0):(r=0,n=1);var d=l-r+u,g=m-n+u,y=l-1+2*u,p=m-1+2*u,v=i[(c&=255)+o[h&=255]],S=i[c+r+o[h+n]],x=i[c+1+o[h+1]],M=.5-l*l-m*m,w=.5-d*d-g*g,b=.5-y*y-p*p;return 70*((M<0?0:(M*=M)*M*v.dot2(l,m))+(w<0?0:(w*=w)*w*S.dot2(d,g))+(b<0?0:(b*=b)*b*x.dot2(y,p)))},t.perlin=function(e,t){var r=Math.floor(e),n=Math.floor(t);e-=r,t-=n;var a=i[(r&=255)+o[n&=255]].dot2(e,t),s=i[r+o[n+1]].dot2(e,t-1),u=i[r+1+o[n]].dot2(e-1,t),f=i[r+1+o[n+1]].dot2(e-1,t-1),l=c(e);return h(h(a,u,l),h(s,f,l),c(t))}}(T.Terrain),T.Terrain=function(e){var t={after:null,easing:T.Terrain.Linear,heightmap:T.Terrain.DiamondSquare,material:null,maxHeight:100,minHeight:-100,optimization:T.Terrain.NONE,frequency:2.5,steps:1,stretch:!0,turbulent:!1,useBufferGeometry:!1,xSegments:63,xSize:1024,ySegments:63,ySize:1024,_mesh:null};for(var r in e=e||{},t)t.hasOwnProperty(r)&&(e[r]=void 0===e[r]?t[r]:e[r]);e.material=e.material||new T.MeshBasicMaterial({color:15623731});var n=new T.Object3D;n.rotation.x=-.5*Math.PI;var a=e._mesh;if(a&&"PlaneGeometry"===a.geometry.type&&a.geometry.parameters.widthSegments===e.xSegments&&a.geometry.parameters.heightSegments===e.ySegments){a.material=e.material,a.scale.x=e.xSize/a.geometry.parameters.width,a.scale.y=e.ySize/a.geometry.parameters.height;for(var o=0,i=a.geometry.vertices.length;o1&&(T.Terrain.Step(e,t.steps),T.Terrain.Smooth(e,t)),T.Terrain.Clamp(e,t),"function"==typeof t.after&&t.after(e,t)}));else{var r=e.geometry.vertices;t.turbulent&&T.Terrain.Turbulence(r,t),t.steps>1&&(T.Terrain.Step(r,t.steps),T.Terrain.Smooth(r,t)),T.Terrain.Clamp(r,t),"function"==typeof t.after&&t.after(r,t)}e.geometry.verticesNeedUpdate=!0,e.geometry.normalsNeedUpdate=!0,e.geometry.computeBoundingSphere(),e.geometry.computeVertexNormals()},T.Terrain.NONE=0,T.Terrain.GEOMIPMAP=1,T.Terrain.GEOCLIPMAP=2,T.Terrain.POLYGONREDUCTION=3,T.Terrain.toArray2D=function(e,t){var r,n,a=new Array(t.xSegments),o=t.xSegments+1,i=t.ySegments+1;for(r=0;ri&&(i=e[u].z),e[u].za&&(a=e[r].z);var i=a-n,s="number"!=typeof t.maxHeight?a:t.maxHeight,u="number"!=typeof t.minHeight?n:t.minHeight,c=t.stretch?s:au?n:u,f=c-h;for(c=0&&s+h>=0&&a+f=0&&c+h>=0&&i+f=0&&s+h>=0&&a+fu&&(u=e[l].z))}var m=s*o+a;if("number"==typeof r){var d=.5*(u-c),g=c+d;u=g+d*r,c=g-d*r}n[m]=e[m].z>u?u:e[m].z=s[n].min&&f<=s[n].max){e[r].z=s[n].avg;break}}},T.Terrain.Turbulence=function(e,t){for(var r=t.maxHeight-t.minHeight,n=0,a=e.length;n=2;h/=2){var f,l,m,d,g=Math.round(.5*h),y=Math.round(h);for(s/=2,f=0;fo?e[m*l+f].z+=a:g<-o?e[m*l+f].z-=a:e[m*l+f].z+=Math.cos(g/o*Math.PI*2)*a}},T.Terrain.Hill=function(e,t,r,n){var a=2*t.frequency,o=a*a*10,i=t.maxHeight-t.minHeight,s=i/(a*a),u=i/a,c=Math.min(t.xSize,t.ySize),h=c/(a*a),f=c/a;r=r||T.Terrain.Influences.Hill;for(var l={x:0,y:0},m=0;mn)){var i=0,s=0,u=n,c=n,h=Math.floor(n/r),f=-h,l=-h;for(i=0;i<=u;i+=h){for(s=0;s<=c;s+=h){var m=s*u+i;if(o[m]=Math.random()*a,!(f<0&&l<0)){for(var d=o[m],g=o[s*u+(i-h)]||d,y=o[(s-h)*u+i]||d,p=o[(s-h)*u+(i-h)]||d,v=f;vMath.random())}else C=t.spread(f[_.a],k,_,d,y);if(C){if(_.normal.angleTo(m)>t.maxSlope)continue;var H=t.mesh.clone();if(H.position.copy(f[_.a]).add(f[_.b]).add(f[_.c]).divideScalar(3),t.maxTilt>0){var O=H.position.clone().add(_.normal);H.lookAt(O);var I=_.normal.angleTo(m);if(I>t.maxTilt){var R=t.maxTilt/I;H.rotation.x*=R,H.rotation.y*=R,H.rotation.z*=R}}if(H.rotation.x+=.5*Math.PI,H.rotateY(2*Math.random()*Math.PI),t.sizeVariance){var E=Math.random()*h-t.sizeVariance;H.scale.x=H.scale.z=1+E,H.scale.y+=E}l.push(H)}}if(!z()&&t.mesh.geometry instanceof T.Geometry){var L=new T.Geometry;for(i=0,s=l.length;in)&&(i[s]=1);return function(){return i}},T.Terrain.Influences={Mesa:function(e){return 1.25*Math.min(.8,Math.exp(-e*e))},Hole:function(e){return-T.Terrain.Influences.Mesa(e)},Hill:function(e){return e<0?(e+1)*(e+1)*(3-2*(e+1)):1-e*e*(3-2*e)},Valley:function(e){return-T.Terrain.Influences.Hill(e)},Dome:function(e){return-(e+1)*(e-1)},Flat:function(e){return 0},Volcano:function(e){return.94-.32*(Math.abs(2*e)+Math.cos(2*Math.PI*Math.abs(e)+.4))}},T.Terrain.Influence=function(e,t,r,n,a,o,i,s,u){r=r||T.Terrain.Influences.Hill,n=void 0===n?.5:n,a=void 0===a?.5:a,o=void 0===o?64:o,i=void 0===i?64:i,s=void 0===s?T.NormalBlending:s,u=u||T.Terrain.EaseIn;for(var c=t.xSegments+1,h=c*n,f=(t.ySegments+1)*a,l=t.xSize/t.xSegments,m=t.ySize/t.ySegments,d=o/l,g=o/m,y=1/o,p=Math.ceil(h-d),v=Math.floor(h+d),S=Math.ceil(f-g),x=Math.floor(f+g),M=p;Mo||void 0===e[b]||(s===T.AdditiveBlending?e[b].z+=O:s===T.SubtractiveBlending?e[b].z-=O:s===T.MultiplyBlending?e[b].z*=O:s===T.NoBlending?e[b].z=O:s===T.NormalBlending?e[b].z=u(C,P,H)*e[b].z+O:"function"==typeof s&&(e[b].z=s(e[b].z,O,C,P,H)))}};function _(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function C(e,t){for(var r=0;r="125"};console.warn("@@ __ge125():",H());var O=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};_(this,e);var r={xSize:1,ySize:1,maxHeight:.1,minHeight:-.1,xS:63,yS:63},n=Object.assign({},r,t);this.xSize=n.xSize,this.ySize=n.ySize,this.maxHeight=n.maxHeight,this.minHeight=n.minHeight,this.xS=n.xS,this.yS=n.yS}var t,r,a;return t=e,r=[{key:"getTerrainScene",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:P.DiamondSquare;return P({easing:P.Linear,frequency:2.5,heightmap:t,material:e,steps:1,useBufferGeometry:!1,xSize:this.xSize,ySize:this.ySize,maxHeight:this.maxHeight,minHeight:this.minHeight,xSegments:this.xS,ySegments:this.yS})}},{key:"getScatterMeshesScene",value:function(t){var r,a=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.001,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.02;return r=H()?new n.Mesh(new n.CylinderGeometry(10*o,10*o,60*o,5),new n.MeshBasicMaterial({color:13421568})):e.buildTree(o),a||H()||(r.geometry=(new n.BufferGeometry).fromGeometry(r.geometry)),{scene:P.ScatterMeshes(t,{mesh:r,w:this.xS,h:this.yS,spread:i,randomness:Math.random}),material:r.material}}}],a=[{key:"loadHeightmapImage",value:function(e,t){var r=new Image;r.onload=function(){t(r)},r.src=e}},{key:"getBlendedMaterial",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.01,r=new n.TextureLoader;r.load("./sand1.jpg",(function(a){a.wrapS=a.wrapT=n.RepeatWrapping,r.load("./grass1.jpg",(function(n){r.load("./stone1.jpg",(function(o){r.load("./snow1.jpg",(function(r){var i=P.generateBlendedMaterial([{texture:a},{texture:n,levels:[-80*t,-35*t,20*t,50*t]},{texture:o,levels:[20*t,50*t,60*t,85*t]},{texture:r,glsl:"1.0 - smoothstep(".concat(65*t," + smoothstep(-256.0, 256.0, vPosition.x) * ").concat(10*t,", ").concat(80*t,", vPosition.z)")},{texture:o,glsl:"slope > 0.7853981633974483 ? 0.2 : 1.0 - smoothstep(0.47123889803846897, 0.7853981633974483, slope) + 0.2"}]);e(i)}))}))}))}))}},{key:"buildTree",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.001,t=[new n.MeshLambertMaterial({color:4007959}),new n.MeshLambertMaterial({color:2968606})],r=new n.Mesh(new n.CylinderGeometry(2*e,2*e,12*e,6*e,1*e,!0));r.position.y=6*e;var a=new n.Mesh(new n.CylinderGeometry(0*e,10*e,14*e,8*e));a.position.y=18*e;var o=new n.Mesh(new n.CylinderGeometry(0*e,9*e,13*e,8*e));o.position.y=25*e;var i=new n.Mesh(new n.CylinderGeometry(0*e,8*e,12*e,8*e));i.position.y=32*e;var s=new n.Geometry;r.updateMatrix(),a.updateMatrix(),o.updateMatrix(),i.updateMatrix(),s.merge(r.geometry,r.matrix),s.merge(a.geometry,a.matrix),s.merge(o.geometry,o.matrix),s.merge(i.geometry,i.matrix);for(var u=r.geometry.faces.length,c=0,h=s.faces.length;ce.length)&&(t=e.length);for(var r=0,n=new Array(t);r0&&(this.appendText(e,"laser source: ".concat(this.toCoords(n))),this.appendText(e,"# reflections: ".concat(r.length)),this.appendText(e,"reflection points: ".concat(this.toCoordsArray(r))))}},{key:"_updateMeasureStats",value:function(e,t){if(this.clear(e),1===t.length)this.appendText(e,"points: ".concat(this.toCoords(t[0])," -> "));else if(2===t.length){var r=E(t,2),n=r[0],a=r[1];this.appendText(e,"points: ".concat(this.toCoords(n)," -> ").concat(this.toCoords(a))),this.appendText(e,"length: ".concat(n.distanceTo(a).toFixed(3)))}}},{key:"toCoords",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3;return"(".concat(e.x.toFixed(t),", ").concat(e.y.toFixed(t),", ").concat(e.z.toFixed(t),")")}},{key:"toCoordsArray",value:function(e){var t=this;return e.map((function(e){return t.toCoords(e)})).join(", ")}},{key:"appendText",value:function(e,t){var r=document.createElement("div");r.appendChild(document.createTextNode(t)),e.appendChild(r)}},{key:"clear",value:function(e){for(;e.firstChild;)e.firstChild.remove()}},{key:"init",value:function(e,t,r,a){var o=new I({xSize:1,ySize:1,maxHeight:.1,minHeight:-.1}),i=[];I.getBlendedMaterial((function(r){I.loadHeightmapImage("./heightmapMods.png",(function(n){var a=o.getTerrainScene(r,n),s=a.children[0];s.name="terrain",i.push(s);var u=o.getScatterMeshesScene(s.geometry,!1).scene;a.add(u),i=i.concat(u.children),e.add(a),t()}))})),I.getSkyDome((function(r){e.add(r),t()})),e.add(I.getWater()),e.add(I.getSunLight()),e.add(I.getSkyLight());var s=new n.MeshBasicMaterial({color:5596842,wireframe:!0}),u=new M({color:16711680});e.add(u);var c=new M({maxPoints:2});e.add(c);var h,f=[],l={vis:"Textured",laserMode:"Raytrace",evRender:!0},m=new n.Group;e.add(m),l.onMark=function(e){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];r?m.clear():m.add(e),t()};var d=new n.Group;return e.add(d),l.onThunder=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(e)d.clear();else{var r=new M({color:16776960,maxPoints:32});r.updatePointsRandomWalk(32),d.add(r)}t()},{config:l,pick:function(e,o,m,d){if("None"!==l.laserMode){var g=u.raycastFromCamera(e,o,r,a,m,i);if(null!==g){var y=g.point,p=new n.Vector3(.003,-.004,.002);if("Raytrace"===l.laserMode)u.setSource(p,m),u.pointWithRaytrace(y,i,65535,16),u.getMeshesHit().forEach((function(e){"terrain"!==e.name&&(e.material=s)}));else"Measure"===l.laserMode&&(u.setSource(p,m),u.point(y,16777215),1===f.length?(c.setSource(f[0]),c.point(y,h),c.visible=!0):c.visible=!1)}else u.clearPoints();l.evRender&&t(),"Raytrace"===l.laserMode&&d(u)}else u.clearPoints()},markToggle:function(e,n,o,s){if("Measure"===l.laserMode){var c=u.raycastFromCamera(e,n,r,a,o,i);if(null!==c){var m=c.point;if(1===f.length){f.push(m);var d=new M({maxPoints:2,color:h});d.updatePoints(f),l.onMark(d)}else f=[m],h=Math.floor(16777215*Math.random())}l.evRender&&t(),s(f)}},markCancel:function(e){e(f=[]),c.visible=!1,l.evRender&&t()}}}}]),r}(s());const U=function(e,t){var r=new W({canvas:document.getElementById("canvas")});r.setup("mod-stats",t,{panelType:1}),r.setup("mod-controls",e),r.render()}},t={n:e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return t.d(r,{a:r}),r},d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},r={};e(0,r,t),NoPkgName=r.default})();export default NoPkgName; \ No newline at end of file diff --git a/examples/demo-terrains/dist/index.html b/examples/demo-terrains/dist/index.html index 1d246fc..7fc08cc 100644 --- a/examples/demo-terrains/dist/index.html +++ b/examples/demo-terrains/dist/index.html @@ -15,8 +15,8 @@ diff --git a/package-lock.json b/package-lock.json index 781855f..33856da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "three-laser-pointer", - "version": "1.2.3-dev.5", + "version": "1.2.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 86241a4..9211646 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "three-laser-pointer", - "version": "1.2.3-dev.5", + "version": "1.2.3", "description": "Laser pointer object using three.js", "main": "dist/three-laser-pointer.min.js", "directories": {