three-stdlib 2.14.1 → 2.15.0
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/csm/CSM.cjs.js +1 -1
- package/csm/CSM.js +8 -8
- package/csm/CSMFrustum.cjs.js +1 -0
- package/csm/CSMFrustum.d.ts +19 -0
- package/csm/{Frustum.js → CSMFrustum.js} +8 -7
- package/csm/CSMShader.cjs.js +1 -0
- package/csm/CSMShader.d.ts +4 -0
- package/csm/{Shader.js → CSMShader.js} +52 -36
- package/curves/CurveExtras.d.ts +52 -54
- package/geometries/ParametricGeometries.cjs.js +1 -1
- package/geometries/ParametricGeometries.js +91 -99
- package/geometries/ParametricGeometry.cjs.js +1 -0
- package/geometries/ParametricGeometry.d.ts +18 -0
- package/geometries/ParametricGeometry.js +87 -0
- package/index.cjs.js +1 -1
- package/index.d.ts +3 -77
- package/index.js +4 -1
- package/interactive/InteractiveGroup.cjs.js +1 -0
- package/interactive/InteractiveGroup.d.ts +5 -0
- package/interactive/InteractiveGroup.js +87 -0
- package/lines/Line2.cjs.js +1 -1
- package/lines/Line2.d.ts +7 -5
- package/lines/Line2.js +2 -5
- package/lines/LineGeometry.cjs.js +1 -1
- package/lines/LineGeometry.d.ts +6 -8
- package/lines/LineGeometry.js +28 -39
- package/lines/LineMaterial.cjs.js +1 -1
- package/lines/LineMaterial.d.ts +23 -19
- package/lines/LineMaterial.js +263 -107
- package/lines/LineSegments2.cjs.js +1 -1
- package/lines/LineSegments2.d.ts +12 -20
- package/lines/LineSegments2.js +272 -125
- package/lines/LineSegmentsGeometry.cjs.js +1 -1
- package/lines/LineSegmentsGeometry.d.ts +18 -16
- package/lines/LineSegmentsGeometry.js +30 -40
- package/lines/Wireframe.cjs.js +1 -1
- package/lines/Wireframe.js +39 -39
- package/lines/WireframeGeometry2.cjs.js +1 -1
- package/lines/WireframeGeometry2.js +8 -9
- package/loaders/GLTFLoader.d.ts +2 -9
- package/loaders/LUT3dlLoader.d.ts +2 -2
- package/loaders/LUTCubeLoader.d.ts +2 -2
- package/loaders/RGBELoader.cjs.js +1 -1
- package/loaders/RGBELoader.js +1 -9
- package/loaders/VOXLoader.d.ts +2 -2
- package/objects/Reflector.d.ts +1 -0
- package/objects/ReflectorForSSRPass.d.ts +4 -4
- package/objects/Refractor.d.ts +1 -0
- package/objects/Water2.d.ts +1 -1
- package/package.json +2 -1
- package/postprocessing/LUTPass.d.ts +3 -3
- package/postprocessing/SSAARenderPass.d.ts +1 -1
- package/postprocessing/SSRPass.d.ts +3 -3
- package/shaders/BokehShader2.d.ts +27 -72
- package/shaders/BokehShader2.js +0 -1
- package/shaders/index.cjs.js +1 -1
- package/shaders/index.d.ts +2 -1
- package/shaders/index.js +1 -1
- package/csm/Frustum.cjs.js +0 -1
- package/csm/Shader.cjs.js +0 -1
- package/loaders/VRMLoader.d.ts +0 -19
- package/nodes/Nodes.d.ts +0 -106
- package/nodes/accessors/CameraNode.d.ts +0 -29
- package/nodes/accessors/NormalNode.d.ts +0 -13
- package/nodes/accessors/PositionNode.d.ts +0 -15
- package/nodes/accessors/ReflectNode.d.ts +0 -12
- package/nodes/accessors/UVNode.d.ts +0 -10
- package/nodes/core/AttributeNode.d.ts +0 -13
- package/nodes/core/ConstNode.d.ts +0 -22
- package/nodes/core/ExpressionNode.d.ts +0 -5
- package/nodes/core/FunctionCallNode.d.ts +0 -17
- package/nodes/core/FunctionNode.d.ts +0 -28
- package/nodes/core/InputNode.d.ts +0 -12
- package/nodes/core/Node.d.ts +0 -34
- package/nodes/core/NodeBuilder.d.ts +0 -149
- package/nodes/core/NodeFrame.d.ts +0 -17
- package/nodes/core/NodeUniform.d.ts +0 -17
- package/nodes/core/NodeUtils.d.ts +0 -7
- package/nodes/core/TempNode.d.ts +0 -23
- package/nodes/core/VarNode.d.ts +0 -12
- package/nodes/materials/MeshStandardNodeMaterial.d.ts +0 -21
- package/nodes/materials/NodeMaterial.d.ts +0 -28
- package/nodes/math/CondNode.d.ts +0 -26
- package/nodes/math/MathNode.d.ts +0 -57
- package/nodes/math/OperatorNode.d.ts +0 -17
- package/nodes/procedural/CheckerNode.d.ts +0 -17
- package/nodes/utils/JoinNode.d.ts +0 -15
- package/nodes/utils/TimerNode.d.ts +0 -19
- package/objects/ReflectorRTT.d.ts +0 -6
package/index.d.ts
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
export * from './offscreen/scene';
|
2
|
-
export * from './offscreen/offscreen';
|
3
|
-
export * from './offscreen/jank';
|
4
1
|
export * from './misc/MD2CharacterComplex';
|
5
2
|
export * from './misc/ConvexObjectBreaker';
|
6
3
|
export * from './misc/MorphBlendMesh';
|
@@ -13,73 +10,14 @@ export * from './misc/MD2Character';
|
|
13
10
|
export * from './misc/VolumeSlice';
|
14
11
|
export * from './misc/TubePainter';
|
15
12
|
export * from './misc/Volume';
|
16
|
-
export * from './misc/ProgressiveLightmap';
|
17
13
|
export * from './renderers/CSS2DRenderer';
|
18
|
-
export * from './renderers/nodes/core/constants';
|
19
|
-
export * from './renderers/nodes/core/NodeBuilder';
|
20
|
-
export * from './renderers/nodes/core/InputNode';
|
21
|
-
export * from './renderers/nodes/core/NodeUniform';
|
22
|
-
export * from './renderers/nodes/core/NodeVary';
|
23
|
-
export * from './renderers/nodes/core/NodeFrame';
|
24
|
-
export * from './renderers/nodes/core/Node';
|
25
|
-
export * from './renderers/nodes/core/NodeSlot';
|
26
|
-
export * from './renderers/nodes/core/NodeAttribute';
|
27
|
-
export * from './renderers/nodes/core/VaryNode';
|
28
|
-
export * from './renderers/nodes/core/AttributeNode';
|
29
|
-
export * from './renderers/nodes/accessors/CameraNode';
|
30
|
-
export * from './renderers/nodes/accessors/UVNode';
|
31
|
-
export * from './renderers/nodes/accessors/ModelNode';
|
32
|
-
export * from './renderers/nodes/accessors/NormalNode';
|
33
|
-
export * from './renderers/nodes/accessors/PositionNode';
|
34
|
-
export * from './renderers/nodes/accessors/ModelViewProjectionNode';
|
35
|
-
export * from './renderers/nodes/utils/SwitchNode';
|
36
|
-
export * from './renderers/nodes/utils/TimerNode';
|
37
|
-
export * from './renderers/nodes/math/OperatorNode';
|
38
|
-
export * from './renderers/nodes/math/MathNode';
|
39
|
-
export * from './renderers/nodes/inputs/ColorNode';
|
40
|
-
export * from './renderers/nodes/inputs/Vector3Node';
|
41
|
-
export * from './renderers/nodes/inputs/Matrix4Node';
|
42
|
-
export * from './renderers/nodes/inputs/TextureNode';
|
43
|
-
export * from './renderers/nodes/inputs/FloatNode';
|
44
|
-
export * from './renderers/nodes/inputs/Vector2Node';
|
45
|
-
export * from './renderers/nodes/inputs/Vector4Node';
|
46
|
-
export * from './renderers/nodes/inputs/Matrix3Node';
|
47
|
-
export * from './renderers/webgpu/constants';
|
48
|
-
export * from './renderers/webgpu/WebGPUTextures';
|
49
|
-
export * from './renderers/webgpu/WebGPUInfo';
|
50
|
-
export * from './renderers/webgpu/WebGPURenderLists';
|
51
|
-
export * from './renderers/webgpu/WebGPUTextureRenderer';
|
52
|
-
export * from './renderers/webgpu/WebGPURenderPipelines';
|
53
|
-
export * from './renderers/webgpu/WebGPUGeometries';
|
54
|
-
export * from './renderers/webgpu/nodes/WebGPUNodeBuilder';
|
55
|
-
export * from './renderers/webgpu/nodes/WebGPUNodeUniform';
|
56
|
-
export * from './renderers/webgpu/nodes/WebGPUNodeUniformsGroup';
|
57
|
-
export * from './renderers/webgpu/nodes/ShaderLib';
|
58
|
-
export * from './renderers/webgpu/nodes/WebGPUNodes';
|
59
|
-
export * from './renderers/webgpu/WebGPUBindings';
|
60
|
-
export * from './renderers/webgpu/WebGPUSampledTexture';
|
61
|
-
export * from './renderers/webgpu/WebGPU';
|
62
|
-
export * from './renderers/webgpu/WebGPUUniformsGroup';
|
63
|
-
export * from './renderers/webgpu/WebGPURenderer';
|
64
|
-
export * from './renderers/webgpu/WebGPUComputePipelines';
|
65
|
-
export * from './renderers/webgpu/WebGPUUniform';
|
66
|
-
export * from './renderers/webgpu/WebGPUObjects';
|
67
|
-
export * from './renderers/webgpu/WebGPUSampler';
|
68
|
-
export * from './renderers/webgpu/WebGPUBackground';
|
69
|
-
export * from './renderers/webgpu/WebGPUBinding';
|
70
|
-
export * from './renderers/webgpu/WebGPUProperties';
|
71
|
-
export * from './renderers/webgpu/WebGPUAttributes';
|
72
|
-
export * from './renderers/webgpu/WebGPUStorageBuffer';
|
73
|
-
export * from './renderers/webgpu/WebGPUTextureUtils';
|
74
14
|
export * from './renderers/CSS3DRenderer';
|
75
15
|
export * from './renderers/Projector';
|
76
16
|
export * from './renderers/SVGRenderer';
|
77
|
-
export * from './textures/FlakesTexture';
|
78
17
|
export * from './modifiers/CurveModifier';
|
79
18
|
export * from './modifiers/SimplifyModifier';
|
80
19
|
export * from './modifiers/EdgeSplitModifier';
|
81
20
|
export * from './modifiers/TessellateModifier';
|
82
|
-
export * from './nodes/Nodes';
|
83
21
|
export * from './exporters/GLTFExporter';
|
84
22
|
export * from './exporters/USDZExporter';
|
85
23
|
export * from './exporters/PLYExporter';
|
@@ -100,7 +38,6 @@ export * from './objects/Lensflare';
|
|
100
38
|
export * from './objects/Water';
|
101
39
|
export * from './objects/MarchingCubes';
|
102
40
|
export * from './objects/LightningStorm';
|
103
|
-
export * from './objects/ReflectorRTT';
|
104
41
|
export * from './objects/ReflectorForSSRPass';
|
105
42
|
export * from './objects/Sky';
|
106
43
|
export * from './objects/Water2';
|
@@ -108,7 +45,6 @@ export * from './objects/GroundProjectedEnv';
|
|
108
45
|
export * from './utils/SceneUtils';
|
109
46
|
export * from './utils/UVsDebug';
|
110
47
|
export * from './utils/GeometryUtils';
|
111
|
-
export * from './utils/RoughnessMipmapper';
|
112
48
|
export * from './utils/SkeletonUtils';
|
113
49
|
export * from './utils/ShadowMapViewer';
|
114
50
|
export * from './utils/BufferGeometryUtils';
|
@@ -158,7 +94,6 @@ export * from './postprocessing/TAARenderPass';
|
|
158
94
|
export * from './postprocessing/ShaderPass';
|
159
95
|
export * from './postprocessing/SSAARenderPass';
|
160
96
|
export * from './postprocessing/RenderPass';
|
161
|
-
export * from './postprocessing/RenderPixelatedPass';
|
162
97
|
export * from './postprocessing/BloomPass';
|
163
98
|
export * from './webxr/ARButton';
|
164
99
|
export * from './webxr/OculusHandModel';
|
@@ -171,6 +106,7 @@ export * from './webxr/XRHandMeshModel';
|
|
171
106
|
export * from './webxr/XRHandModelFactory';
|
172
107
|
export * from './webxr/XRHandPrimitiveModel';
|
173
108
|
export * from './geometries/ParametricGeometries';
|
109
|
+
export * from './geometries/ParametricGeometry';
|
174
110
|
export * from './geometries/ConvexGeometry';
|
175
111
|
export * from './geometries/LightningStrike';
|
176
112
|
export * from './geometries/RoundedBoxGeometry';
|
@@ -179,10 +115,9 @@ export * from './geometries/DecalGeometry';
|
|
179
115
|
export * from './geometries/TeapotGeometry';
|
180
116
|
export * from './geometries/TextGeometry';
|
181
117
|
export * from './csm/CSM';
|
182
|
-
export * from './csm/
|
118
|
+
export * from './csm/CSMFrustum';
|
183
119
|
export * from './csm/CSMHelper';
|
184
|
-
export * from './csm/
|
185
|
-
export * from './shaders';
|
120
|
+
export * from './csm/CSMShader';
|
186
121
|
export * from './interactive/SelectionHelper';
|
187
122
|
export * from './interactive/SelectionBox';
|
188
123
|
export * from './physics/AmmoPhysics';
|
@@ -199,16 +134,13 @@ export * from './loaders/LUTCubeLoader';
|
|
199
134
|
export * from './loaders/NRRDLoader';
|
200
135
|
export * from './loaders/STLLoader';
|
201
136
|
export * from './loaders/MTLLoader';
|
202
|
-
export * from './loaders/XLoader';
|
203
137
|
export * from './loaders/BVHLoader';
|
204
138
|
export * from './loaders/KMZLoader';
|
205
|
-
export * from './loaders/VRMLoader';
|
206
139
|
export * from './loaders/VRMLLoader';
|
207
140
|
export * from './loaders/KTX2Loader';
|
208
141
|
export * from './loaders/LottieLoader';
|
209
142
|
export * from './loaders/TTFLoader';
|
210
143
|
export * from './loaders/RGBELoader';
|
211
|
-
export * from './loaders/AssimpLoader';
|
212
144
|
export * from './loaders/ColladaLoader';
|
213
145
|
export * from './loaders/MDDLoader';
|
214
146
|
export * from './loaders/EXRLoader';
|
@@ -223,9 +155,6 @@ export * from './loaders/BasisTextureLoader';
|
|
223
155
|
export * from './loaders/TDSLoader';
|
224
156
|
export * from './loaders/LDrawLoader';
|
225
157
|
export * from './loaders/GLTFLoader';
|
226
|
-
export * from './loaders/lwo/LWO3Parser';
|
227
|
-
export * from './loaders/lwo/LWO2Parser';
|
228
|
-
export * from './loaders/lwo/IFFParser';
|
229
158
|
export * from './loaders/SVGLoader';
|
230
159
|
export * from './loaders/3DMLoader';
|
231
160
|
export * from './loaders/OBJLoader';
|
@@ -240,7 +169,6 @@ export * from './loaders/PDBLoader';
|
|
240
169
|
export * from './loaders/PRWMLoader';
|
241
170
|
export * from './loaders/RGBMLoader';
|
242
171
|
export * from './loaders/VOXLoader';
|
243
|
-
export * from './loaders/NodeMaterialLoader';
|
244
172
|
export * from './loaders/PCDLoader';
|
245
173
|
export * from './loaders/LWOLoader';
|
246
174
|
export * from './loaders/PLYLoader';
|
@@ -263,5 +191,3 @@ export * from './curves/NURBSCurve';
|
|
263
191
|
export * from './curves/NURBSSurface';
|
264
192
|
export * from './curves/CurveExtras';
|
265
193
|
export * from './deprecated/Geometry';
|
266
|
-
export * from './libs/MeshoptDecoder';
|
267
|
-
export * from './libs/MotionControllers';
|
package/index.js
CHANGED
@@ -117,6 +117,7 @@ export { XRHandMeshModel } from './webxr/XRHandMeshModel.js';
|
|
117
117
|
export { XRHandModelFactory } from './webxr/XRHandModelFactory.js';
|
118
118
|
export { XRHandPrimitiveModel } from './webxr/XRHandPrimitiveModel.js';
|
119
119
|
export { ParametricGeometries } from './geometries/ParametricGeometries.js';
|
120
|
+
export { ParametricGeometry } from './geometries/ParametricGeometry.js';
|
120
121
|
export { ConvexGeometry } from './geometries/ConvexGeometry.js';
|
121
122
|
export { LightningStrike } from './geometries/LightningStrike.js';
|
122
123
|
export { RoundedBoxGeometry } from './geometries/RoundedBoxGeometry.js';
|
@@ -125,7 +126,9 @@ export { DecalGeometry, DecalVertex } from './geometries/DecalGeometry.js';
|
|
125
126
|
export { TeapotGeometry } from './geometries/TeapotGeometry.js';
|
126
127
|
export { TextGeometry as TextBufferGeometry, TextGeometry } from './geometries/TextGeometry.js';
|
127
128
|
export { CSM } from './csm/CSM.js';
|
129
|
+
export { CSMFrustum } from './csm/CSMFrustum.js';
|
128
130
|
export { CSMHelper } from './csm/CSMHelper.js';
|
131
|
+
export { CSMShader } from './csm/CSMShader.js';
|
129
132
|
export { SelectionHelper } from './interactive/SelectionHelper.js';
|
130
133
|
export { SelectionBox } from './interactive/SelectionBox.js';
|
131
134
|
export { AmmoPhysics } from './physics/AmmoPhysics.js';
|
@@ -276,13 +279,13 @@ export { default as NodeObjectLoader } from './nodes/loaders/NodeObjectLoader.js
|
|
276
279
|
export { default as NodeMaterialLoader } from './nodes/loaders/NodeMaterialLoader.js';
|
277
280
|
export { BRDF_GGX, BRDF_Lambert, D_GGX, F_Schlick, PhysicalLightingModel, RE_Direct_Physical, V_GGX_SmithCorrelated, getDistanceAttenuation } from './nodes/functions/BSDFs.js';
|
278
281
|
export { EPSILON, INFINITY, ShaderNode, abs, acos, add, addTo, alphaTest, and, asin, assign, atan, attribute, bitAnd, bitOr, bitXor, bmat3, bmat4, bool, buffer, bvec2, bvec3, bvec4, cameraPosition, ceil, clamp, color, cond, cos, cross, dFdx, dFdy, degrees, diffuseColor, distance, div, dot, element, equal, exp, exp2, faceforward, float, floor, fract, greaterThan, greaterThanEqual, imat3, imat4, int, inversesqrt, invert, ivec2, ivec3, ivec4, join, label, length, lessThan, lessThanEqual, log, log2, mat3, mat4, max, metalness, min, mix, mod, mul, negate, nodeObject, normalGeometry, normalLocal, normalView, normalWorld, normalize, or, positionLocal, positionView, positionViewDirection, positionWorld, pow, pow2, pow3, pow4, radians, reflect, refract, remainder, roughness, round, sampler, saturate, shiftLeft, shiftRight, sign, sin, smoothstep, specularColor, sqrt, step, sub, tan, temp, texture, transformDirection, transformedNormalView, uint, umat3, umat4, uniform, uv, uvec2, uvec3, uvec4, vec2, vec3, vec4, viewMatrix, xor } from './nodes/ShaderNode.js';
|
282
|
+
export { BokehShader2 } from './shaders/BokehShader2.js';
|
279
283
|
export { ACESFilmicToneMappingShader } from './shaders/ACESFilmicToneMappingShader.js';
|
280
284
|
export { AfterimageShader } from './shaders/AfterimageShader.js';
|
281
285
|
export { BasicShader } from './shaders/BasicShader.js';
|
282
286
|
export { BleachBypassShader } from './shaders/BleachBypassShader.js';
|
283
287
|
export { BlendShader } from './shaders/BlendShader.js';
|
284
288
|
export { BokehShader } from './shaders/BokehShader.js';
|
285
|
-
export { BokehDepthShader, BokehShader2 } from './shaders/BokehShader2.js';
|
286
289
|
export { BrightnessContrastShader } from './shaders/BrightnessContrastShader.js';
|
287
290
|
export { ColorCorrectionShader } from './shaders/ColorCorrectionShader.js';
|
288
291
|
export { ColorifyShader } from './shaders/ColorifyShader.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three");const t=new e.Vector2,n={type:"",data:t};class s extends e.Group{constructor(s,r){super();const o=this,i=new e.Raycaster,d=new e.Matrix4,c=s.domElement;function a(e){e.stopPropagation(),t.x=e.clientX/c.clientWidth*2-1,t.y=-e.clientY/c.clientHeight*2+1,i.setFromCamera(t,r);const s=i.intersectObjects(o.children,!1);if(s.length>0){const t=s[0],r=t.object,o=t.uv;n.type=e.type,n.data.set(o.x,1-o.y),r.dispatchEvent(n)}}c.addEventListener("pointerdown",a),c.addEventListener("pointerup",a),c.addEventListener("pointermove",a),c.addEventListener("mousedown",a),c.addEventListener("mouseup",a),c.addEventListener("mousemove",a),c.addEventListener("click",a);const l={move:"mousemove",select:"click",selectstart:"mousedown",selectend:"mouseup"};function v(e){const t=e.target;d.identity().extractRotation(t.matrixWorld),i.ray.origin.setFromMatrixPosition(t.matrixWorld),i.ray.direction.set(0,0,-1).applyMatrix4(d);const s=i.intersectObjects(o.children,!1);if(s.length>0){const t=s[0],r=t.object,o=t.uv;n.type=l[e.type],n.data.set(o.x,1-o.y),r.dispatchEvent(n)}}const p=s.xr.getController(0);p.addEventListener("move",v),p.addEventListener("select",v),p.addEventListener("selectstart",v),p.addEventListener("selectend",v);const u=s.xr.getController(1);u.addEventListener("move",v),u.addEventListener("select",v),u.addEventListener("selectstart",v),u.addEventListener("selectend",v)}}exports.InteractiveGroup=s;
|
@@ -0,0 +1,87 @@
|
|
1
|
+
import { Vector2, Group, Raycaster, Matrix4 } from 'three';
|
2
|
+
|
3
|
+
const _pointer = new Vector2();
|
4
|
+
|
5
|
+
const _event = {
|
6
|
+
type: '',
|
7
|
+
data: _pointer
|
8
|
+
};
|
9
|
+
|
10
|
+
class InteractiveGroup extends Group {
|
11
|
+
constructor(renderer, camera) {
|
12
|
+
super();
|
13
|
+
const scope = this;
|
14
|
+
const raycaster = new Raycaster();
|
15
|
+
const tempMatrix = new Matrix4(); // Pointer Events
|
16
|
+
|
17
|
+
const element = renderer.domElement;
|
18
|
+
|
19
|
+
function onPointerEvent(event) {
|
20
|
+
event.stopPropagation();
|
21
|
+
_pointer.x = event.clientX / element.clientWidth * 2 - 1;
|
22
|
+
_pointer.y = -(event.clientY / element.clientHeight) * 2 + 1;
|
23
|
+
raycaster.setFromCamera(_pointer, camera);
|
24
|
+
const intersects = raycaster.intersectObjects(scope.children, false);
|
25
|
+
|
26
|
+
if (intersects.length > 0) {
|
27
|
+
const intersection = intersects[0];
|
28
|
+
const object = intersection.object;
|
29
|
+
const uv = intersection.uv;
|
30
|
+
_event.type = event.type;
|
31
|
+
|
32
|
+
_event.data.set(uv.x, 1 - uv.y);
|
33
|
+
|
34
|
+
object.dispatchEvent(_event);
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
element.addEventListener('pointerdown', onPointerEvent);
|
39
|
+
element.addEventListener('pointerup', onPointerEvent);
|
40
|
+
element.addEventListener('pointermove', onPointerEvent);
|
41
|
+
element.addEventListener('mousedown', onPointerEvent);
|
42
|
+
element.addEventListener('mouseup', onPointerEvent);
|
43
|
+
element.addEventListener('mousemove', onPointerEvent);
|
44
|
+
element.addEventListener('click', onPointerEvent); // WebXR Controller Events
|
45
|
+
// TODO: Dispatch pointerevents too
|
46
|
+
|
47
|
+
const events = {
|
48
|
+
move: 'mousemove',
|
49
|
+
select: 'click',
|
50
|
+
selectstart: 'mousedown',
|
51
|
+
selectend: 'mouseup'
|
52
|
+
};
|
53
|
+
|
54
|
+
function onXRControllerEvent(event) {
|
55
|
+
const controller = event.target;
|
56
|
+
tempMatrix.identity().extractRotation(controller.matrixWorld);
|
57
|
+
raycaster.ray.origin.setFromMatrixPosition(controller.matrixWorld);
|
58
|
+
raycaster.ray.direction.set(0, 0, -1).applyMatrix4(tempMatrix);
|
59
|
+
const intersections = raycaster.intersectObjects(scope.children, false);
|
60
|
+
|
61
|
+
if (intersections.length > 0) {
|
62
|
+
const intersection = intersections[0];
|
63
|
+
const object = intersection.object;
|
64
|
+
const uv = intersection.uv;
|
65
|
+
_event.type = events[event.type];
|
66
|
+
|
67
|
+
_event.data.set(uv.x, 1 - uv.y);
|
68
|
+
|
69
|
+
object.dispatchEvent(_event);
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
const controller1 = renderer.xr.getController(0);
|
74
|
+
controller1.addEventListener('move', onXRControllerEvent);
|
75
|
+
controller1.addEventListener('select', onXRControllerEvent);
|
76
|
+
controller1.addEventListener('selectstart', onXRControllerEvent);
|
77
|
+
controller1.addEventListener('selectend', onXRControllerEvent);
|
78
|
+
const controller2 = renderer.xr.getController(1);
|
79
|
+
controller2.addEventListener('move', onXRControllerEvent);
|
80
|
+
controller2.addEventListener('select', onXRControllerEvent);
|
81
|
+
controller2.addEventListener('selectstart', onXRControllerEvent);
|
82
|
+
controller2.addEventListener('selectend', onXRControllerEvent);
|
83
|
+
}
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
export { InteractiveGroup };
|
package/lines/Line2.cjs.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./LineSegments2.cjs.js"),r=require("./LineGeometry.cjs.js"),s=require("./LineMaterial.cjs.js");require("three"),require("./LineSegmentsGeometry.cjs.js");class i extends e.LineSegments2{constructor(e=new r.LineGeometry,i=new s.LineMaterial({color:16777215*Math.random()})){super(e,i),this.isLine2=!0,this.type="Line2"}}exports.Line2=i;
|
package/lines/Line2.d.ts
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
-
import { LineSegments2 } from './LineSegments2';
|
2
1
|
import { LineGeometry } from './LineGeometry';
|
2
|
+
import { LineSegments2 } from './LineSegments2';
|
3
3
|
import { LineMaterial } from './LineMaterial';
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
|
5
|
+
export class Line2 extends LineSegments2 {
|
6
|
+
geometry: LineGeometry;
|
7
|
+
material: LineMaterial;
|
8
|
+
|
7
9
|
constructor(geometry?: LineGeometry, material?: LineMaterial);
|
10
|
+
readonly isLine2: true;
|
8
11
|
}
|
9
|
-
export { Line2 };
|
package/lines/Line2.js
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
2
1
|
import { LineSegments2 } from './LineSegments2.js';
|
3
2
|
import { LineGeometry } from './LineGeometry.js';
|
4
3
|
import { LineMaterial } from './LineMaterial.js';
|
@@ -8,10 +7,8 @@ class Line2 extends LineSegments2 {
|
|
8
7
|
color: Math.random() * 0xffffff
|
9
8
|
})) {
|
10
9
|
super(geometry, material);
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
_defineProperty(this, "isLine2", true);
|
10
|
+
this.isLine2 = true;
|
11
|
+
this.type = 'Line2';
|
15
12
|
}
|
16
13
|
|
17
14
|
}
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./LineSegmentsGeometry.cjs.js");require("three");class t extends e.LineSegmentsGeometry{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(e){const t=e.length-3,s=new Float32Array(2*t);for(let r=0;r<t;r+=3)s[2*r]=e[r],s[2*r+1]=e[r+1],s[2*r+2]=e[r+2],s[2*r+3]=e[r+3],s[2*r+4]=e[r+4],s[2*r+5]=e[r+5];return super.setPositions(s),this}setColors(e){const t=e.length-3,s=new Float32Array(2*t);for(let r=0;r<t;r+=3)s[2*r]=e[r],s[2*r+1]=e[r+1],s[2*r+2]=e[r+2],s[2*r+3]=e[r+3],s[2*r+4]=e[r+4],s[2*r+5]=e[r+5];return super.setColors(s),this}fromLine(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}}exports.LineGeometry=t;
|
package/lines/LineGeometry.d.ts
CHANGED
@@ -1,12 +1,10 @@
|
|
1
1
|
import { Line } from 'three';
|
2
|
+
|
2
3
|
import { LineSegmentsGeometry } from './LineSegmentsGeometry';
|
3
|
-
|
4
|
-
|
5
|
-
private isLineGeometry;
|
4
|
+
|
5
|
+
export class LineGeometry extends LineSegmentsGeometry {
|
6
6
|
constructor();
|
7
|
-
|
8
|
-
|
9
|
-
fromLine
|
10
|
-
copy: () => this;
|
7
|
+
readonly isLineGeometry: true;
|
8
|
+
|
9
|
+
fromLine(line: Line): this;
|
11
10
|
}
|
12
|
-
export { LineGeometry };
|
package/lines/LineGeometry.js
CHANGED
@@ -1,47 +1,10 @@
|
|
1
|
-
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
2
1
|
import { LineSegmentsGeometry } from './LineSegmentsGeometry.js';
|
3
2
|
|
4
3
|
class LineGeometry extends LineSegmentsGeometry {
|
5
4
|
constructor() {
|
6
5
|
super();
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
_defineProperty(this, "isLineGeometry", true);
|
11
|
-
|
12
|
-
_defineProperty(this, "setColors", array => {
|
13
|
-
// converts [ r1, g1, b1, r2, g2, b2, ... ] to pairs format
|
14
|
-
const length = array.length - 3;
|
15
|
-
const colors = new Float32Array(2 * length);
|
16
|
-
|
17
|
-
for (let i = 0; i < length; i += 3) {
|
18
|
-
colors[2 * i] = array[i];
|
19
|
-
colors[2 * i + 1] = array[i + 1];
|
20
|
-
colors[2 * i + 2] = array[i + 2];
|
21
|
-
colors[2 * i + 3] = array[i + 3];
|
22
|
-
colors[2 * i + 4] = array[i + 4];
|
23
|
-
colors[2 * i + 5] = array[i + 5];
|
24
|
-
}
|
25
|
-
|
26
|
-
super.setColors(colors);
|
27
|
-
return this;
|
28
|
-
});
|
29
|
-
|
30
|
-
_defineProperty(this, "fromLine", line => {
|
31
|
-
const geometry = line.geometry;
|
32
|
-
|
33
|
-
if (geometry.isBufferGeometry) {
|
34
|
-
this.setPositions(Array.from(geometry.attributes.position.array)); // assumes non-indexed
|
35
|
-
} // set colors, maybe
|
36
|
-
|
37
|
-
|
38
|
-
return this;
|
39
|
-
});
|
40
|
-
|
41
|
-
_defineProperty(this, "copy", () => {
|
42
|
-
// todo
|
43
|
-
return this;
|
44
|
-
});
|
6
|
+
this.isLineGeometry = true;
|
7
|
+
this.type = 'LineGeometry';
|
45
8
|
}
|
46
9
|
|
47
10
|
setPositions(array) {
|
@@ -62,6 +25,32 @@ class LineGeometry extends LineSegmentsGeometry {
|
|
62
25
|
return this;
|
63
26
|
}
|
64
27
|
|
28
|
+
setColors(array) {
|
29
|
+
// converts [ r1, g1, b1, r2, g2, b2, ... ] to pairs format
|
30
|
+
const length = array.length - 3;
|
31
|
+
const colors = new Float32Array(2 * length);
|
32
|
+
|
33
|
+
for (let i = 0; i < length; i += 3) {
|
34
|
+
colors[2 * i] = array[i];
|
35
|
+
colors[2 * i + 1] = array[i + 1];
|
36
|
+
colors[2 * i + 2] = array[i + 2];
|
37
|
+
colors[2 * i + 3] = array[i + 3];
|
38
|
+
colors[2 * i + 4] = array[i + 4];
|
39
|
+
colors[2 * i + 5] = array[i + 5];
|
40
|
+
}
|
41
|
+
|
42
|
+
super.setColors(colors);
|
43
|
+
return this;
|
44
|
+
}
|
45
|
+
|
46
|
+
fromLine(line) {
|
47
|
+
const geometry = line.geometry;
|
48
|
+
this.setPositions(geometry.attributes.position.array); // assumes non-indexed
|
49
|
+
// set colors, maybe
|
50
|
+
|
51
|
+
return this;
|
52
|
+
}
|
53
|
+
|
65
54
|
}
|
66
55
|
|
67
56
|
export { LineGeometry };
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@babel/runtime/helpers/defineProperty"),n=require("three");function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var i=e(t);const a={linewidth:{value:1},resolution:{value:new n.Vector2(1,1)},dashScale:{value:1},dashSize:{value:1},dashOffset:{value:0},gapSize:{value:1},opacity:{value:1}};n.ShaderLib.line={uniforms:n.UniformsUtils.merge([n.UniformsLib.common,n.UniformsLib.fog,a]),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\tvarying vec2 vUv;\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\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\tvUv = uv;\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// 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\tvec2 ndcStart = clipStart.xy / clipStart.w;\n\t\t\tvec2 ndcEnd = clipEnd.xy / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd - ndcStart;\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// perpendicular to dir\n\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\n\t\t\t// undo aspect ratio adjustment\n\t\t\tdir.x /= aspect;\n\t\t\toffset.x /= aspect;\n\n\t\t\t// sign flip\n\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t// endcaps\n\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\toffset += - dir;\n\n\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\toffset += dir;\n\n\t\t\t}\n\n\t\t\t// adjust for linewidth\n\t\t\toffset *= linewidth;\n\n\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\toffset /= resolution.y;\n\n\t\t\t// select end\n\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t// back to clip space\n\t\t\toffset *= clip.w;\n\n\t\t\tclip.xy += offset;\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\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashSize;\n\t\t\tuniform float dashOffset;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\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\tvarying vec2 vUv;\n\n\t\tvoid main() {\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\tfloat alpha = opacity;\n\n\t\t\t#ifdef ALPHA_TO_COVERAGE\n\n\t\t\t// artifacts appear on some hardware if a derivative is taken within a conditional\n\t\t\tfloat a = vUv.x;\n\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\tfloat len2 = a * a + b * b;\n\t\t\tfloat dlen = fwidth( len2 );\n\n\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\talpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n\t\t\t}\n\n\t\t\t#else\n\n\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\tfloat a = vUv.x;\n\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t}\n\n\t\t\t#endif\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, alpha );\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 <encodings_fragment>\n\t\t\t#include <fog_fragment>\n\t\t\t#include <premultiplied_alpha_fragment>\n\n\t\t}\n\t\t"};class s extends n.ShaderMaterial{constructor(t={}){super({uniforms:n.UniformsUtils.clone(n.ShaderLib.line.uniforms),vertexShader:n.ShaderLib.line.vertexShader,fragmentShader:n.ShaderLib.line.fragmentShader,clipping:!0}),i.default(this,"isLineMaterial",!0),i.default(this,"dashed",!1),i.default(this,"color",new n.Color(0)),i.default(this,"lineWidth",0),i.default(this,"dashScale",0),i.default(this,"dashOffset",0),i.default(this,"dashSize",0),i.default(this,"opacity",0),i.default(this,"resolution",new n.Vector2),i.default(this,"alphaToCoverage",!1),Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(t){const e=new n.Color(t);this.uniforms.diffuse.value=e.getHex()}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(t){this.uniforms.linewidth.value=t}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(t){this.uniforms.dashScale.value=t}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(t){this.uniforms.dashSize.value=t}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(t){this.uniforms.dashOffset.value=t}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(t){this.uniforms.gapSize.value=t}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(t){this.uniforms.opacity.value=t}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(t){this.uniforms.resolution.value.copy(t)}},alphaToCoverage:{enumerable:!0,get:function(){return Boolean("ALPHA_TO_COVERAGE"in this.defines)},set:function(t){Boolean(t)!==Boolean("ALPHA_TO_COVERAGE"in this.defines)&&(this.needsUpdate=!0),t?(this.defines.ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.ALPHA_TO_COVERAGE,this.extensions.derivatives=!1)}},dashed:{enumerable:!0,get:function(){return Boolean("USE_DASH"in this.defines)},set:function(t){Boolean(t)!==Boolean("USE_DASH"in this.defines)&&(this.needsUpdate=!0),t?this.defines.USE_DASH="":delete this.defines.USE_DASH}}}),this.setValues(t)}}exports.LineMaterial=s;
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("three");t.UniformsLib.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new t.Vector2(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},t.ShaderLib.line={uniforms:t.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\t// get the offset direction as perpendicular to the view vector\n\t\t\t\tvec3 worldDir = normalize( end.xyz - start.xyz );\n\t\t\t\tvec3 offset;\n\t\t\t\tif ( position.y < 0.5 ) {\n\n\t\t\t\t\toffset = normalize( cross( start.xyz, worldDir ) );\n\n\t\t\t\t} else {\n\n\t\t\t\t\toffset = normalize( cross( end.xyz, worldDir ) );\n\n\t\t\t\t}\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\tfloat forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );\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// extend the line bounds to encompass endcaps\n\t\t\t\t\tstart.xyz += - worldDir * linewidth * 0.5;\n\t\t\t\t\tend.xyz += worldDir * linewidth * 0.5;\n\n\t\t\t\t\t// shift the position of the quad so it hugs the forward edge of the line\n\t\t\t\t\toffset.xy -= dir * forwardOffset;\n\t\t\t\t\toffset.z += 0.5;\n\n\t\t\t\t#endif\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y > 1.0 || position.y < 0.0 ) {\n\n\t\t\t\t\toffset.xy += dir * 2.0 * forwardOffset;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth * 0.5;\n\n\t\t\t\t// set the world position\n\t\t\t\tworldPos = ( position.y < 0.5 ) ? start : end;\n\t\t\t\tworldPos.xyz += offset;\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\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\tfloat alpha = opacity;\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\tvec4 diffuseColor = vec4( diffuse, alpha );\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 <encodings_fragment>\n\t\t\t#include <fog_fragment>\n\t\t\t#include <premultiplied_alpha_fragment>\n\n\t\t}\n\t\t"};class n extends t.ShaderMaterial{constructor(n){super({type:"LineMaterial",uniforms:t.UniformsUtils.clone(t.ShaderLib.line.uniforms),vertexShader:t.ShaderLib.line.vertexShader,fragmentShader:t.ShaderLib.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(t){this.uniforms.diffuse.value=t}},worldUnits:{enumerable:!0,get:function(){return"WORLD_UNITS"in this.defines},set:function(t){!0===t?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(t){this.uniforms.linewidth.value=t}},dashed:{enumerable:!0,get:function(){return Boolean("USE_DASH"in this.defines)},set(t){Boolean(t)!==Boolean("USE_DASH"in this.defines)&&(this.needsUpdate=!0),!0===t?this.defines.USE_DASH="":delete this.defines.USE_DASH}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(t){this.uniforms.dashScale.value=t}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(t){this.uniforms.dashSize.value=t}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(t){this.uniforms.dashOffset.value=t}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(t){this.uniforms.gapSize.value=t}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(t){this.uniforms.opacity.value=t}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(t){this.uniforms.resolution.value.copy(t)}},alphaToCoverage:{enumerable:!0,get:function(){return Boolean("USE_ALPHA_TO_COVERAGE"in this.defines)},set:function(t){Boolean(t)!==Boolean("USE_ALPHA_TO_COVERAGE"in this.defines)&&(this.needsUpdate=!0),!0===t?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1)}}}),this.setValues(n)}}exports.LineMaterial=n;
|
package/lines/LineMaterial.d.ts
CHANGED
@@ -1,27 +1,31 @@
|
|
1
|
-
import { ShaderMaterial, Vector2
|
2
|
-
|
3
|
-
export
|
4
|
-
|
5
|
-
color?:
|
6
|
-
dashed?: boolean;
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
gapSize?: number;
|
11
|
-
linewidth?: number;
|
12
|
-
resolution?: Vector2;
|
1
|
+
import { Color, MaterialParameters, ShaderMaterial, Vector2 } from 'three';
|
2
|
+
|
3
|
+
export interface LineMaterialParameters extends MaterialParameters {
|
4
|
+
alphaToCoverage?: boolean | undefined;
|
5
|
+
color?: number | undefined;
|
6
|
+
dashed?: boolean | undefined;
|
7
|
+
dashScale?: number | undefined;
|
8
|
+
dashSize?: number | undefined;
|
9
|
+
dashOffset?: number | undefined;
|
10
|
+
gapSize?: number | undefined;
|
11
|
+
linewidth?: number | undefined;
|
12
|
+
resolution?: Vector2 | undefined;
|
13
|
+
wireframe?: boolean | undefined;
|
14
|
+
worldUnits?: boolean | undefined;
|
13
15
|
}
|
14
|
-
|
15
|
-
|
16
|
-
|
16
|
+
|
17
|
+
export class LineMaterial extends ShaderMaterial {
|
18
|
+
constructor(parameters?: LineMaterialParameters);
|
17
19
|
color: Color;
|
18
|
-
|
20
|
+
dashed: boolean;
|
19
21
|
dashScale: number;
|
20
|
-
dashOffset: number;
|
21
22
|
dashSize: number;
|
23
|
+
dashOffset: number;
|
24
|
+
gapSize: number;
|
22
25
|
opacity: number;
|
26
|
+
readonly isLineMaterial: true;
|
27
|
+
linewidth: number;
|
23
28
|
resolution: Vector2;
|
24
29
|
alphaToCoverage: boolean;
|
25
|
-
|
30
|
+
worldUnits: boolean;
|
26
31
|
}
|
27
|
-
export { LineMaterial };
|