three-stdlib 2.14.3 → 2.15.1
Sign up to get free protection for your applications and to get access to all the features.
- 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/ConvexGeometry.cjs.js +1 -1
- package/geometries/ConvexGeometry.js +1 -1
- 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 +57 -77
- package/index.js +55 -52
- package/interactive/InteractiveGroup.cjs.js +1 -0
- package/interactive/InteractiveGroup.d.ts +5 -0
- package/interactive/InteractiveGroup.js +87 -0
- package/loaders/GLTFLoader.d.ts +2 -9
- package/loaders/LUT3dlLoader.d.ts +2 -2
- package/loaders/LUTCubeLoader.d.ts +2 -2
- package/loaders/VOXLoader.d.ts +2 -2
- package/math/ConvexHull.cjs.js +1 -1
- package/math/ConvexHull.js +639 -603
- 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/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/shaders/index.cjs.js +0 -1
- package/shaders/index.d.ts +0 -53
- package/shaders/index.js +0 -53
@@ -1,4 +1,5 @@
|
|
1
|
-
import { Vector3,
|
1
|
+
import { Vector3, Curve } from 'three';
|
2
|
+
import { ParametricGeometry } from './ParametricGeometry.js';
|
2
3
|
|
3
4
|
/**
|
4
5
|
* Experimenting of primitive geometry creation using Surface Parametric equations
|
@@ -9,7 +10,7 @@ const ParametricGeometries = {
|
|
9
10
|
u *= Math.PI;
|
10
11
|
v *= 2 * Math.PI;
|
11
12
|
u = u * 2;
|
12
|
-
let x,
|
13
|
+
let x, z;
|
13
14
|
|
14
15
|
if (u < Math.PI) {
|
15
16
|
x = 3 * Math.cos(u) * (1 + Math.sin(u)) + 2 * (1 - Math.cos(u) / 2) * Math.cos(u) * Math.cos(v);
|
@@ -19,11 +20,11 @@ const ParametricGeometries = {
|
|
19
20
|
z = -8 * Math.sin(u);
|
20
21
|
}
|
21
22
|
|
22
|
-
y = -2 * (1 - Math.cos(u) / 2) * Math.sin(v);
|
23
|
+
const y = -2 * (1 - Math.cos(u) / 2) * Math.sin(v);
|
23
24
|
target.set(x, y, z);
|
24
25
|
},
|
25
26
|
plane: function (width, height) {
|
26
|
-
return (u, v, target)
|
27
|
+
return function (u, v, target) {
|
27
28
|
const x = u * width;
|
28
29
|
const y = 0;
|
29
30
|
const z = v * height;
|
@@ -35,11 +36,10 @@ const ParametricGeometries = {
|
|
35
36
|
// http://www.wolframalpha.com/input/?i=M%C3%B6bius+strip+parametric+equations&lk=1&a=ClashPrefs_*Surface.MoebiusStrip.SurfaceProperty.ParametricEquations-
|
36
37
|
u = u - 0.5;
|
37
38
|
const v = 2 * Math.PI * t;
|
38
|
-
let x, y, z;
|
39
39
|
const a = 2;
|
40
|
-
x = Math.cos(v) * (a + u * Math.cos(v / 2));
|
41
|
-
y = Math.sin(v) * (a + u * Math.cos(v / 2));
|
42
|
-
z = u * Math.sin(v / 2);
|
40
|
+
const x = Math.cos(v) * (a + u * Math.cos(v / 2));
|
41
|
+
const y = Math.sin(v) * (a + u * Math.cos(v / 2));
|
42
|
+
const z = u * Math.sin(v / 2);
|
43
43
|
target.set(x, y, z);
|
44
44
|
},
|
45
45
|
mobius3d: function (u, t, target) {
|
@@ -51,10 +51,9 @@ const ParametricGeometries = {
|
|
51
51
|
const major = 2.25,
|
52
52
|
a = 0.125,
|
53
53
|
b = 0.65;
|
54
|
-
let x
|
55
|
-
|
56
|
-
|
57
|
-
y = (major + x) * Math.sin(u);
|
54
|
+
let x = a * Math.cos(t) * Math.cos(phi) - b * Math.sin(t) * Math.sin(phi);
|
55
|
+
const z = a * Math.cos(t) * Math.sin(phi) + b * Math.sin(t) * Math.cos(phi);
|
56
|
+
const y = (major + x) * Math.sin(u);
|
58
57
|
x = (major + x) * Math.cos(u);
|
59
58
|
target.set(x, y, z);
|
60
59
|
}
|
@@ -65,123 +64,116 @@ const ParametricGeometries = {
|
|
65
64
|
*
|
66
65
|
*********************************************/
|
67
66
|
|
68
|
-
ParametricGeometries.TubeGeometry =
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
};
|
67
|
+
ParametricGeometries.TubeGeometry = class TubeGeometry extends ParametricGeometry {
|
68
|
+
constructor(path, segments = 64, radius = 1, segmentsRadius = 8, closed = false) {
|
69
|
+
const numpoints = segments + 1;
|
70
|
+
const frames = path.computeFrenetFrames(segments, closed),
|
71
|
+
tangents = frames.tangents,
|
72
|
+
normals = frames.normals,
|
73
|
+
binormals = frames.binormals;
|
74
|
+
const position = new Vector3();
|
75
|
+
|
76
|
+
function ParametricTube(u, v, target) {
|
77
|
+
v *= 2 * Math.PI;
|
78
|
+
const i = Math.floor(u * (numpoints - 1));
|
79
|
+
path.getPointAt(u, position);
|
80
|
+
const normal = normals[i];
|
81
|
+
const binormal = binormals[i];
|
82
|
+
const cx = -radius * Math.cos(v); // TODO: Hack: Negating it so it faces outside.
|
83
|
+
|
84
|
+
const cy = radius * Math.sin(v);
|
85
|
+
position.x += cx * normal.x + cy * binormal.x;
|
86
|
+
position.y += cx * normal.y + cy * binormal.y;
|
87
|
+
position.z += cx * normal.z + cy * binormal.z;
|
88
|
+
target.copy(position);
|
89
|
+
}
|
90
|
+
|
91
|
+
super(ParametricTube, segments, segmentsRadius); // proxy internals
|
92
|
+
|
93
|
+
this.tangents = tangents;
|
94
|
+
this.normals = normals;
|
95
|
+
this.binormals = binormals;
|
96
|
+
this.path = path;
|
97
|
+
this.segments = segments;
|
98
|
+
this.radius = radius;
|
99
|
+
this.segmentsRadius = segmentsRadius;
|
100
|
+
this.closed = closed;
|
101
|
+
}
|
104
102
|
|
105
|
-
|
106
|
-
ParametricGeometries.TubeGeometry.prototype.constructor = ParametricGeometries.TubeGeometry;
|
103
|
+
};
|
107
104
|
/*********************************************
|
108
105
|
*
|
109
106
|
* Parametric Replacement for TorusKnotGeometry
|
110
107
|
*
|
111
108
|
*********************************************/
|
112
109
|
|
113
|
-
ParametricGeometries.TorusKnotGeometry =
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
110
|
+
ParametricGeometries.TorusKnotGeometry = class TorusKnotGeometry extends ParametricGeometries.TubeGeometry {
|
111
|
+
constructor(radius = 200, tube = 40, segmentsT = 64, segmentsR = 8, p = 2, q = 3) {
|
112
|
+
class TorusKnotCurve extends Curve {
|
113
|
+
getPoint(t, optionalTarget = new Vector3()) {
|
114
|
+
const point = optionalTarget;
|
115
|
+
t *= Math.PI * 2;
|
116
|
+
const r = 0.5;
|
117
|
+
const x = (1 + r * Math.cos(q * t)) * Math.cos(p * t);
|
118
|
+
const y = (1 + r * Math.cos(q * t)) * Math.sin(p * t);
|
119
|
+
const z = r * Math.sin(q * t);
|
120
|
+
return point.set(x, y, z).multiplyScalar(radius);
|
121
|
+
}
|
125
122
|
|
126
|
-
getPoint(t, optionalTarget) {
|
127
|
-
const point = optionalTarget || new Vector3();
|
128
|
-
t *= Math.PI * 2;
|
129
|
-
const r = 0.5;
|
130
|
-
const x = (1 + r * Math.cos(q * t)) * Math.cos(p * t);
|
131
|
-
const y = (1 + r * Math.cos(q * t)) * Math.sin(p * t);
|
132
|
-
const z = r * Math.sin(q * t);
|
133
|
-
return point.set(x, y, z).multiplyScalar(radius);
|
134
123
|
}
|
135
124
|
|
125
|
+
const segments = segmentsT;
|
126
|
+
const radiusSegments = segmentsR;
|
127
|
+
const extrudePath = new TorusKnotCurve();
|
128
|
+
super(extrudePath, segments, tube, radiusSegments, true, false);
|
129
|
+
this.radius = radius;
|
130
|
+
this.tube = tube;
|
131
|
+
this.segmentsT = segmentsT;
|
132
|
+
this.segmentsR = segmentsR;
|
133
|
+
this.p = p;
|
134
|
+
this.q = q;
|
136
135
|
}
|
137
136
|
|
138
|
-
const segments = segmentsT;
|
139
|
-
const radiusSegments = segmentsR;
|
140
|
-
const extrudePath = new TorusKnotCurve();
|
141
|
-
ParametricGeometries.TubeGeometry.call(this, extrudePath, segments, tube, radiusSegments, true, false);
|
142
137
|
};
|
143
|
-
|
144
|
-
ParametricGeometries.TorusKnotGeometry.prototype = Object.create(BufferGeometry.prototype);
|
145
|
-
ParametricGeometries.TorusKnotGeometry.prototype.constructor = ParametricGeometries.TorusKnotGeometry;
|
146
138
|
/*********************************************
|
147
139
|
*
|
148
140
|
* Parametric Replacement for SphereGeometry
|
149
141
|
*
|
150
142
|
*********************************************/
|
151
143
|
|
152
|
-
ParametricGeometries.SphereGeometry =
|
153
|
-
|
154
|
-
u
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
144
|
+
ParametricGeometries.SphereGeometry = class SphereGeometry extends ParametricGeometry {
|
145
|
+
constructor(size, u, v) {
|
146
|
+
function sphere(u, v, target) {
|
147
|
+
u *= Math.PI;
|
148
|
+
v *= 2 * Math.PI;
|
149
|
+
const x = size * Math.sin(u) * Math.cos(v);
|
150
|
+
const y = size * Math.sin(u) * Math.sin(v);
|
151
|
+
const z = size * Math.cos(u);
|
152
|
+
target.set(x, y, z);
|
153
|
+
}
|
154
|
+
|
155
|
+
super(sphere, u, v);
|
160
156
|
}
|
161
157
|
|
162
|
-
ParametricGeometry.call(this, sphere, u, v);
|
163
158
|
};
|
164
|
-
|
165
|
-
ParametricGeometries.SphereGeometry.prototype = Object.create(BufferGeometry.prototype);
|
166
|
-
ParametricGeometries.SphereGeometry.prototype.constructor = ParametricGeometries.SphereGeometry;
|
167
159
|
/*********************************************
|
168
160
|
*
|
169
161
|
* Parametric Replacement for PlaneGeometry
|
170
162
|
*
|
171
163
|
*********************************************/
|
172
164
|
|
173
|
-
ParametricGeometries.PlaneGeometry =
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
165
|
+
ParametricGeometries.PlaneGeometry = class PlaneGeometry extends ParametricGeometry {
|
166
|
+
constructor(width, depth, segmentsWidth, segmentsDepth) {
|
167
|
+
function plane(u, v, target) {
|
168
|
+
const x = u * width;
|
169
|
+
const y = 0;
|
170
|
+
const z = v * depth;
|
171
|
+
target.set(x, y, z);
|
172
|
+
}
|
173
|
+
|
174
|
+
super(plane, segmentsWidth, segmentsDepth);
|
179
175
|
}
|
180
176
|
|
181
|
-
ParametricGeometry.call(this, plane, segmentsWidth, segmentsDepth);
|
182
177
|
};
|
183
178
|
|
184
|
-
ParametricGeometries.PlaneGeometry.prototype = Object.create(BufferGeometry.prototype);
|
185
|
-
ParametricGeometries.PlaneGeometry.prototype.constructor = ParametricGeometries.PlaneGeometry;
|
186
|
-
|
187
179
|
export { ParametricGeometries };
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("three");class e extends t.BufferGeometry{constructor(e=((t,e,s)=>s.set(t,e,Math.cos(t)*Math.sin(e))),s=8,r=8){super(),this.type="ParametricGeometry",this.parameters={func:e,slices:s,stacks:r};const o=[],u=[],c=[],i=[],n=1e-5,a=new t.Vector3,f=new t.Vector3,h=new t.Vector3,l=new t.Vector3,p=new t.Vector3,b=s+1;for(let t=0;t<=r;t++){const o=t/r;for(let t=0;t<=s;t++){const r=t/s;e(r,o,f),u.push(f.x,f.y,f.z),r-n>=0?(e(r-n,o,h),l.subVectors(f,h)):(e(r+n,o,h),l.subVectors(h,f)),o-n>=0?(e(r,o-n,h),p.subVectors(f,h)):(e(r,o+n,h),p.subVectors(h,f)),a.crossVectors(l,p).normalize(),c.push(a.x,a.y,a.z),i.push(r,o)}}for(let t=0;t<r;t++)for(let e=0;e<s;e++){const s=t*b+e,r=t*b+e+1,u=(t+1)*b+e+1,c=(t+1)*b+e;o.push(s,r,c),o.push(r,u,c)}this.setIndex(o),this.setAttribute("position",new t.Float32BufferAttribute(u,3)),this.setAttribute("normal",new t.Float32BufferAttribute(c,3)),this.setAttribute("uv",new t.Float32BufferAttribute(i,2))}}exports.ParametricGeometry=e;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import { Vector3, BufferGeometry } from 'three';
|
2
|
+
|
3
|
+
export class ParametricGeometry extends BufferGeometry {
|
4
|
+
constructor(func?: (u: number, v: number, target: Vector3) => void, slices?: number, stacks?: number);
|
5
|
+
|
6
|
+
/**
|
7
|
+
* @default 'ParametricGeometry'
|
8
|
+
*/
|
9
|
+
type: string;
|
10
|
+
|
11
|
+
parameters: {
|
12
|
+
func: (u: number, v: number, dest: Vector3) => void;
|
13
|
+
slices: number;
|
14
|
+
stacks: number;
|
15
|
+
};
|
16
|
+
}
|
17
|
+
|
18
|
+
export { ParametricGeometry as ParametricBufferGeometry };
|
@@ -0,0 +1,87 @@
|
|
1
|
+
import { BufferGeometry, Vector3, Float32BufferAttribute } from 'three';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Parametric Surfaces Geometry
|
5
|
+
* based on the brilliant article by @prideout https://prideout.net/blog/old/blog/index.html@p=44.html
|
6
|
+
*/
|
7
|
+
|
8
|
+
class ParametricGeometry extends BufferGeometry {
|
9
|
+
constructor(func = (u, v, target) => target.set(u, v, Math.cos(u) * Math.sin(v)), slices = 8, stacks = 8) {
|
10
|
+
super();
|
11
|
+
this.type = 'ParametricGeometry';
|
12
|
+
this.parameters = {
|
13
|
+
func: func,
|
14
|
+
slices: slices,
|
15
|
+
stacks: stacks
|
16
|
+
}; // buffers
|
17
|
+
|
18
|
+
const indices = [];
|
19
|
+
const vertices = [];
|
20
|
+
const normals = [];
|
21
|
+
const uvs = [];
|
22
|
+
const EPS = 0.00001;
|
23
|
+
const normal = new Vector3();
|
24
|
+
const p0 = new Vector3(),
|
25
|
+
p1 = new Vector3();
|
26
|
+
const pu = new Vector3(),
|
27
|
+
pv = new Vector3(); // generate vertices, normals and uvs
|
28
|
+
|
29
|
+
const sliceCount = slices + 1;
|
30
|
+
|
31
|
+
for (let i = 0; i <= stacks; i++) {
|
32
|
+
const v = i / stacks;
|
33
|
+
|
34
|
+
for (let j = 0; j <= slices; j++) {
|
35
|
+
const u = j / slices; // vertex
|
36
|
+
|
37
|
+
func(u, v, p0);
|
38
|
+
vertices.push(p0.x, p0.y, p0.z); // normal
|
39
|
+
// approximate tangent vectors via finite differences
|
40
|
+
|
41
|
+
if (u - EPS >= 0) {
|
42
|
+
func(u - EPS, v, p1);
|
43
|
+
pu.subVectors(p0, p1);
|
44
|
+
} else {
|
45
|
+
func(u + EPS, v, p1);
|
46
|
+
pu.subVectors(p1, p0);
|
47
|
+
}
|
48
|
+
|
49
|
+
if (v - EPS >= 0) {
|
50
|
+
func(u, v - EPS, p1);
|
51
|
+
pv.subVectors(p0, p1);
|
52
|
+
} else {
|
53
|
+
func(u, v + EPS, p1);
|
54
|
+
pv.subVectors(p1, p0);
|
55
|
+
} // cross product of tangent vectors returns surface normal
|
56
|
+
|
57
|
+
|
58
|
+
normal.crossVectors(pu, pv).normalize();
|
59
|
+
normals.push(normal.x, normal.y, normal.z); // uv
|
60
|
+
|
61
|
+
uvs.push(u, v);
|
62
|
+
}
|
63
|
+
} // generate indices
|
64
|
+
|
65
|
+
|
66
|
+
for (let i = 0; i < stacks; i++) {
|
67
|
+
for (let j = 0; j < slices; j++) {
|
68
|
+
const a = i * sliceCount + j;
|
69
|
+
const b = i * sliceCount + j + 1;
|
70
|
+
const c = (i + 1) * sliceCount + j + 1;
|
71
|
+
const d = (i + 1) * sliceCount + j; // faces one and two
|
72
|
+
|
73
|
+
indices.push(a, b, d);
|
74
|
+
indices.push(b, c, d);
|
75
|
+
}
|
76
|
+
} // build geometry
|
77
|
+
|
78
|
+
|
79
|
+
this.setIndex(indices);
|
80
|
+
this.setAttribute('position', new Float32BufferAttribute(vertices, 3));
|
81
|
+
this.setAttribute('normal', new Float32BufferAttribute(normals, 3));
|
82
|
+
this.setAttribute('uv', new Float32BufferAttribute(uvs, 2));
|
83
|
+
}
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
export { ParametricGeometry };
|