t3d-ez.gl 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/Addons/RaycasterAide.cjs.js +1 -0
- package/dist/core/Addons/RaycasterAide.esm.js +1 -0
- package/dist/core/Controls/TTControls/TTControls.cjs.js +1 -1
- package/dist/core/Controls/TTControls/TTControls.esm.js +1 -1
- package/dist/core/Map/index.cjs.js +1 -1
- package/dist/core/Map/index.esm.js +1 -1
- package/dist/core/Resource/loaders.cjs.js +1 -1
- package/dist/core/Resource/loaders.esm.js +1 -1
- package/dist/core/WebGLEngine/index.cjs.js +1 -1
- package/dist/core/WebGLEngine/index.esm.js +1 -1
- package/dist/helpers/AxesAddHelper.cjs.js +1 -0
- package/dist/helpers/AxesAddHelper.esm.js +1 -0
- package/dist/helpers/T3DEzViewportGizmo.cjs.js +1 -0
- package/dist/helpers/T3DEzViewportGizmo.esm.js +1 -0
- package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/build/three.core.cjs.js +1 -1
- package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/build/three.core.esm.js +1 -1
- package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/build/three.module.cjs.js +1 -1
- package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/build/three.module.esm.js +1 -1
- package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/lines/Line2.cjs.js +1 -0
- package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/lines/Line2.esm.js +1 -0
- package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/lines/LineGeometry.cjs.js +1 -0
- package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/lines/LineGeometry.esm.js +1 -0
- package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/lines/LineMaterial.cjs.js +1 -0
- package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/lines/LineMaterial.esm.js +1 -0
- package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/lines/LineSegments2.cjs.js +1 -0
- package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/lines/LineSegments2.esm.js +1 -0
- package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/lines/LineSegmentsGeometry.cjs.js +1 -0
- package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/lines/LineSegmentsGeometry.esm.js +1 -0
- package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/utils/BufferGeometryUtils.cjs.js +1 -1
- package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/utils/BufferGeometryUtils.esm.js +1 -1
- package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/src/math/MathUtils.cjs.js +1 -0
- package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/src/math/MathUtils.esm.js +1 -0
- package/dist/package.json +1 -1
- package/dist/t3d-ez.gl.cjs.js +1 -1
- package/dist/t3d-ez.gl.esm.js +1 -1
- package/dist/types/core/Addons/RaycasterAide.d.ts +12 -0
- package/dist/types/core/Addons/index.d.ts +1 -0
- package/dist/types/core/PostProcessor/index.d.ts +3 -3
- package/dist/types/core/Resource/ResourceManager.d.ts +1 -1
- package/dist/types/core/Resource/loaders.d.ts +2 -2
- package/dist/types/core/index.d.ts +1 -1
- package/dist/types/helpers/AxesAddHelper.d.ts +6 -0
- package/dist/types/helpers/T3DEzViewportGizmo.d.ts +271 -0
- package/dist/types/helpers/index.d.ts +2 -0
- package/package.json +1 -1
- package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/loaders/RGBELoader.cjs.js +0 -1
- package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/loaders/RGBELoader.esm.js +0 -1
- package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/physics/AmmoPhysics.cjs.js +0 -1
- package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/physics/AmmoPhysics.esm.js +0 -1
- package/dist/types/core/Physics/index.d.ts +0 -1
- /package/dist/core/Map/{extrudeMap.cjs.js → ExtrudeMap.cjs.js} +0 -0
- /package/dist/core/Map/{extrudeMap.esm.js → ExtrudeMap.esm.js} +0 -0
- /package/dist/types/core/Map/{extrudeMap.d.ts → ExtrudeMap.d.ts} +0 -0
package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/lines/Line2.cjs.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("./LineSegments2.cjs.js"),s=require("./LineGeometry.cjs.js"),i=require("./LineMaterial.cjs.js");class r extends e.LineSegments2{constructor(e=new s.LineGeometry,r=new i.LineMaterial({color:16777215*Math.random()})){super(e,r),this.isLine2=!0,this.type="Line2"}}exports.Line2=r;
|
package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/lines/Line2.esm.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LineSegments2 as e}from"./LineSegments2.esm.js";import{LineGeometry as s}from"./LineGeometry.esm.js";import{LineMaterial as r}from"./LineMaterial.esm.js";class t extends e{constructor(e=new s,t=new r({color:16777215*Math.random()})){super(e,t),this.isLine2=!0,this.type="Line2"}}export{t as Line2};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var t=require("./LineSegmentsGeometry.cjs.js");class e extends t.LineSegmentsGeometry{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(t){const e=t.length-3,s=new Float32Array(2*e);for(let r=0;r<e;r+=3)s[2*r]=t[r],s[2*r+1]=t[r+1],s[2*r+2]=t[r+2],s[2*r+3]=t[r+3],s[2*r+4]=t[r+4],s[2*r+5]=t[r+5];return super.setPositions(s),this}setColors(t){const e=t.length-3,s=new Float32Array(2*e);for(let r=0;r<e;r+=3)s[2*r]=t[r],s[2*r+1]=t[r+1],s[2*r+2]=t[r+2],s[2*r+3]=t[r+3],s[2*r+4]=t[r+4],s[2*r+5]=t[r+5];return super.setColors(s),this}setFromPoints(t){const e=t.length-1,s=new Float32Array(6*e);for(let r=0;r<e;r++)s[6*r]=t[r].x,s[6*r+1]=t[r].y,s[6*r+2]=t[r].z||0,s[6*r+3]=t[r+1].x,s[6*r+4]=t[r+1].y,s[6*r+5]=t[r+1].z||0;return super.setPositions(s),this}fromLine(t){const e=t.geometry;return this.setPositions(e.attributes.position.array),this}}exports.LineGeometry=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LineSegmentsGeometry as t}from"./LineSegmentsGeometry.esm.js";class e extends t{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(t){const e=t.length-3,s=new Float32Array(2*e);for(let r=0;r<e;r+=3)s[2*r]=t[r],s[2*r+1]=t[r+1],s[2*r+2]=t[r+2],s[2*r+3]=t[r+3],s[2*r+4]=t[r+4],s[2*r+5]=t[r+5];return super.setPositions(s),this}setColors(t){const e=t.length-3,s=new Float32Array(2*e);for(let r=0;r<e;r+=3)s[2*r]=t[r],s[2*r+1]=t[r+1],s[2*r+2]=t[r+2],s[2*r+3]=t[r+3],s[2*r+4]=t[r+4],s[2*r+5]=t[r+5];return super.setColors(s),this}setFromPoints(t){const e=t.length-1,s=new Float32Array(6*e);for(let r=0;r<e;r++)s[6*r]=t[r].x,s[6*r+1]=t[r].y,s[6*r+2]=t[r].z||0,s[6*r+3]=t[r+1].x,s[6*r+4]=t[r+1].y,s[6*r+5]=t[r+1].z||0;return super.setPositions(s),this}fromLine(t){const e=t.geometry;return this.setPositions(e.attributes.position.array),this}}export{e as LineGeometry};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var t=require("../../../build/three.module.cjs.js"),n=require("../../../build/three.core.cjs.js");t.UniformsLib.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new n.Vector2(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},t.ShaderLib.line={uniforms:n.UniformsUtils.merge([t.UniformsLib.common,t.UniformsLib.fog,t.UniformsLib.line]),vertexShader:"\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tworldStart = start.xyz;\n\t\t\t\tworldEnd = end.xyz;\n\n\t\t\t#else\n\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec3 ndcStart = clipStart.xyz / clipStart.w;\n\t\t\tvec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd.xy - ndcStart.xy;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tvec3 worldDir = normalize( end.xyz - start.xyz );\n\t\t\t\tvec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );\n\t\t\t\tvec3 worldUp = normalize( cross( worldDir, tmpFwd ) );\n\t\t\t\tvec3 worldFwd = cross( worldDir, worldUp );\n\t\t\t\tworldPos = position.y < 0.5 ? start: end;\n\n\t\t\t\t// height offset\n\t\t\t\tfloat hw = linewidth * 0.5;\n\t\t\t\tworldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;\n\n\t\t\t\t// don't extend the line if we're rendering dashes because we\n\t\t\t\t// won't be rendering the endcaps\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t// cap extension\n\t\t\t\t\tworldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;\n\n\t\t\t\t\t// add width to the box\n\t\t\t\t\tworldPos.xyz += worldFwd * hw;\n\n\t\t\t\t\t// endcaps\n\t\t\t\t\tif ( position.y > 1.0 || position.y < 0.0 ) {\n\n\t\t\t\t\t\tworldPos.xyz -= worldFwd * 2.0 * hw;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t\t// project the worldpos\n\t\t\t\tvec4 clip = projectionMatrix * worldPos;\n\n\t\t\t\t// shift the depth of the projected points so the line\n\t\t\t\t// segments overlap neatly\n\t\t\t\tvec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;\n\t\t\t\tclip.z = clipPose.z * clip.w;\n\n\t\t\t#else\n\n\t\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\t\t\t\t// undo aspect ratio adjustment\n\t\t\t\tdir.x /= aspect;\n\t\t\t\toffset.x /= aspect;\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\t\toffset += - dir;\n\n\t\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\t\toffset += dir;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth;\n\n\t\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\t\toffset /= resolution.y;\n\n\t\t\t\t// select end\n\t\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t\t// back to clip space\n\t\t\t\toffset *= clip.w;\n\n\t\t\t\tclip.xy += offset;\n\n\t\t\t#endif\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\t\tuniform float linewidth;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashOffset;\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n\t\t\tfloat mua;\n\t\t\tfloat mub;\n\n\t\t\tvec3 p13 = p1 - p3;\n\t\t\tvec3 p43 = p4 - p3;\n\n\t\t\tvec3 p21 = p2 - p1;\n\n\t\t\tfloat d1343 = dot( p13, p43 );\n\t\t\tfloat d4321 = dot( p43, p21 );\n\t\t\tfloat d1321 = dot( p13, p21 );\n\t\t\tfloat d4343 = dot( p43, p43 );\n\t\t\tfloat d2121 = dot( p21, p21 );\n\n\t\t\tfloat denom = d2121 * d4343 - d4321 * d4321;\n\n\t\t\tfloat numer = d1343 * d4321 - d1321 * d4343;\n\n\t\t\tmua = numer / denom;\n\t\t\tmua = clamp( mua, 0.0, 1.0 );\n\t\t\tmub = ( d1343 + d4321 * ( mua ) ) / d4343;\n\t\t\tmub = clamp( mub, 0.0, 1.0 );\n\n\t\t\treturn vec2( mua, mub );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tfloat alpha = opacity;\n\t\t\tvec4 diffuseColor = vec4( diffuse, alpha );\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// Find the closest points on the view ray and the line segment\n\t\t\t\tvec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n\t\t\t\tvec3 lineDir = worldEnd - worldStart;\n\t\t\t\tvec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n\t\t\t\tvec3 p1 = worldStart + lineDir * params.x;\n\t\t\t\tvec3 p2 = rayEnd * params.y;\n\t\t\t\tvec3 delta = p1 - p2;\n\t\t\t\tfloat len = length( delta );\n\t\t\t\tfloat norm = len / linewidth;\n\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t\tfloat dnorm = fwidth( norm );\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );\n\n\t\t\t\t\t#else\n\n\t\t\t\t\t\tif ( norm > 0.5 ) {\n\n\t\t\t\t\t\t\tdiscard;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t#else\n\n\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t// artifacts appear on some hardware if a derivative is taken within a conditional\n\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\tfloat len2 = a * a + b * b;\n\t\t\t\t\tfloat dlen = fwidth( len2 );\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <colorspace_fragment>\n\t\t\t#include <fog_fragment>\n\t\t\t#include <premultiplied_alpha_fragment>\n\n\t\t}\n\t\t"};class e extends n.ShaderMaterial{constructor(e){super({type:"LineMaterial",uniforms:n.UniformsUtils.clone(t.ShaderLib.line.uniforms),vertexShader:t.ShaderLib.line.vertexShader,fragmentShader:t.ShaderLib.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(t){this.uniforms.diffuse.value=t}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(t){!0===t?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(t){this.uniforms.linewidth&&(this.uniforms.linewidth.value=t)}get dashed(){return"USE_DASH"in this.defines}set dashed(t){!0===t!==this.dashed&&(this.needsUpdate=!0),!0===t?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(t){this.uniforms.dashScale.value=t}get dashSize(){return this.uniforms.dashSize.value}set dashSize(t){this.uniforms.dashSize.value=t}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(t){this.uniforms.dashOffset.value=t}get gapSize(){return this.uniforms.gapSize.value}set gapSize(t){this.uniforms.gapSize.value=t}get opacity(){return this.uniforms.opacity.value}set opacity(t){this.uniforms&&(this.uniforms.opacity.value=t)}get resolution(){return this.uniforms.resolution.value}set resolution(t){this.uniforms.resolution.value.copy(t)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(t){this.defines&&(!0===t!==this.alphaToCoverage&&(this.needsUpdate=!0),!0===t?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}exports.LineMaterial=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ShaderLib as t,UniformsLib as n}from"../../../build/three.module.esm.js";import{ShaderMaterial as e,UniformsUtils as i,Vector2 as a}from"../../../build/three.core.esm.js";n.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new a(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},t.line={uniforms:i.merge([n.common,n.fog,n.line]),vertexShader:"\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tworldStart = start.xyz;\n\t\t\t\tworldEnd = end.xyz;\n\n\t\t\t#else\n\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec3 ndcStart = clipStart.xyz / clipStart.w;\n\t\t\tvec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd.xy - ndcStart.xy;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tvec3 worldDir = normalize( end.xyz - start.xyz );\n\t\t\t\tvec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );\n\t\t\t\tvec3 worldUp = normalize( cross( worldDir, tmpFwd ) );\n\t\t\t\tvec3 worldFwd = cross( worldDir, worldUp );\n\t\t\t\tworldPos = position.y < 0.5 ? start: end;\n\n\t\t\t\t// height offset\n\t\t\t\tfloat hw = linewidth * 0.5;\n\t\t\t\tworldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;\n\n\t\t\t\t// don't extend the line if we're rendering dashes because we\n\t\t\t\t// won't be rendering the endcaps\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t// cap extension\n\t\t\t\t\tworldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;\n\n\t\t\t\t\t// add width to the box\n\t\t\t\t\tworldPos.xyz += worldFwd * hw;\n\n\t\t\t\t\t// endcaps\n\t\t\t\t\tif ( position.y > 1.0 || position.y < 0.0 ) {\n\n\t\t\t\t\t\tworldPos.xyz -= worldFwd * 2.0 * hw;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t\t// project the worldpos\n\t\t\t\tvec4 clip = projectionMatrix * worldPos;\n\n\t\t\t\t// shift the depth of the projected points so the line\n\t\t\t\t// segments overlap neatly\n\t\t\t\tvec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;\n\t\t\t\tclip.z = clipPose.z * clip.w;\n\n\t\t\t#else\n\n\t\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\t\t\t\t// undo aspect ratio adjustment\n\t\t\t\tdir.x /= aspect;\n\t\t\t\toffset.x /= aspect;\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\t\toffset += - dir;\n\n\t\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\t\toffset += dir;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth;\n\n\t\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\t\toffset /= resolution.y;\n\n\t\t\t\t// select end\n\t\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t\t// back to clip space\n\t\t\t\toffset *= clip.w;\n\n\t\t\t\tclip.xy += offset;\n\n\t\t\t#endif\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\t\tuniform float linewidth;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashOffset;\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n\t\t\tfloat mua;\n\t\t\tfloat mub;\n\n\t\t\tvec3 p13 = p1 - p3;\n\t\t\tvec3 p43 = p4 - p3;\n\n\t\t\tvec3 p21 = p2 - p1;\n\n\t\t\tfloat d1343 = dot( p13, p43 );\n\t\t\tfloat d4321 = dot( p43, p21 );\n\t\t\tfloat d1321 = dot( p13, p21 );\n\t\t\tfloat d4343 = dot( p43, p43 );\n\t\t\tfloat d2121 = dot( p21, p21 );\n\n\t\t\tfloat denom = d2121 * d4343 - d4321 * d4321;\n\n\t\t\tfloat numer = d1343 * d4321 - d1321 * d4343;\n\n\t\t\tmua = numer / denom;\n\t\t\tmua = clamp( mua, 0.0, 1.0 );\n\t\t\tmub = ( d1343 + d4321 * ( mua ) ) / d4343;\n\t\t\tmub = clamp( mub, 0.0, 1.0 );\n\n\t\t\treturn vec2( mua, mub );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tfloat alpha = opacity;\n\t\t\tvec4 diffuseColor = vec4( diffuse, alpha );\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// Find the closest points on the view ray and the line segment\n\t\t\t\tvec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n\t\t\t\tvec3 lineDir = worldEnd - worldStart;\n\t\t\t\tvec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n\t\t\t\tvec3 p1 = worldStart + lineDir * params.x;\n\t\t\t\tvec3 p2 = rayEnd * params.y;\n\t\t\t\tvec3 delta = p1 - p2;\n\t\t\t\tfloat len = length( delta );\n\t\t\t\tfloat norm = len / linewidth;\n\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t\tfloat dnorm = fwidth( norm );\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );\n\n\t\t\t\t\t#else\n\n\t\t\t\t\t\tif ( norm > 0.5 ) {\n\n\t\t\t\t\t\t\tdiscard;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t#else\n\n\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t// artifacts appear on some hardware if a derivative is taken within a conditional\n\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\tfloat len2 = a * a + b * b;\n\t\t\t\t\tfloat dlen = fwidth( len2 );\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <colorspace_fragment>\n\t\t\t#include <fog_fragment>\n\t\t\t#include <premultiplied_alpha_fragment>\n\n\t\t}\n\t\t"};class o extends e{constructor(n){super({type:"LineMaterial",uniforms:i.clone(t.line.uniforms),vertexShader:t.line.vertexShader,fragmentShader:t.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(n)}get color(){return this.uniforms.diffuse.value}set color(t){this.uniforms.diffuse.value=t}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(t){!0===t?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(t){this.uniforms.linewidth&&(this.uniforms.linewidth.value=t)}get dashed(){return"USE_DASH"in this.defines}set dashed(t){!0===t!==this.dashed&&(this.needsUpdate=!0),!0===t?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(t){this.uniforms.dashScale.value=t}get dashSize(){return this.uniforms.dashSize.value}set dashSize(t){this.uniforms.dashSize.value=t}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(t){this.uniforms.dashOffset.value=t}get gapSize(){return this.uniforms.gapSize.value}set gapSize(t){this.uniforms.gapSize.value=t}get opacity(){return this.uniforms.opacity.value}set opacity(t){this.uniforms&&(this.uniforms.opacity.value=t)}get resolution(){return this.uniforms.resolution.value}set resolution(t){this.uniforms.resolution.value.copy(t)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(t){this.defines&&(!0===t!==this.alphaToCoverage&&(this.needsUpdate=!0),!0===t?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}export{o as LineMaterial};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";require("../../../build/three.module.cjs.js");var t=require("./LineSegmentsGeometry.cjs.js"),e=require("./LineMaterial.cjs.js"),n=require("../../../build/three.core.cjs.js");const r=new n.Vector4,i=new n.Vector3,a=new n.Vector3,o=new n.Vector4,s=new n.Vector4,c=new n.Vector4,l=new n.Vector3,u=new n.Matrix4,p=new n.Line3,m=new n.Vector3,d=new n.Box3,f=new n.Sphere,x=new n.Vector4;let y,h;function w(t,e,n){return x.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),x.multiplyScalar(1/x.w),x.x=h/n.width,x.y=h/n.height,x.applyMatrix4(t.projectionMatrixInverse),x.multiplyScalar(1/x.w),Math.abs(Math.max(x.x,x.y))}class M extends n.Mesh{constructor(n=new t.LineSegmentsGeometry,r=new e.LineMaterial({color:16777215*Math.random()})){super(n,r),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const t=this.geometry,e=t.attributes.instanceStart,r=t.attributes.instanceEnd,o=new Float32Array(2*e.count);for(let t=0,n=0,s=e.count;t<s;t++,n+=2)i.fromBufferAttribute(e,t),a.fromBufferAttribute(r,t),o[n]=0===n?0:o[n-1],o[n+1]=o[n]+i.distanceTo(a);const s=new n.InstancedInterleavedBuffer(o,2,1);return t.setAttribute("instanceDistanceStart",new n.InterleavedBufferAttribute(s,1,0)),t.setAttribute("instanceDistanceEnd",new n.InterleavedBufferAttribute(s,1,1)),this}raycast(t,e){const r=this.material.worldUnits,i=t.camera,a=void 0!==t.params.Line2&&t.params.Line2.threshold||0;y=t.ray;const x=this.matrixWorld,M=this.geometry,b=this.material;let S,g;if(h=b.linewidth+a,null===M.boundingSphere&&M.computeBoundingSphere(),f.copy(M.boundingSphere).applyMatrix4(x),r)S=.5*h;else{S=w(i,Math.max(i.near,f.distanceToPoint(y.origin)),b.resolution)}if(f.radius+=S,!1!==y.intersectsSphere(f)){if(null===M.boundingBox&&M.computeBoundingBox(),d.copy(M.boundingBox).applyMatrix4(x),r)g=.5*h;else{g=w(i,Math.max(i.near,d.distanceToPoint(y.origin)),b.resolution)}d.expandByScalar(g),!1!==y.intersectsBox(d)&&(r?function(t,e){const r=t.matrixWorld,i=t.geometry,a=i.attributes.instanceStart,o=i.attributes.instanceEnd;for(let s=0,c=Math.min(i.instanceCount,a.count);s<c;s++){p.start.fromBufferAttribute(a,s),p.end.fromBufferAttribute(o,s),p.applyMatrix4(r);const i=new n.Vector3,c=new n.Vector3;y.distanceSqToSegment(p.start,p.end,c,i),c.distanceTo(i)<.5*h&&e.push({point:c,pointOnLine:i,distance:y.origin.distanceTo(c),object:t,face:null,faceIndex:s,uv:null,uv1:null})}}(this,e):function(t,e,r){const i=e.projectionMatrix,a=t.material.resolution,d=t.matrixWorld,f=t.geometry,x=f.attributes.instanceStart,w=f.attributes.instanceEnd,M=Math.min(f.instanceCount,x.count),b=-e.near;y.at(1,c),c.w=1,c.applyMatrix4(e.matrixWorldInverse),c.applyMatrix4(i),c.multiplyScalar(1/c.w),c.x*=a.x/2,c.y*=a.y/2,c.z=0,l.copy(c),u.multiplyMatrices(e.matrixWorldInverse,d);for(let e=0,c=M;e<c;e++){if(o.fromBufferAttribute(x,e),s.fromBufferAttribute(w,e),o.w=1,s.w=1,o.applyMatrix4(u),s.applyMatrix4(u),o.z>b&&s.z>b)continue;if(o.z>b){const t=o.z-s.z,e=(o.z-b)/t;o.lerp(s,e)}else if(s.z>b){const t=s.z-o.z,e=(s.z-b)/t;s.lerp(o,e)}o.applyMatrix4(i),s.applyMatrix4(i),o.multiplyScalar(1/o.w),s.multiplyScalar(1/s.w),o.x*=a.x/2,o.y*=a.y/2,s.x*=a.x/2,s.y*=a.y/2,p.start.copy(o),p.start.z=0,p.end.copy(s),p.end.z=0;const c=p.closestPointToPointParameter(l,!0);p.at(c,m);const f=n.MathUtils.lerp(o.z,s.z,c),M=f>=-1&&f<=1,S=l.distanceTo(m)<.5*h;if(M&&S){p.start.fromBufferAttribute(x,e),p.end.fromBufferAttribute(w,e),p.start.applyMatrix4(d),p.end.applyMatrix4(d);const i=new n.Vector3,a=new n.Vector3;y.distanceSqToSegment(p.start,p.end,a,i),r.push({point:a,pointOnLine:i,distance:y.origin.distanceTo(a),object:t,face:null,faceIndex:e,uv:null,uv1:null})}}}(this,i,e))}}onBeforeRender(t){const e=this.material.uniforms;e&&e.resolution&&(t.getViewport(r),this.material.uniforms.resolution.value.set(r.z,r.w))}}exports.LineSegments2=M;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../../../build/three.module.esm.js";import{LineSegmentsGeometry as t}from"./LineSegmentsGeometry.esm.js";import{LineMaterial as e}from"./LineMaterial.esm.js";import{Mesh as n,Vector3 as i,InstancedInterleavedBuffer as r,InterleavedBufferAttribute as a,Sphere as o,Box3 as s,Vector4 as l,Line3 as c,Matrix4 as u,MathUtils as p}from"../../../build/three.core.esm.js";const m=new l,d=new i,f=new i,y=new l,x=new l,w=new l,h=new i,b=new u,M=new c,g=new i,S=new s,z=new o,B=new l;let A,T;function j(t,e,n){return B.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),B.multiplyScalar(1/B.w),B.x=T/n.width,B.y=T/n.height,B.applyMatrix4(t.projectionMatrixInverse),B.multiplyScalar(1/B.w),Math.abs(Math.max(B.x,B.y))}class v extends n{constructor(n=new t,i=new e({color:16777215*Math.random()})){super(n,i),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const t=this.geometry,e=t.attributes.instanceStart,n=t.attributes.instanceEnd,i=new Float32Array(2*e.count);for(let t=0,r=0,a=e.count;t<a;t++,r+=2)d.fromBufferAttribute(e,t),f.fromBufferAttribute(n,t),i[r]=0===r?0:i[r-1],i[r+1]=i[r]+d.distanceTo(f);const o=new r(i,2,1);return t.setAttribute("instanceDistanceStart",new a(o,1,0)),t.setAttribute("instanceDistanceEnd",new a(o,1,1)),this}raycast(t,e){const n=this.material.worldUnits,r=t.camera,a=void 0!==t.params.Line2&&t.params.Line2.threshold||0;A=t.ray;const o=this.matrixWorld,s=this.geometry,l=this.material;let c,u;if(T=l.linewidth+a,null===s.boundingSphere&&s.computeBoundingSphere(),z.copy(s.boundingSphere).applyMatrix4(o),n)c=.5*T;else{c=j(r,Math.max(r.near,z.distanceToPoint(A.origin)),l.resolution)}if(z.radius+=c,!1!==A.intersectsSphere(z)){if(null===s.boundingBox&&s.computeBoundingBox(),S.copy(s.boundingBox).applyMatrix4(o),n)u=.5*T;else{u=j(r,Math.max(r.near,S.distanceToPoint(A.origin)),l.resolution)}S.expandByScalar(u),!1!==A.intersectsBox(S)&&(n?function(t,e){const n=t.matrixWorld,r=t.geometry,a=r.attributes.instanceStart,o=r.attributes.instanceEnd;for(let s=0,l=Math.min(r.instanceCount,a.count);s<l;s++){M.start.fromBufferAttribute(a,s),M.end.fromBufferAttribute(o,s),M.applyMatrix4(n);const r=new i,l=new i;A.distanceSqToSegment(M.start,M.end,l,r),l.distanceTo(r)<.5*T&&e.push({point:l,pointOnLine:r,distance:A.origin.distanceTo(l),object:t,face:null,faceIndex:s,uv:null,uv1:null})}}(this,e):function(t,e,n){const r=e.projectionMatrix,a=t.material.resolution,o=t.matrixWorld,s=t.geometry,l=s.attributes.instanceStart,c=s.attributes.instanceEnd,u=Math.min(s.instanceCount,l.count),m=-e.near;A.at(1,w),w.w=1,w.applyMatrix4(e.matrixWorldInverse),w.applyMatrix4(r),w.multiplyScalar(1/w.w),w.x*=a.x/2,w.y*=a.y/2,w.z=0,h.copy(w),b.multiplyMatrices(e.matrixWorldInverse,o);for(let e=0,s=u;e<s;e++){if(y.fromBufferAttribute(l,e),x.fromBufferAttribute(c,e),y.w=1,x.w=1,y.applyMatrix4(b),x.applyMatrix4(b),y.z>m&&x.z>m)continue;if(y.z>m){const t=y.z-x.z,e=(y.z-m)/t;y.lerp(x,e)}else if(x.z>m){const t=x.z-y.z,e=(x.z-m)/t;x.lerp(y,e)}y.applyMatrix4(r),x.applyMatrix4(r),y.multiplyScalar(1/y.w),x.multiplyScalar(1/x.w),y.x*=a.x/2,y.y*=a.y/2,x.x*=a.x/2,x.y*=a.y/2,M.start.copy(y),M.start.z=0,M.end.copy(x),M.end.z=0;const s=M.closestPointToPointParameter(h,!0);M.at(s,g);const u=p.lerp(y.z,x.z,s),d=u>=-1&&u<=1,f=h.distanceTo(g)<.5*T;if(d&&f){M.start.fromBufferAttribute(l,e),M.end.fromBufferAttribute(c,e),M.start.applyMatrix4(o),M.end.applyMatrix4(o);const r=new i,a=new i;A.distanceSqToSegment(M.start,M.end,a,r),n.push({point:a,pointOnLine:r,distance:A.origin.distanceTo(a),object:t,face:null,faceIndex:e,uv:null,uv1:null})}}}(this,r,e))}}onBeforeRender(t){const e=this.material.uniforms;e&&e.resolution&&(t.getViewport(m),this.material.uniforms.resolution.value.set(m.z,m.w))}}export{v as LineSegments2};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";require("../../../build/three.module.cjs.js");var t=require("../../../build/three.core.cjs.js");const e=new t.Box3,i=new t.Vector3;class r extends t.InstancedBufferGeometry{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new t.Float32BufferAttribute([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new t.Float32BufferAttribute([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(t){const e=this.attributes.instanceStart,i=this.attributes.instanceEnd;return void 0!==e&&(e.applyMatrix4(t),i.applyMatrix4(t),e.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}setPositions(e){let i;e instanceof Float32Array?i=e:Array.isArray(e)&&(i=new Float32Array(e));const r=new t.InstancedInterleavedBuffer(i,6,1);return this.setAttribute("instanceStart",new t.InterleavedBufferAttribute(r,3,0)),this.setAttribute("instanceEnd",new t.InterleavedBufferAttribute(r,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let i;e instanceof Float32Array?i=e:Array.isArray(e)&&(i=new Float32Array(e));const r=new t.InstancedInterleavedBuffer(i,6,1);return this.setAttribute("instanceColorStart",new t.InterleavedBufferAttribute(r,3,0)),this.setAttribute("instanceColorEnd",new t.InterleavedBufferAttribute(r,3,3)),this}fromWireframeGeometry(t){return this.setPositions(t.attributes.position.array),this}fromEdgesGeometry(t){return this.setPositions(t.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new t.WireframeGeometry(e.geometry)),this}fromLineSegments(t){const e=t.geometry;return this.setPositions(e.attributes.position.array),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new t.Box3);const i=this.attributes.instanceStart,r=this.attributes.instanceEnd;void 0!==i&&void 0!==r&&(this.boundingBox.setFromBufferAttribute(i),e.setFromBufferAttribute(r),this.boundingBox.union(e))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new t.Sphere),null===this.boundingBox&&this.computeBoundingBox();const e=this.attributes.instanceStart,r=this.attributes.instanceEnd;if(void 0!==e&&void 0!==r){const t=this.boundingSphere.center;this.boundingBox.getCenter(t);let n=0;for(let s=0,o=e.count;s<o;s++)i.fromBufferAttribute(e,s),n=Math.max(n,t.distanceToSquared(i)),i.fromBufferAttribute(r,s),n=Math.max(n,t.distanceToSquared(i));this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)}}toJSON(){}}exports.LineSegmentsGeometry=r;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../../../build/three.module.esm.js";import{InstancedBufferGeometry as t,Float32BufferAttribute as e,InstancedInterleavedBuffer as i,InterleavedBufferAttribute as n,WireframeGeometry as s,Box3 as r,Sphere as o,Vector3 as u}from"../../../build/three.core.esm.js";const a=new r,h=new u;class d extends t{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new e([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new e([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(t){const e=this.attributes.instanceStart,i=this.attributes.instanceEnd;return void 0!==e&&(e.applyMatrix4(t),i.applyMatrix4(t),e.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}setPositions(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const s=new i(e,6,1);return this.setAttribute("instanceStart",new n(s,3,0)),this.setAttribute("instanceEnd",new n(s,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const s=new i(e,6,1);return this.setAttribute("instanceColorStart",new n(s,3,0)),this.setAttribute("instanceColorEnd",new n(s,3,3)),this}fromWireframeGeometry(t){return this.setPositions(t.attributes.position.array),this}fromEdgesGeometry(t){return this.setPositions(t.attributes.position.array),this}fromMesh(t){return this.fromWireframeGeometry(new s(t.geometry)),this}fromLineSegments(t){const e=t.geometry;return this.setPositions(e.attributes.position.array),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new r);const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;void 0!==t&&void 0!==e&&(this.boundingBox.setFromBufferAttribute(t),a.setFromBufferAttribute(e),this.boundingBox.union(a))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new o),null===this.boundingBox&&this.computeBoundingBox();const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;if(void 0!==t&&void 0!==e){const i=this.boundingSphere.center;this.boundingBox.getCenter(i);let n=0;for(let s=0,r=t.count;s<r;s++)h.fromBufferAttribute(t,s),n=Math.max(n,i.distanceToSquared(h)),h.fromBufferAttribute(e,s),n=Math.max(n,i.distanceToSquared(h));this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)}}toJSON(){}}export{d as LineSegmentsGeometry};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";require("../../../build/three.module.cjs.js");var t=require("../../../build/three.core.cjs.js");function e(e){let r,n,o,u=-1,i=0;for(let t=0;t<e.length;++t){const s=e[t];if(void 0===r&&(r=s.array.constructor),r!==s.array.constructor)return null;if(void 0===n&&(n=s.itemSize),n!==s.itemSize)return null;if(void 0===o&&(o=s.normalized),o!==s.normalized)return null;if(-1===u&&(u=s.gpuType),u!==s.gpuType)return null;i+=s.count*n}const s=new r(i),l=new t.BufferAttribute(s,n,o);let f=0;for(let t=0;t<e.length;++t){const r=e[t];if(r.isInterleavedBufferAttribute){const t=f/n;for(let e=0,o=r.count;e<o;e++)for(let o=0;o<n;o++){const n=r.getComponent(e,o);l.setComponent(e+t,o,n)}}else s.set(r.array,f);f+=r.count*n}return void 0!==u&&(l.gpuType=u),l}exports.mergeAttributes=e,exports.mergeGeometries=function(r,n=!1){const o=null!==r[0].index,u=new Set(Object.keys(r[0].attributes)),i=new Set(Object.keys(r[0].morphAttributes)),s={},l={},f=r[0].morphTargetsRelative,c=new t.BufferGeometry;let p=0;for(let t=0;t<r.length;++t){const e=r[t];let a=0;if(o!==(null!==e.index))return null;for(const t in e.attributes){if(!u.has(t))return null;void 0===s[t]&&(s[t]=[]),s[t].push(e.attributes[t]),a++}if(a!==u.size)return null;if(f!==e.morphTargetsRelative)return null;for(const t in e.morphAttributes){if(!i.has(t))return null;void 0===l[t]&&(l[t]=[]),l[t].push(e.morphAttributes[t])}if(n){let r;if(o)r=e.index.count;else{if(void 0===e.attributes.position)return null;r=e.attributes.position.count}c.addGroup(p,r,t),p+=r}}if(o){let t=0;const e=[];for(let n=0;n<r.length;++n){const o=r[n].index;for(let r=0;r<o.count;++r)e.push(o.getX(r)+t);t+=r[n].attributes.position.count}c.setIndex(e)}for(const t in s){const r=e(s[t]);if(!r)return null;c.setAttribute(t,r)}for(const t in l){const r=l[t][0].length;if(0===r)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[t]=[];for(let n=0;n<r;++n){const r=[];for(let e=0;e<l[t].length;++e)r.push(l[t][e][n]);const o=e(r);if(!o)return null;c.morphAttributes[t].push(o)}}return c},exports.toTrianglesDrawMode=function(e,r){if(r===t.TrianglesDrawMode)return e;if(r===t.TriangleFanDrawMode||r===t.TriangleStripDrawMode){let n=e.getIndex();if(null===n){const t=[],r=e.getAttribute("position");if(void 0===r)return e;for(let e=0;e<r.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}const o=n.count-2,u=[];if(r===t.TriangleFanDrawMode)for(let t=1;t<=o;t++)u.push(n.getX(0)),u.push(n.getX(t)),u.push(n.getX(t+1));else for(let t=0;t<o;t++)t%2==0?(u.push(n.getX(t)),u.push(n.getX(t+1)),u.push(n.getX(t+2))):(u.push(n.getX(t+2)),u.push(n.getX(t+1)),u.push(n.getX(t)));u.length;const i=e.clone();return i.setIndex(u),i.clearGroups(),i}return e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{TrianglesDrawMode as
|
|
1
|
+
import"../../../build/three.module.esm.js";import{TrianglesDrawMode as t,TriangleFanDrawMode as e,TriangleStripDrawMode as n,BufferGeometry as r,BufferAttribute as o}from"../../../build/three.core.esm.js";function u(t,e=!1){const n=null!==t[0].index,o=new Set(Object.keys(t[0].attributes)),u=new Set(Object.keys(t[0].morphAttributes)),s={},l={},f=t[0].morphTargetsRelative,c=new r;let p=0;for(let r=0;r<t.length;++r){const i=t[r];let h=0;if(n!==(null!==i.index))return null;for(const t in i.attributes){if(!o.has(t))return null;void 0===s[t]&&(s[t]=[]),s[t].push(i.attributes[t]),h++}if(h!==o.size)return null;if(f!==i.morphTargetsRelative)return null;for(const t in i.morphAttributes){if(!u.has(t))return null;void 0===l[t]&&(l[t]=[]),l[t].push(i.morphAttributes[t])}if(e){let t;if(n)t=i.index.count;else{if(void 0===i.attributes.position)return null;t=i.attributes.position.count}c.addGroup(p,t,r),p+=t}}if(n){let e=0;const n=[];for(let r=0;r<t.length;++r){const o=t[r].index;for(let t=0;t<o.count;++t)n.push(o.getX(t)+e);e+=t[r].attributes.position.count}c.setIndex(n)}for(const t in s){const e=i(s[t]);if(!e)return null;c.setAttribute(t,e)}for(const t in l){const e=l[t][0].length;if(0===e)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[t]=[];for(let n=0;n<e;++n){const e=[];for(let r=0;r<l[t].length;++r)e.push(l[t][r][n]);const r=i(e);if(!r)return null;c.morphAttributes[t].push(r)}}return c}function i(t){let e,n,r,u=-1,i=0;for(let o=0;o<t.length;++o){const s=t[o];if(void 0===e&&(e=s.array.constructor),e!==s.array.constructor)return null;if(void 0===n&&(n=s.itemSize),n!==s.itemSize)return null;if(void 0===r&&(r=s.normalized),r!==s.normalized)return null;if(-1===u&&(u=s.gpuType),u!==s.gpuType)return null;i+=s.count*n}const s=new e(i),l=new o(s,n,r);let f=0;for(let e=0;e<t.length;++e){const r=t[e];if(r.isInterleavedBufferAttribute){const t=f/n;for(let e=0,o=r.count;e<o;e++)for(let o=0;o<n;o++){const n=r.getComponent(e,o);l.setComponent(e+t,o,n)}}else s.set(r.array,f);f+=r.count*n}return void 0!==u&&(l.gpuType=u),l}function s(r,o){if(o===t)return r;if(o===e||o===n){let t=r.getIndex();if(null===t){const e=[],n=r.getAttribute("position");if(void 0===n)return r;for(let t=0;t<n.count;t++)e.push(t);r.setIndex(e),t=r.getIndex()}const n=t.count-2,u=[];if(o===e)for(let e=1;e<=n;e++)u.push(t.getX(0)),u.push(t.getX(e)),u.push(t.getX(e+1));else for(let e=0;e<n;e++)e%2==0?(u.push(t.getX(e)),u.push(t.getX(e+1)),u.push(t.getX(e+2))):(u.push(t.getX(e+2)),u.push(t.getX(e+1)),u.push(t.getX(e)));u.length;const i=r.clone();return i.setIndex(u),i.clearGroups(),i}return r}export{i as mergeAttributes,u as mergeGeometries,s as toTrianglesDrawMode};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";exports.clamp=function(t,a,n){return Math.max(a,Math.min(n,t))};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(t,n,a){return Math.max(n,Math.min(a,t))}export{t as clamp};
|
package/dist/package.json
CHANGED
package/dist/t3d-ez.gl.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./utils/index.cjs.js"),r=require("./core/Meshes/index.cjs.js"),s=require("./core/WebGLEngine/index.cjs.js"),o=require("./core/Controls/index.cjs.js"),t=require("./core/Lights/index.cjs.js"),i=require("./core/Resource/ResourceManager.cjs.js"),c=require("./core/Resource/types.cjs.js"),l=require("./core/Resource/loaders.cjs.js"),a=require("./core/Materials/index.cjs.js"),
|
|
1
|
+
"use strict";var e=require("./utils/index.cjs.js"),r=require("./core/Meshes/index.cjs.js"),s=require("./core/WebGLEngine/index.cjs.js"),o=require("./core/Controls/index.cjs.js"),t=require("./core/Lights/index.cjs.js"),i=require("./core/Resource/ResourceManager.cjs.js"),c=require("./core/Resource/types.cjs.js"),l=require("./core/Resource/loaders.cjs.js"),a=require("./core/Materials/index.cjs.js"),u=require("./core/DynamicSky/index.cjs.js"),n=require("./core/Map/index.cjs.js"),d=require("./core/Addons/RaycasterAide.cjs.js"),p=require("./core/PostProcessor/index.cjs.js"),j=require("./helpers/InfiniteGridHelper.cjs.js"),x=require("./helpers/AxesAddHelper.cjs.js"),f=require("./helpers/T3DEzViewportGizmo.cjs.js"),B=require("./utils/FpsMeter/index.cjs.js"),P=require("./utils/Logger.cjs.js"),q=require("./core/Meshes/Builders/BoxBuilder.cjs.js"),M=require("./core/Meshes/Builders/SphereBuilder.cjs.js"),E=require("./core/Meshes/Builders/PlaneBuilder.cjs.js"),g=require("./core/Meshes/Builders/CapsuleBuilder.cjs.js"),h=require("./core/Controls/TTControls/TTControls.cjs.js"),T=require("./core/Lights/Builders/DirectionalLightBuilder.cjs.js"),L=require("./core/Lights/Builders/PointLightBuilder.cjs.js"),m=require("./node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/loaders/GLTFLoader.cjs.js"),y=require("./core/Materials/GradationMaterial.cjs.js"),C=require("./core/Materials/FresnelMaterial.cjs.js"),A=require("./core/PostProcessor/effects/PotateEffect.cjs.js"),R=require("./core/PostProcessor/effects/SAOEffect.cjs.js"),S=require("./core/PostProcessor/effects/OutlineEffect.cjs.js"),G=require("./core/PostProcessor/effects/UnrealBloomEffect.cjs.js");exports.destroyModel=e.destroyModel,exports.disposeApp=e.disposeApp,exports.flyTo=e.flyTo,exports.focusTo=e.focusTo,exports.getContainerElement=e.getContainerElement,exports.loadHdrToScene=e.loadHdrToScene,exports.setDefaultEnvironment=e.setDefaultEnvironment,exports.throttleTimer=e.throttleTimer,exports.MeshBuilder=r.MeshBuilder,exports.PotatoEngine=s.PotatoEngine,Object.defineProperty(exports,"CONTROL_TYPE",{enumerable:!0,get:function(){return o.CONTROL_TYPE}}),exports.ControlsManager=o.ControlsManager,exports.LightBuilder=t.LightBuilder,exports.ResourceManager=i.ResourceManager,exports.RESOURCE_TYPE=c.RESOURCE_TYPE,exports.LoaderMaps=l.LoaderMaps,exports.MaterialsLibrary=a.MaterialsLibrary,exports.DynamicSky=u.DynamicSky,exports.PotatoMap=n.PotatoMap,exports.RaycasterAide=d.RaycasterAide,exports.PostProcessor=p.PostProcessor,exports.InfiniteGridHelper=j.InfiniteGridHelper,exports.AxesAddHelper=x.AxesAddHelper,exports.T3DEzViewportGizmo=f.T3DEzViewportGizmo,exports.PerformanceStats=B.PerformanceStats,exports.Logger=P.Logger,exports.BoxBuilder=q.BoxBuilder,exports.SphereBuilder=M.SphereBuilder,exports.PlaneBuilder=E.PlaneBuilder,exports.CapsuleBuilder=g.CapsuleBuilder,exports.TTControls=h.TTControls,exports.DirectionalLightBuilder=T.DirectionalLightBuilder,exports.PointLightBuilder=L.PointLightBuilder,exports.GLTFLoader=m.GLTFLoader,exports.GradationMaterial=y.GradationMaterial,exports.FresnelMaterial=C.FresnelMaterial,exports.PotateEffect=A.PotateEffect,exports.SAOEffect=R.SAOEffect,exports.OutlineEffect=S.OutlineEffect,exports.UnrealBloomEffect=G.UnrealBloomEffect;
|
package/dist/t3d-ez.gl.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{destroyModel,disposeApp,flyTo,focusTo,getContainerElement,loadHdrToScene,setDefaultEnvironment,throttleTimer}from"./utils/index.esm.js";export{MeshBuilder}from"./core/Meshes/index.esm.js";export{PotatoEngine}from"./core/WebGLEngine/index.esm.js";export{CONTROL_TYPE,ControlsManager}from"./core/Controls/index.esm.js";export{LightBuilder}from"./core/Lights/index.esm.js";export{ResourceManager}from"./core/Resource/ResourceManager.esm.js";export{RESOURCE_TYPE}from"./core/Resource/types.esm.js";export{LoaderMaps}from"./core/Resource/loaders.esm.js";export{MaterialsLibrary}from"./core/Materials/index.esm.js";export{DynamicSky}from"./core/DynamicSky/index.esm.js";export{PotatoMap}from"./core/Map/index.esm.js";export{
|
|
1
|
+
export{destroyModel,disposeApp,flyTo,focusTo,getContainerElement,loadHdrToScene,setDefaultEnvironment,throttleTimer}from"./utils/index.esm.js";export{MeshBuilder}from"./core/Meshes/index.esm.js";export{PotatoEngine}from"./core/WebGLEngine/index.esm.js";export{CONTROL_TYPE,ControlsManager}from"./core/Controls/index.esm.js";export{LightBuilder}from"./core/Lights/index.esm.js";export{ResourceManager}from"./core/Resource/ResourceManager.esm.js";export{RESOURCE_TYPE}from"./core/Resource/types.esm.js";export{LoaderMaps}from"./core/Resource/loaders.esm.js";export{MaterialsLibrary}from"./core/Materials/index.esm.js";export{DynamicSky}from"./core/DynamicSky/index.esm.js";export{PotatoMap}from"./core/Map/index.esm.js";export{RaycasterAide}from"./core/Addons/RaycasterAide.esm.js";export{PostProcessor}from"./core/PostProcessor/index.esm.js";export{InfiniteGridHelper}from"./helpers/InfiniteGridHelper.esm.js";export{AxesAddHelper}from"./helpers/AxesAddHelper.esm.js";export{T3DEzViewportGizmo}from"./helpers/T3DEzViewportGizmo.esm.js";export{PerformanceStats}from"./utils/FpsMeter/index.esm.js";export{Logger}from"./utils/Logger.esm.js";export{BoxBuilder}from"./core/Meshes/Builders/BoxBuilder.esm.js";export{SphereBuilder}from"./core/Meshes/Builders/SphereBuilder.esm.js";export{PlaneBuilder}from"./core/Meshes/Builders/PlaneBuilder.esm.js";export{CapsuleBuilder}from"./core/Meshes/Builders/CapsuleBuilder.esm.js";export{TTControls}from"./core/Controls/TTControls/TTControls.esm.js";export{DirectionalLightBuilder}from"./core/Lights/Builders/DirectionalLightBuilder.esm.js";export{PointLightBuilder}from"./core/Lights/Builders/PointLightBuilder.esm.js";export{GLTFLoader}from"./node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/loaders/GLTFLoader.esm.js";export{GradationMaterial}from"./core/Materials/GradationMaterial.esm.js";export{FresnelMaterial}from"./core/Materials/FresnelMaterial.esm.js";export{PotateEffect}from"./core/PostProcessor/effects/PotateEffect.esm.js";export{SAOEffect}from"./core/PostProcessor/effects/SAOEffect.esm.js";export{OutlineEffect}from"./core/PostProcessor/effects/OutlineEffect.esm.js";export{UnrealBloomEffect}from"./core/PostProcessor/effects/UnrealBloomEffect.esm.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Camera, Group, Mesh, Object3D, Raycaster, Vector2 } from "three";
|
|
2
|
+
export declare class RaycasterAide extends Raycaster {
|
|
3
|
+
name: string;
|
|
4
|
+
domContainer: HTMLElement;
|
|
5
|
+
activeMesh: Mesh | null;
|
|
6
|
+
activeGroup: Group | Mesh | null;
|
|
7
|
+
constructor(domEle: HTMLElement);
|
|
8
|
+
activeSceneGraphMeshNode(evt: MouseEvent, camera: Camera, activeList: Object3D[]): Mesh | Object3D | null;
|
|
9
|
+
activeSceneGraphGroupNode(evt: MouseEvent, camera: Camera, activeList: Object3D[], groupType?: string): Group | Mesh | null;
|
|
10
|
+
getIntersectNodes(evt: MouseEvent, camera: Camera, activeList: Object3D[]): import("three").Intersection<Object3D<import("three").Object3DEventMap>>[];
|
|
11
|
+
getPointerVec2(evt: MouseEvent): Vector2;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./RaycasterAide";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { WebGLRenderTarget } from "three";
|
|
2
2
|
import { EffectComposer } from "three/examples/jsm/postprocessing/EffectComposer.js";
|
|
3
3
|
import { SMAAPass } from "three/examples/jsm/postprocessing/SMAAPass.js";
|
|
4
|
-
import { PotatoEngine } from "../WebGLEngine";
|
|
5
|
-
import { PotateEffect } from "./effects";
|
|
4
|
+
import { PotatoEngine } from "../WebGLEngine/index";
|
|
5
|
+
import { PotateEffect } from "./effects/index";
|
|
6
6
|
import { ShaderPass } from 'three/examples/jsm/postprocessing/ShaderPass.js';
|
|
7
7
|
export declare class PostProcessor extends EffectComposer {
|
|
8
8
|
name: string;
|
|
@@ -18,4 +18,4 @@ export declare class PostProcessor extends EffectComposer {
|
|
|
18
18
|
close(): void;
|
|
19
19
|
dispose(): void;
|
|
20
20
|
}
|
|
21
|
-
export * from "./effects";
|
|
21
|
+
export * from "./effects/index";
|
|
@@ -8,7 +8,7 @@ type rsManagerType = {
|
|
|
8
8
|
export declare class ResourceManager {
|
|
9
9
|
type: string;
|
|
10
10
|
engine: IPotatoEngine;
|
|
11
|
-
LoaderMaps: Map<string, import("three/examples/jsm/loaders/GLTFLoader").GLTFLoader | import("three/examples/jsm/loaders/
|
|
11
|
+
LoaderMaps: Map<string, import("three/examples/jsm/loaders/GLTFLoader").GLTFLoader | import("three/examples/jsm/loaders/HDRLoader").HDRLoader | import("three").TextureLoader>;
|
|
12
12
|
RESOURCE_TYPE: Readonly<{
|
|
13
13
|
GLTF: "GLTF_MODEL";
|
|
14
14
|
HDR: "HDR";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TextureLoader } from 'three';
|
|
2
2
|
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
|
3
|
-
import {
|
|
3
|
+
import { HDRLoader } from 'three/examples/jsm/loaders/HDRLoader.js';
|
|
4
4
|
export { GLTFLoader };
|
|
5
|
-
type loadType = GLTFLoader |
|
|
5
|
+
type loadType = GLTFLoader | HDRLoader | TextureLoader;
|
|
6
6
|
export declare const LoaderMaps: Map<string, loadType>;
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { Vector3, Vector2, Object3D, Quaternion, Clock, Scene } from 'three';
|
|
2
|
+
/**
|
|
3
|
+
* ViewportGizmo is a 3D camera orientation controller that provides a visual interface
|
|
4
|
+
* for changing the camera's viewing angle. It creates a widget that shows the current
|
|
5
|
+
* camera orientation and allows direct manipulation of the view through clicking or dragging.
|
|
6
|
+
*
|
|
7
|
+
* @fires ViewportGizmo#start - Fired when a view change interaction begins
|
|
8
|
+
* @fires ViewportGizmo#change - Fired during view changes
|
|
9
|
+
* @fires ViewportGizmo#end - Fired when a view change interaction ends
|
|
10
|
+
*
|
|
11
|
+
* @extends Object3D
|
|
12
|
+
*/
|
|
13
|
+
declare class T3DEzViewportGizmo extends Object3D {
|
|
14
|
+
/** Whether the gizmo is currently active and responding to user input */
|
|
15
|
+
enabled: boolean;
|
|
16
|
+
/** The camera being controlled by this gizmo */
|
|
17
|
+
camera: any;
|
|
18
|
+
/** The WebGLRenderer rendering the gizmo */
|
|
19
|
+
renderer: any;
|
|
20
|
+
/** The configuration options */
|
|
21
|
+
options: any;
|
|
22
|
+
/** The point around which the camera rotates */
|
|
23
|
+
target: Vector3;
|
|
24
|
+
/** Whether view changes should be animated */
|
|
25
|
+
animated: boolean;
|
|
26
|
+
/** The speed of view change animations. Higher values result in faster animations */
|
|
27
|
+
speed: number;
|
|
28
|
+
/**
|
|
29
|
+
* Indicates whether the gizmo is currently being animated or not,
|
|
30
|
+
* Useful when interacting with other camera controllers
|
|
31
|
+
*
|
|
32
|
+
* @readonly This value is set internally.
|
|
33
|
+
**/
|
|
34
|
+
animating: boolean;
|
|
35
|
+
_options: any;
|
|
36
|
+
_intersections: any;
|
|
37
|
+
_background: null;
|
|
38
|
+
_viewport: number[];
|
|
39
|
+
_originalViewport: number[];
|
|
40
|
+
_originalScissor: number[];
|
|
41
|
+
_scene: Scene<import("three").Object3DEventMap>;
|
|
42
|
+
_camera: any;
|
|
43
|
+
_container: any;
|
|
44
|
+
_domElement: any;
|
|
45
|
+
_domRect: any;
|
|
46
|
+
_dragging: boolean;
|
|
47
|
+
calc_distance: number;
|
|
48
|
+
_clock: Clock;
|
|
49
|
+
_targetQuaternion: Quaternion;
|
|
50
|
+
_quaternionStart: Quaternion;
|
|
51
|
+
_quaternionEnd: Quaternion;
|
|
52
|
+
_pointerStart: Vector2;
|
|
53
|
+
_focus: null;
|
|
54
|
+
_placement: any;
|
|
55
|
+
_controls: any;
|
|
56
|
+
_controlsListeners: any;
|
|
57
|
+
/**
|
|
58
|
+
* Creates a new ViewportGizmo instance.
|
|
59
|
+
*
|
|
60
|
+
* @param camera - The camera to be controlled by this gizmo
|
|
61
|
+
* @param renderer - The WebGL renderer used to render the scene
|
|
62
|
+
* @param options - {@link GizmoOptions}, Configuration options for the gizmo.
|
|
63
|
+
* @param options.container - Parent element for the gizmo. Can be an HTMLElement or a CSS selector string
|
|
64
|
+
* @param options.type - The gizmo configuration type. Either 'sphere' or 'cube', defaults to 'sphere'
|
|
65
|
+
* @param options.size - Size of the gizmo widget in pixels. Defaults to 128
|
|
66
|
+
* @param options.placement - Position of the gizmo in the viewport
|
|
67
|
+
* Options include:
|
|
68
|
+
* - `"top-left"`
|
|
69
|
+
* - `"top-center"`
|
|
70
|
+
* - `"top-right"`
|
|
71
|
+
* - `"center-left"`
|
|
72
|
+
* - `"center-center"`
|
|
73
|
+
* - `"center-right"`
|
|
74
|
+
* - `"bottom-left"`
|
|
75
|
+
* - `"bottom-center"`
|
|
76
|
+
* - `"bottom-right"`
|
|
77
|
+
* @param options.offset - Offset of the gizmo from container edges in pixels
|
|
78
|
+
* @param options.offset.left - Offset from the left edge
|
|
79
|
+
* @param options.offset.top - Offset from the top edge
|
|
80
|
+
* @param options.offset.right - Offset from the right edge
|
|
81
|
+
* @param options.offset.bottom - Offset from the bottom edge
|
|
82
|
+
* @param options.animated - Whether view changes should be animated. Defaults to true
|
|
83
|
+
* @param options.speed - Animation speed multiplier. Defaults to 1
|
|
84
|
+
* @param options.resolution - Texture resolution. Defaults to 64 for sphere, 128 for cube
|
|
85
|
+
* @param options.lineWidth - Width of the axes lines in pixels
|
|
86
|
+
* @param options.id - HTML `id` attribute for the gizmo container
|
|
87
|
+
* @param options.className - HTML `class` attribute for the gizmo container
|
|
88
|
+
* @param options.font - Font configuration for axis labels
|
|
89
|
+
* @param options.font.family - Font family for axis labels
|
|
90
|
+
* @param options.font.weight - Font weight for axis labels
|
|
91
|
+
* @param options.background - Configuration for the background sphere/cube
|
|
92
|
+
* @param options.background.enabled - Whether to display the background
|
|
93
|
+
* @param options.background.color - Color of the background in normal state
|
|
94
|
+
* @param options.background.opacity - Opacity of the background in normal state
|
|
95
|
+
* @param options.background.hover.color - Color of the background when hovered
|
|
96
|
+
* @param options.background.hover.opacity - Opacity of the background when hovered
|
|
97
|
+
* @param options.corners - Configuration for corner indicators
|
|
98
|
+
* @param options.corners.enabled - Whether to display corner indicators
|
|
99
|
+
* @param options.corners.color - Base color of corner indicators
|
|
100
|
+
* @param options.corners.opacity - Opacity of corner indicators
|
|
101
|
+
* @param options.corners.scale - Scale multiplier for corner indicators
|
|
102
|
+
* @param options.corners.radius - Radius of corner indicators
|
|
103
|
+
* @param options.corners.smoothness - Smoothness of corner indicators
|
|
104
|
+
* @param options.corners.hover.color - Color of corner indicators when hovered
|
|
105
|
+
* @param options.corners.hover.opacity - Opacity of corner indicators when hovered
|
|
106
|
+
* @param options.corners.hover.scale - Scale of corner indicators when hovered
|
|
107
|
+
* @param options.edges - Configuration for edge indicators
|
|
108
|
+
* @param options.edges.enabled - Whether to display edge indicators
|
|
109
|
+
* @param options.edges.color - Base color of edge indicators
|
|
110
|
+
* @param options.edges.opacity - Opacity of edge indicators
|
|
111
|
+
* @param options.edges.scale - Scale multiplier for edge indicators
|
|
112
|
+
* @param options.edges.radius - Radius of edge indicators
|
|
113
|
+
* @param options.edges.smoothness - Smoothness of edge indicators
|
|
114
|
+
* @param options.edges.hover.color - Color of edge indicators when hovered
|
|
115
|
+
* @param options.edges.hover.opacity - Opacity of edge indicators when hovered
|
|
116
|
+
* @param options.edges.hover.scale - Scale of edge indicators when hovered
|
|
117
|
+
* @param options.x - Configuration for positive X axis/face
|
|
118
|
+
* @param options.y - Configuration for positive Y axis/face
|
|
119
|
+
* @param options.z - Configuration for positive Z axis/face
|
|
120
|
+
* @param options.nx - Configuration for negative X axis/face
|
|
121
|
+
* @param options.ny - Configuration for negative Y axis/face
|
|
122
|
+
* @param options.nz - Configuration for negative Z axis/face
|
|
123
|
+
*
|
|
124
|
+
* @remarks Axis-specific configuration can also use alias names for cube mode:
|
|
125
|
+
* - `right` (same as `x`)
|
|
126
|
+
* - `left` (same as `nx`)
|
|
127
|
+
* - `top` (same as `y`)
|
|
128
|
+
* - `bottom` (same as `ny`)
|
|
129
|
+
* - `front` (same as `z`)
|
|
130
|
+
* - `back` (same as `nz`)
|
|
131
|
+
*
|
|
132
|
+
* For each axis/face configuration, the following options are available:
|
|
133
|
+
* @param options.AXIS.enabled - Whether to draw the axis
|
|
134
|
+
* @param options.AXIS.label - Custom text label for the axis
|
|
135
|
+
* @param options.AXIS.opacity - Axis opacity
|
|
136
|
+
* @param options.AXIS.scale - Scale multiplier for indicator size
|
|
137
|
+
* @param options.AXIS.line - Whether to draw the axis line
|
|
138
|
+
* @param options.AXIS.color - Axis indicator background color
|
|
139
|
+
* @param options.AXIS.labelColor - Axis label color
|
|
140
|
+
* @param options.AXIS.border.size - Border size around the axis indicator
|
|
141
|
+
* @param options.AXIS.border.color - Border color around the axis indicator
|
|
142
|
+
* @param options.AXIS.hover.color - Fill color on hover
|
|
143
|
+
* @param options.AXIS.hover.labelColor - Label text color on hover
|
|
144
|
+
* @param options.AXIS.hover.opacity - Opacity when hovered
|
|
145
|
+
* @param options.AXIS.hover.scale - Indicator scale when hovered
|
|
146
|
+
* @param options.AXIS.hover.border.size - Hover border size
|
|
147
|
+
* @param options.AXIS.hover.border.color - Hover border color
|
|
148
|
+
*/
|
|
149
|
+
constructor(camera: any, renderer: any, options?: {});
|
|
150
|
+
/** Gets the current placement of the gizmo relative to its container. */
|
|
151
|
+
get placement(): any;
|
|
152
|
+
/**
|
|
153
|
+
* Sets and update the placement of the gizmo relative to its container.
|
|
154
|
+
*
|
|
155
|
+
* @param placement - The new placement position
|
|
156
|
+
*/
|
|
157
|
+
set placement(placement: any);
|
|
158
|
+
/**
|
|
159
|
+
* Regenerates the gizmo with the new options.
|
|
160
|
+
*
|
|
161
|
+
* @remarks
|
|
162
|
+
* - Not recommended for use in real-time rendering or animation loops
|
|
163
|
+
* - Provides a way to completely rebuild the gizmo with new options
|
|
164
|
+
* - Can be computationally expensive, so use sparingly
|
|
165
|
+
*/
|
|
166
|
+
set(options?: {}): this;
|
|
167
|
+
/**
|
|
168
|
+
* Renders the gizmo to the screen.
|
|
169
|
+
* This method handles viewport and scissor management to ensure the gizmo
|
|
170
|
+
* renders correctly without affecting the main scene rendering.
|
|
171
|
+
*
|
|
172
|
+
* @returns The gizmo instance for method chaining
|
|
173
|
+
*/
|
|
174
|
+
render(): this;
|
|
175
|
+
/**
|
|
176
|
+
* Updates the gizmo's DOM-related properties based on its current position
|
|
177
|
+
* and size in the document.
|
|
178
|
+
*
|
|
179
|
+
* @returns The gizmo instance for method chaining
|
|
180
|
+
*/
|
|
181
|
+
domUpdate(): this;
|
|
182
|
+
/**
|
|
183
|
+
* Updates the gizmo's orientation to match the current camera orientation.
|
|
184
|
+
*
|
|
185
|
+
* @returns The gizmo instance for method chaining
|
|
186
|
+
*/
|
|
187
|
+
cameraUpdate(): this;
|
|
188
|
+
/**
|
|
189
|
+
* Performs a complete update of the gizmo, including both DOM and camera-related updates.
|
|
190
|
+
*
|
|
191
|
+
* @param controls - Internal. Set to `false` if the update event comes from the attached controls.
|
|
192
|
+
*
|
|
193
|
+
* @returns The gizmo instance for method chaining
|
|
194
|
+
*/
|
|
195
|
+
update(controls?: boolean): this;
|
|
196
|
+
/**
|
|
197
|
+
* Connects OrbitControls with the gizmo, handling interaction states and updates.
|
|
198
|
+
* Automatically detaches any previously attached controls.
|
|
199
|
+
*
|
|
200
|
+
* @param controls - The scene's {@link https://threejs.org/docs/#examples/en/controls/OrbitControls OrbitControls}
|
|
201
|
+
*/
|
|
202
|
+
attachControls(controls: any): this;
|
|
203
|
+
/** Removes all control event listeners and references. Safe to call multiple times. */
|
|
204
|
+
detachControls(): this | undefined;
|
|
205
|
+
/** Cleans up all resources including geometries, materials, textures, and event listeners. */
|
|
206
|
+
dispose(): void;
|
|
207
|
+
/**
|
|
208
|
+
* Updates the gizmo's orientation either based on the camera or internal state.
|
|
209
|
+
*
|
|
210
|
+
* @private
|
|
211
|
+
* @param fromCamera - Whether to update based on camera orientation (true) or internal state (false)
|
|
212
|
+
*/
|
|
213
|
+
_updateOrientation(fromCamera?: boolean): void;
|
|
214
|
+
/**
|
|
215
|
+
* Handles the animation of camera position and orientation changes.
|
|
216
|
+
*
|
|
217
|
+
* @private
|
|
218
|
+
*/
|
|
219
|
+
_animate(): void;
|
|
220
|
+
/**
|
|
221
|
+
* Sets the camera orientation to look at the target from a specific axis.
|
|
222
|
+
*
|
|
223
|
+
* @private
|
|
224
|
+
* @param position - The axis point position
|
|
225
|
+
*/
|
|
226
|
+
setOrientation(position: any): void;
|
|
227
|
+
/**
|
|
228
|
+
* Handles the pointer down event for starting drag operations.
|
|
229
|
+
*
|
|
230
|
+
* @private
|
|
231
|
+
* @param e - The pointer event
|
|
232
|
+
*/
|
|
233
|
+
_onPointerDown(e: any): void;
|
|
234
|
+
/**
|
|
235
|
+
* Converts the input-coordinates from the standard Y-axis up to what is set in Object3D.DEFAULT_UP.
|
|
236
|
+
*
|
|
237
|
+
* @private
|
|
238
|
+
* @param target - The target Vector3 to be converted
|
|
239
|
+
* @param isSpherical - Whether or not the coordinates are for a sphere
|
|
240
|
+
* @returns The converted coordinates
|
|
241
|
+
*/
|
|
242
|
+
coordinateConversion(target: any, isSpherical?: boolean): any;
|
|
243
|
+
/**
|
|
244
|
+
* Handles pointer move events for hover effects and drag operations.
|
|
245
|
+
*
|
|
246
|
+
* @private
|
|
247
|
+
* @param e - The pointer event
|
|
248
|
+
*/
|
|
249
|
+
_onPointerMove(e: any): void;
|
|
250
|
+
/**
|
|
251
|
+
* Handles pointer leave events to reset hover states.
|
|
252
|
+
*
|
|
253
|
+
* @private
|
|
254
|
+
*/
|
|
255
|
+
_onPointerLeave(): void;
|
|
256
|
+
/**
|
|
257
|
+
* Handles click events for axis selection.
|
|
258
|
+
*
|
|
259
|
+
* @private
|
|
260
|
+
* @param e - The pointer event
|
|
261
|
+
*/
|
|
262
|
+
_handleClick(e: any): void;
|
|
263
|
+
/**
|
|
264
|
+
* Handles hover effects for interactive elements.
|
|
265
|
+
*
|
|
266
|
+
* @private
|
|
267
|
+
* @param e - The pointer event
|
|
268
|
+
*/
|
|
269
|
+
_handleHover(e: any): void;
|
|
270
|
+
}
|
|
271
|
+
export { T3DEzViewportGizmo };
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var r=require("./HDRLoader.cjs.js");class e extends r.HDRLoader{constructor(r){super(r)}}exports.RGBELoader=e;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{HDRLoader as r}from"./HDRLoader.esm.js";class s extends r{constructor(r){super(r)}}export{s as RGBELoader};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function t(t,e,n,o){const i=e.x(),s=e.y(),r=e.z(),a=e.w(),c=i+i,d=s+s,u=r+r,l=i*c,w=i*d,f=i*u,y=s*d,g=s*u,h=r*u,b=a*c,m=a*d,p=a*u;n[o+0]=1-(y+h),n[o+1]=w+p,n[o+2]=f-m,n[o+3]=0,n[o+4]=w-p,n[o+5]=1-(l+h),n[o+6]=g+b,n[o+7]=0,n[o+8]=f+m,n[o+9]=g-b,n[o+10]=1-(l+y),n[o+11]=0,n[o+12]=t.x(),n[o+13]=t.y(),n[o+14]=t.z(),n[o+15]=1}exports.AmmoPhysics=async function(){if("Ammo"in window==!1)return;const e=await Ammo(),n=new e.btDefaultCollisionConfiguration,o=new e.btCollisionDispatcher(n),i=new e.btDbvtBroadphase,s=new e.btSequentialImpulseConstraintSolver,r=new e.btDiscreteDynamicsWorld(o,i,s,n);r.setGravity(new e.btVector3(0,-9.8,0));const a=new e.btTransform,c=[],d=new WeakMap;function u(t,n=0,o=0){const i=function(t){const n=t.parameters;if("BoxGeometry"===t.type){const t=void 0!==n.width?n.width/2:.5,o=void 0!==n.height?n.height/2:.5,i=void 0!==n.depth?n.depth/2:.5,s=new e.btBoxShape(new e.btVector3(t,o,i));return s.setMargin(.05),s}if("SphereGeometry"===t.type||"IcosahedronGeometry"===t.type){const t=void 0!==n.radius?n.radius:1,o=new e.btSphereShape(t);return o.setMargin(.05),o}return null}(t.geometry);null!==i&&(t.isInstancedMesh?function(t,n,o,i){const s=t.instanceMatrix.array,a=[];for(let c=0;c<t.count;c++){const t=16*c,d=new e.btTransform;d.setFromOpenGLMatrix(s.slice(t,t+16));const u=new e.btDefaultMotionState(d),l=new e.btVector3(0,0,0);n.calculateLocalInertia(o,l);const w=new e.btRigidBodyConstructionInfo(o,u,n,l);w.set_m_restitution(i);const f=new e.btRigidBody(w);r.addRigidBody(f),a.push(f)}o>0&&(c.push(t),d.set(t,a))}(t,i,n,o):t.isMesh&&function(t,n,o,i){const s=t.position,a=t.quaternion,u=new e.btTransform;u.setIdentity(),u.setOrigin(new e.btVector3(s.x,s.y,s.z)),u.setRotation(new e.btQuaternion(a.x,a.y,a.z,a.w));const l=new e.btDefaultMotionState(u),w=new e.btVector3(0,0,0);n.calculateLocalInertia(o,w);const f=new e.btRigidBodyConstructionInfo(o,l,n,w);f.set_m_restitution(i);const y=new e.btRigidBody(f);r.addRigidBody(y),o>0&&(c.push(t),d.set(t,y))}(t,i,n,o))}let l=0;return setInterval(function(){const e=performance.now();if(l>0){const n=(e-l)/1e3;r.stepSimulation(n,10);for(let e=0,n=c.length;e<n;e++){const n=c[e];if(n.isInstancedMesh){const e=n.instanceMatrix.array,o=d.get(n);for(let n=0;n<o.length;n++){o[n].getMotionState().getWorldTransform(a);t(a.getOrigin(),a.getRotation(),e,16*n)}n.instanceMatrix.needsUpdate=!0,n.computeBoundingSphere()}else if(n.isMesh){d.get(n).getMotionState().getWorldTransform(a);const t=a.getOrigin(),e=a.getRotation();n.position.set(t.x(),t.y(),t.z()),n.quaternion.set(e.x(),e.y(),e.z(),e.w())}}}l=e},1e3/60),{addScene:function(t){t.traverse(function(t){if(t.isMesh){const e=t.userData.physics;e&&u(t,e.mass,e.restitution)}})},addMesh:u,setMeshPosition:function(t,n,o=0){if(t.isInstancedMesh){const i=d.get(t)[o];i.setAngularVelocity(new e.btVector3(0,0,0)),i.setLinearVelocity(new e.btVector3(0,0,0)),a.setIdentity(),a.setOrigin(new e.btVector3(n.x,n.y,n.z)),i.setWorldTransform(a)}else if(t.isMesh){const o=d.get(t);o.setAngularVelocity(new e.btVector3(0,0,0)),o.setLinearVelocity(new e.btVector3(0,0,0)),a.setIdentity(),a.setOrigin(new e.btVector3(n.x,n.y,n.z)),o.setWorldTransform(a)}}}};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
async function t(){if("Ammo"in window==!1)return;const t=await Ammo(),n=new t.btDefaultCollisionConfiguration,o=new t.btCollisionDispatcher(n),i=new t.btDbvtBroadphase,s=new t.btSequentialImpulseConstraintSolver,r=new t.btDiscreteDynamicsWorld(o,i,s,n);r.setGravity(new t.btVector3(0,-9.8,0));const a=new t.btTransform;const c=[],d=new WeakMap;function u(e,n=0,o=0){const i=function(e){const n=e.parameters;if("BoxGeometry"===e.type){const e=void 0!==n.width?n.width/2:.5,o=void 0!==n.height?n.height/2:.5,i=void 0!==n.depth?n.depth/2:.5,s=new t.btBoxShape(new t.btVector3(e,o,i));return s.setMargin(.05),s}if("SphereGeometry"===e.type||"IcosahedronGeometry"===e.type){const e=void 0!==n.radius?n.radius:1,o=new t.btSphereShape(e);return o.setMargin(.05),o}return null}(e.geometry);null!==i&&(e.isInstancedMesh?function(e,n,o,i){const s=e.instanceMatrix.array,a=[];for(let c=0;c<e.count;c++){const e=16*c,d=new t.btTransform;d.setFromOpenGLMatrix(s.slice(e,e+16));const u=new t.btDefaultMotionState(d),l=new t.btVector3(0,0,0);n.calculateLocalInertia(o,l);const w=new t.btRigidBodyConstructionInfo(o,u,n,l);w.set_m_restitution(i);const f=new t.btRigidBody(w);r.addRigidBody(f),a.push(f)}o>0&&(c.push(e),d.set(e,a))}(e,i,n,o):e.isMesh&&function(e,n,o,i){const s=e.position,a=e.quaternion,u=new t.btTransform;u.setIdentity(),u.setOrigin(new t.btVector3(s.x,s.y,s.z)),u.setRotation(new t.btQuaternion(a.x,a.y,a.z,a.w));const l=new t.btDefaultMotionState(u),w=new t.btVector3(0,0,0);n.calculateLocalInertia(o,w);const f=new t.btRigidBodyConstructionInfo(o,l,n,w);f.set_m_restitution(i);const g=new t.btRigidBody(f);r.addRigidBody(g),o>0&&(c.push(e),d.set(e,g))}(e,i,n,o))}let l=0;return setInterval(function(){const t=performance.now();if(l>0){const n=(t-l)/1e3;r.stepSimulation(n,10);for(let t=0,n=c.length;t<n;t++){const n=c[t];if(n.isInstancedMesh){const t=n.instanceMatrix.array,o=d.get(n);for(let n=0;n<o.length;n++){o[n].getMotionState().getWorldTransform(a);e(a.getOrigin(),a.getRotation(),t,16*n)}n.instanceMatrix.needsUpdate=!0,n.computeBoundingSphere()}else if(n.isMesh){d.get(n).getMotionState().getWorldTransform(a);const t=a.getOrigin(),e=a.getRotation();n.position.set(t.x(),t.y(),t.z()),n.quaternion.set(e.x(),e.y(),e.z(),e.w())}}}l=t},1e3/60),{addScene:function(t){t.traverse(function(t){if(t.isMesh){const e=t.userData.physics;e&&u(t,e.mass,e.restitution)}})},addMesh:u,setMeshPosition:function(e,n,o=0){if(e.isInstancedMesh){const i=d.get(e)[o];i.setAngularVelocity(new t.btVector3(0,0,0)),i.setLinearVelocity(new t.btVector3(0,0,0)),a.setIdentity(),a.setOrigin(new t.btVector3(n.x,n.y,n.z)),i.setWorldTransform(a)}else if(e.isMesh){const o=d.get(e);o.setAngularVelocity(new t.btVector3(0,0,0)),o.setLinearVelocity(new t.btVector3(0,0,0)),a.setIdentity(),a.setOrigin(new t.btVector3(n.x,n.y,n.z)),o.setWorldTransform(a)}}}}function e(t,e,n,o){const i=e.x(),s=e.y(),r=e.z(),a=e.w(),c=i+i,d=s+s,u=r+r,l=i*c,w=i*d,f=i*u,g=s*d,y=s*u,h=r*u,b=a*c,p=a*d,m=a*u;n[o+0]=1-(g+h),n[o+1]=w+m,n[o+2]=f-p,n[o+3]=0,n[o+4]=w-m,n[o+5]=1-(l+h),n[o+6]=y+b,n[o+7]=0,n[o+8]=f+p,n[o+9]=y-b,n[o+10]=1-(l+g),n[o+11]=0,n[o+12]=t.x(),n[o+13]=t.y(),n[o+14]=t.z(),n[o+15]=1}export{t as AmmoPhysics};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "three/examples/jsm/physics/AmmoPhysics.js";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|