@zephyr3d/scene 0.1.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/dist/animation/animation.js +173 -0
- package/dist/animation/animation.js.map +1 -0
- package/dist/animation/animationset.js +95 -0
- package/dist/animation/animationset.js.map +1 -0
- package/dist/animation/animationtrack.js +38 -0
- package/dist/animation/animationtrack.js.map +1 -0
- package/dist/animation/eulerrotationtrack.js +33 -0
- package/dist/animation/eulerrotationtrack.js.map +1 -0
- package/dist/animation/rotationtrack.js +37 -0
- package/dist/animation/rotationtrack.js.map +1 -0
- package/dist/animation/scaletrack.js +36 -0
- package/dist/animation/scaletrack.js.map +1 -0
- package/dist/animation/skeleton.js +97 -0
- package/dist/animation/skeleton.js.map +1 -0
- package/dist/animation/translationtrack.js +36 -0
- package/dist/animation/translationtrack.js.map +1 -0
- package/dist/animation/usertrack.js +47 -0
- package/dist/animation/usertrack.js.map +1 -0
- package/dist/app.js +173 -0
- package/dist/app.js.map +1 -0
- package/dist/asset/assetmanager.js +476 -0
- package/dist/asset/assetmanager.js.map +1 -0
- package/dist/asset/builtin.js +373 -0
- package/dist/asset/builtin.js.map +1 -0
- package/dist/asset/loaders/dds/dds.js +472 -0
- package/dist/asset/loaders/dds/dds.js.map +1 -0
- package/dist/asset/loaders/dds/dds_loader.js +38 -0
- package/dist/asset/loaders/dds/dds_loader.js.map +1 -0
- package/dist/asset/loaders/gltf/gltf_loader.js +981 -0
- package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -0
- package/dist/asset/loaders/gltf/helpers.js +314 -0
- package/dist/asset/loaders/gltf/helpers.js.map +1 -0
- package/dist/asset/loaders/hdr/hdr.js +175 -0
- package/dist/asset/loaders/hdr/hdr.js.map +1 -0
- package/dist/asset/loaders/image/tga_Loader.js +117 -0
- package/dist/asset/loaders/image/tga_Loader.js.map +1 -0
- package/dist/asset/loaders/image/webimage_loader.js +50 -0
- package/dist/asset/loaders/image/webimage_loader.js.map +1 -0
- package/dist/asset/loaders/loader.js +45 -0
- package/dist/asset/loaders/loader.js.map +1 -0
- package/dist/asset/model.js +264 -0
- package/dist/asset/model.js.map +1 -0
- package/dist/blitter/blitter.js +389 -0
- package/dist/blitter/blitter.js.map +1 -0
- package/dist/blitter/box.js +118 -0
- package/dist/blitter/box.js.map +1 -0
- package/dist/blitter/copy.js +22 -0
- package/dist/blitter/copy.js.map +1 -0
- package/dist/blitter/depthlimitedgaussion.js +166 -0
- package/dist/blitter/depthlimitedgaussion.js.map +1 -0
- package/dist/blitter/gaussianblur.js +229 -0
- package/dist/blitter/gaussianblur.js.map +1 -0
- package/dist/camera/base.js +90 -0
- package/dist/camera/base.js.map +1 -0
- package/dist/camera/camera.js +358 -0
- package/dist/camera/camera.js.map +1 -0
- package/dist/camera/fps.js +246 -0
- package/dist/camera/fps.js.map +1 -0
- package/dist/camera/orbit.js +157 -0
- package/dist/camera/orbit.js.map +1 -0
- package/dist/camera/orthocamera.js +126 -0
- package/dist/camera/orthocamera.js.map +1 -0
- package/dist/camera/perspectivecamera.js +133 -0
- package/dist/camera/perspectivecamera.js.map +1 -0
- package/dist/index.d.ts +8402 -0
- package/dist/index.js +87 -0
- package/dist/index.js.map +1 -0
- package/dist/input/inputmgr.js +242 -0
- package/dist/input/inputmgr.js.map +1 -0
- package/dist/material/blinn.js +75 -0
- package/dist/material/blinn.js.map +1 -0
- package/dist/material/grassmaterial.js +221 -0
- package/dist/material/grassmaterial.js.map +1 -0
- package/dist/material/lambert.js +52 -0
- package/dist/material/lambert.js.map +1 -0
- package/dist/material/lightmodel.js +2074 -0
- package/dist/material/lightmodel.js.map +1 -0
- package/dist/material/lit.js +578 -0
- package/dist/material/lit.js.map +1 -0
- package/dist/material/material.js +458 -0
- package/dist/material/material.js.map +1 -0
- package/dist/material/meshmaterial.js +311 -0
- package/dist/material/meshmaterial.js.map +1 -0
- package/dist/material/mixins/albedocolor.js +130 -0
- package/dist/material/mixins/albedocolor.js.map +1 -0
- package/dist/material/mixins/texture.js +110 -0
- package/dist/material/mixins/texture.js.map +1 -0
- package/dist/material/mixins/vertexcolor.js +45 -0
- package/dist/material/mixins/vertexcolor.js.map +1 -0
- package/dist/material/pbr.js +27 -0
- package/dist/material/pbr.js.map +1 -0
- package/dist/material/standard.js +282 -0
- package/dist/material/standard.js.map +1 -0
- package/dist/material/terrainlightmodel.js +259 -0
- package/dist/material/terrainlightmodel.js.map +1 -0
- package/dist/material/terrainmaterial.js +139 -0
- package/dist/material/terrainmaterial.js.map +1 -0
- package/dist/material/unlit.js +29 -0
- package/dist/material/unlit.js.map +1 -0
- package/dist/posteffect/bloom.js +398 -0
- package/dist/posteffect/bloom.js.map +1 -0
- package/dist/posteffect/compositor.js +264 -0
- package/dist/posteffect/compositor.js.map +1 -0
- package/dist/posteffect/fxaa.js +291 -0
- package/dist/posteffect/fxaa.js.map +1 -0
- package/dist/posteffect/grayscale.js +87 -0
- package/dist/posteffect/grayscale.js.map +1 -0
- package/dist/posteffect/posteffect.js +165 -0
- package/dist/posteffect/posteffect.js.map +1 -0
- package/dist/posteffect/sao.js +327 -0
- package/dist/posteffect/sao.js.map +1 -0
- package/dist/posteffect/tonemap.js +112 -0
- package/dist/posteffect/tonemap.js.map +1 -0
- package/dist/posteffect/water.js +535 -0
- package/dist/posteffect/water.js.map +1 -0
- package/dist/render/clipmap.js +462 -0
- package/dist/render/clipmap.js.map +1 -0
- package/dist/render/cluster_light.js +329 -0
- package/dist/render/cluster_light.js.map +1 -0
- package/dist/render/cull_visitor.js +124 -0
- package/dist/render/cull_visitor.js.map +1 -0
- package/dist/render/depth_pass.js +47 -0
- package/dist/render/depth_pass.js.map +1 -0
- package/dist/render/envlight.js +282 -0
- package/dist/render/envlight.js.map +1 -0
- package/dist/render/forward.js +186 -0
- package/dist/render/forward.js.map +1 -0
- package/dist/render/forward_pass.js +137 -0
- package/dist/render/forward_pass.js.map +1 -0
- package/dist/render/helper.js +38 -0
- package/dist/render/helper.js.map +1 -0
- package/dist/render/primitive.js +246 -0
- package/dist/render/primitive.js.map +1 -0
- package/dist/render/render_queue.js +163 -0
- package/dist/render/render_queue.js.map +1 -0
- package/dist/render/renderpass.js +151 -0
- package/dist/render/renderpass.js.map +1 -0
- package/dist/render/renderscheme.js +61 -0
- package/dist/render/renderscheme.js.map +1 -0
- package/dist/render/scatteringlut.js +634 -0
- package/dist/render/scatteringlut.js.map +1 -0
- package/dist/render/shadowmap_pass.js +70 -0
- package/dist/render/shadowmap_pass.js.map +1 -0
- package/dist/render/sky.js +881 -0
- package/dist/render/sky.js.map +1 -0
- package/dist/render/temporalcache.js +222 -0
- package/dist/render/temporalcache.js.map +1 -0
- package/dist/render/watermesh.js +835 -0
- package/dist/render/watermesh.js.map +1 -0
- package/dist/scene/environment.js +146 -0
- package/dist/scene/environment.js.map +1 -0
- package/dist/scene/graph_node.js +69 -0
- package/dist/scene/graph_node.js.map +1 -0
- package/dist/scene/light.js +436 -0
- package/dist/scene/light.js.map +1 -0
- package/dist/scene/mesh.js +215 -0
- package/dist/scene/mesh.js.map +1 -0
- package/dist/scene/model.js +111 -0
- package/dist/scene/model.js.map +1 -0
- package/dist/scene/octree.js +651 -0
- package/dist/scene/octree.js.map +1 -0
- package/dist/scene/octree_update_visitor.js +16 -0
- package/dist/scene/octree_update_visitor.js.map +1 -0
- package/dist/scene/raycast_visitor.js +72 -0
- package/dist/scene/raycast_visitor.js.map +1 -0
- package/dist/scene/scene.js +225 -0
- package/dist/scene/scene.js.map +1 -0
- package/dist/scene/scene_node.js +299 -0
- package/dist/scene/scene_node.js.map +1 -0
- package/dist/scene/terrain/grass.js +277 -0
- package/dist/scene/terrain/grass.js.map +1 -0
- package/dist/scene/terrain/heightfield.js +391 -0
- package/dist/scene/terrain/heightfield.js.map +1 -0
- package/dist/scene/terrain/patch.js +530 -0
- package/dist/scene/terrain/patch.js.map +1 -0
- package/dist/scene/terrain/quadtree.js +430 -0
- package/dist/scene/terrain/quadtree.js.map +1 -0
- package/dist/scene/terrain/terrain.js +258 -0
- package/dist/scene/terrain/terrain.js.map +1 -0
- package/dist/scene/xform.js +224 -0
- package/dist/scene/xform.js.map +1 -0
- package/dist/shaders/builtins.js +110 -0
- package/dist/shaders/builtins.js.map +1 -0
- package/dist/shaders/framework.js +709 -0
- package/dist/shaders/framework.js.map +1 -0
- package/dist/shaders/lighting.js +335 -0
- package/dist/shaders/lighting.js.map +1 -0
- package/dist/shaders/misc.js +405 -0
- package/dist/shaders/misc.js.map +1 -0
- package/dist/shaders/noise.js +157 -0
- package/dist/shaders/noise.js.map +1 -0
- package/dist/shaders/pbr.js +132 -0
- package/dist/shaders/pbr.js.map +1 -0
- package/dist/shaders/shadow.js +642 -0
- package/dist/shaders/shadow.js.map +1 -0
- package/dist/shaders/water.js +630 -0
- package/dist/shaders/water.js.map +1 -0
- package/dist/shadow/esm.js +235 -0
- package/dist/shadow/esm.js.map +1 -0
- package/dist/shadow/pcf_opt.js +182 -0
- package/dist/shadow/pcf_opt.js.map +1 -0
- package/dist/shadow/pcf_pd.js +190 -0
- package/dist/shadow/pcf_pd.js.map +1 -0
- package/dist/shadow/shadow_impl.js +15 -0
- package/dist/shadow/shadow_impl.js.map +1 -0
- package/dist/shadow/shadowmapper.js +709 -0
- package/dist/shadow/shadowmapper.js.map +1 -0
- package/dist/shadow/ssm.js +194 -0
- package/dist/shadow/ssm.js.map +1 -0
- package/dist/shadow/vsm.js +298 -0
- package/dist/shadow/vsm.js.map +1 -0
- package/dist/shapes/box.js +313 -0
- package/dist/shapes/box.js.map +1 -0
- package/dist/shapes/cylinder.js +74 -0
- package/dist/shapes/cylinder.js.map +1 -0
- package/dist/shapes/plane.js +48 -0
- package/dist/shapes/plane.js.map +1 -0
- package/dist/shapes/shape.js +33 -0
- package/dist/shapes/shape.js.map +1 -0
- package/dist/shapes/sphere.js +91 -0
- package/dist/shapes/sphere.js.map +1 -0
- package/dist/shapes/torus.js +100 -0
- package/dist/shapes/torus.js.map +1 -0
- package/dist/utility/aabbtree.js +390 -0
- package/dist/utility/aabbtree.js.map +1 -0
- package/dist/utility/bounding_volume.js +78 -0
- package/dist/utility/bounding_volume.js.map +1 -0
- package/dist/utility/panorama.js +163 -0
- package/dist/utility/panorama.js.map +1 -0
- package/dist/utility/pmrem.js +345 -0
- package/dist/utility/pmrem.js.map +1 -0
- package/dist/utility/shprojection.js +448 -0
- package/dist/utility/shprojection.js.map +1 -0
- package/dist/values.js +48 -0
- package/dist/values.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import { Vector3 } from '@zephyr3d/base';
|
|
2
|
+
import { BoundingBox } from '../utility/bounding_volume.js';
|
|
3
|
+
import { Shape } from './shape.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Box shape
|
|
7
|
+
* @public
|
|
8
|
+
*/ class BoxShape extends Shape {
|
|
9
|
+
/**
|
|
10
|
+
* Creates an instance of box shape
|
|
11
|
+
* @param options - The creation options
|
|
12
|
+
*/ constructor(options){
|
|
13
|
+
super(options);
|
|
14
|
+
}
|
|
15
|
+
/** @internal */ createDefaultOptions() {
|
|
16
|
+
const options = super.createDefaultOptions();
|
|
17
|
+
options.size = 1;
|
|
18
|
+
return options;
|
|
19
|
+
}
|
|
20
|
+
/** @internal */ _createArrays(vertices, normals, uvs, indices, minx, miny, minz, maxx, maxy, maxz) {
|
|
21
|
+
const needTangent = this._options.needTangent;
|
|
22
|
+
const needNormal = this._options.needNormal || needTangent;
|
|
23
|
+
const needUV = this._options.needUV;
|
|
24
|
+
const uv = needUV ? [
|
|
25
|
+
0,
|
|
26
|
+
0,
|
|
27
|
+
0,
|
|
28
|
+
1,
|
|
29
|
+
1,
|
|
30
|
+
1,
|
|
31
|
+
1,
|
|
32
|
+
0
|
|
33
|
+
] : null;
|
|
34
|
+
const topFacePos = [
|
|
35
|
+
minx,
|
|
36
|
+
maxy,
|
|
37
|
+
minz,
|
|
38
|
+
minx,
|
|
39
|
+
maxy,
|
|
40
|
+
maxz,
|
|
41
|
+
maxx,
|
|
42
|
+
maxy,
|
|
43
|
+
maxz,
|
|
44
|
+
maxx,
|
|
45
|
+
maxy,
|
|
46
|
+
minz
|
|
47
|
+
];
|
|
48
|
+
const topFacenormal = needNormal ? [
|
|
49
|
+
0,
|
|
50
|
+
1,
|
|
51
|
+
0,
|
|
52
|
+
0,
|
|
53
|
+
1,
|
|
54
|
+
0,
|
|
55
|
+
0,
|
|
56
|
+
1,
|
|
57
|
+
0,
|
|
58
|
+
0,
|
|
59
|
+
1,
|
|
60
|
+
0
|
|
61
|
+
] : null;
|
|
62
|
+
const frontFacePos = [
|
|
63
|
+
minx,
|
|
64
|
+
maxy,
|
|
65
|
+
maxz,
|
|
66
|
+
minx,
|
|
67
|
+
miny,
|
|
68
|
+
maxz,
|
|
69
|
+
maxx,
|
|
70
|
+
miny,
|
|
71
|
+
maxz,
|
|
72
|
+
maxx,
|
|
73
|
+
maxy,
|
|
74
|
+
maxz
|
|
75
|
+
];
|
|
76
|
+
const frontFaceNormal = needNormal ? [
|
|
77
|
+
0,
|
|
78
|
+
0,
|
|
79
|
+
1,
|
|
80
|
+
0,
|
|
81
|
+
0,
|
|
82
|
+
1,
|
|
83
|
+
0,
|
|
84
|
+
0,
|
|
85
|
+
1,
|
|
86
|
+
0,
|
|
87
|
+
0,
|
|
88
|
+
1
|
|
89
|
+
] : null;
|
|
90
|
+
const rightFacePos = [
|
|
91
|
+
maxx,
|
|
92
|
+
maxy,
|
|
93
|
+
maxz,
|
|
94
|
+
maxx,
|
|
95
|
+
miny,
|
|
96
|
+
maxz,
|
|
97
|
+
maxx,
|
|
98
|
+
miny,
|
|
99
|
+
minz,
|
|
100
|
+
maxx,
|
|
101
|
+
maxy,
|
|
102
|
+
minz
|
|
103
|
+
];
|
|
104
|
+
const rightFaceNormal = needNormal ? [
|
|
105
|
+
1,
|
|
106
|
+
0,
|
|
107
|
+
0,
|
|
108
|
+
1,
|
|
109
|
+
0,
|
|
110
|
+
0,
|
|
111
|
+
1,
|
|
112
|
+
0,
|
|
113
|
+
0,
|
|
114
|
+
1,
|
|
115
|
+
0,
|
|
116
|
+
0
|
|
117
|
+
] : null;
|
|
118
|
+
const backFacePos = [
|
|
119
|
+
maxx,
|
|
120
|
+
maxy,
|
|
121
|
+
minz,
|
|
122
|
+
maxx,
|
|
123
|
+
miny,
|
|
124
|
+
minz,
|
|
125
|
+
minx,
|
|
126
|
+
miny,
|
|
127
|
+
minz,
|
|
128
|
+
minx,
|
|
129
|
+
maxy,
|
|
130
|
+
minz
|
|
131
|
+
];
|
|
132
|
+
const backFaceNormal = needNormal ? [
|
|
133
|
+
0,
|
|
134
|
+
0,
|
|
135
|
+
-1,
|
|
136
|
+
0,
|
|
137
|
+
0,
|
|
138
|
+
-1,
|
|
139
|
+
0,
|
|
140
|
+
0,
|
|
141
|
+
-1,
|
|
142
|
+
0,
|
|
143
|
+
0,
|
|
144
|
+
-1
|
|
145
|
+
] : null;
|
|
146
|
+
const leftFacePos = [
|
|
147
|
+
minx,
|
|
148
|
+
maxy,
|
|
149
|
+
minz,
|
|
150
|
+
minx,
|
|
151
|
+
miny,
|
|
152
|
+
minz,
|
|
153
|
+
minx,
|
|
154
|
+
miny,
|
|
155
|
+
maxz,
|
|
156
|
+
minx,
|
|
157
|
+
maxy,
|
|
158
|
+
maxz
|
|
159
|
+
];
|
|
160
|
+
const leftFaceNormal = needNormal ? [
|
|
161
|
+
-1,
|
|
162
|
+
0,
|
|
163
|
+
0,
|
|
164
|
+
-1,
|
|
165
|
+
0,
|
|
166
|
+
0,
|
|
167
|
+
-1,
|
|
168
|
+
0,
|
|
169
|
+
0,
|
|
170
|
+
-1,
|
|
171
|
+
0,
|
|
172
|
+
0
|
|
173
|
+
] : null;
|
|
174
|
+
const bottomFacePos = [
|
|
175
|
+
minx,
|
|
176
|
+
miny,
|
|
177
|
+
maxz,
|
|
178
|
+
minx,
|
|
179
|
+
miny,
|
|
180
|
+
minz,
|
|
181
|
+
maxx,
|
|
182
|
+
miny,
|
|
183
|
+
minz,
|
|
184
|
+
maxx,
|
|
185
|
+
miny,
|
|
186
|
+
maxz
|
|
187
|
+
];
|
|
188
|
+
const bottomFaceNormal = needNormal ? [
|
|
189
|
+
0,
|
|
190
|
+
-1,
|
|
191
|
+
0,
|
|
192
|
+
0,
|
|
193
|
+
-1,
|
|
194
|
+
0,
|
|
195
|
+
0,
|
|
196
|
+
-1,
|
|
197
|
+
0,
|
|
198
|
+
0,
|
|
199
|
+
-1,
|
|
200
|
+
0
|
|
201
|
+
] : null;
|
|
202
|
+
indices && indices.push(0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, 10, 11, 12, 13, 14, 12, 14, 15, 16, 17, 18, 16, 18, 19, 20, 21, 22, 20, 22, 23);
|
|
203
|
+
vertices && vertices.push(...topFacePos, ...frontFacePos, ...rightFacePos, ...backFacePos, ...leftFacePos, ...bottomFacePos);
|
|
204
|
+
needNormal && normals && normals.push(...topFacenormal, ...frontFaceNormal, ...rightFaceNormal, ...backFaceNormal, ...leftFaceNormal, ...bottomFaceNormal);
|
|
205
|
+
needUV && uvs && uvs.push(...uv, ...uv, ...uv, ...uv, ...uv, ...uv);
|
|
206
|
+
this.primitiveType = 'triangle-list';
|
|
207
|
+
}
|
|
208
|
+
/** @internal */ _create() {
|
|
209
|
+
const needNormal = this._options.needNormal;
|
|
210
|
+
const needUV = this._options.needUV;
|
|
211
|
+
const sizeX = this._options.sizeX ?? this._options.size ?? 1;
|
|
212
|
+
const sizeY = this._options.sizeY ?? this._options.size ?? 1;
|
|
213
|
+
const sizeZ = this._options.sizeZ ?? this._options.size ?? 1;
|
|
214
|
+
const anchorX = this._options.anchorX ?? 0;
|
|
215
|
+
const anchorY = this._options.anchorY ?? 0;
|
|
216
|
+
const anchorZ = this._options.anchorZ ?? 0;
|
|
217
|
+
const minx = -anchorX * sizeX;
|
|
218
|
+
const maxx = minx + sizeX;
|
|
219
|
+
const miny = -anchorY * sizeY;
|
|
220
|
+
const maxy = miny + sizeY;
|
|
221
|
+
const minz = -anchorZ * sizeZ;
|
|
222
|
+
const maxz = minz + sizeZ;
|
|
223
|
+
const vertices = [];
|
|
224
|
+
const indices = [];
|
|
225
|
+
const normals = needNormal ? [] : null;
|
|
226
|
+
const uvs = needUV ? [] : null;
|
|
227
|
+
this._createArrays(vertices, normals, uvs, indices, minx, miny, minz, maxx, maxy, maxz);
|
|
228
|
+
this.createAndSetVertexBuffer('position_f32x3', new Float32Array(vertices));
|
|
229
|
+
normals && this.createAndSetVertexBuffer('normal_f32x3', new Float32Array(normals));
|
|
230
|
+
uvs && this.createAndSetVertexBuffer('tex0_f32x2', new Float32Array(uvs));
|
|
231
|
+
this.createAndSetIndexBuffer(new Uint16Array(indices));
|
|
232
|
+
this.setBoundingVolume(new BoundingBox(new Vector3(minx, miny, minz), new Vector3(maxx, maxy, maxz)));
|
|
233
|
+
this.indexCount = indices.length;
|
|
234
|
+
return true;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Wireframe box shape
|
|
239
|
+
* @public
|
|
240
|
+
*/ class BoxFrameShape extends Shape {
|
|
241
|
+
/**
|
|
242
|
+
* Creates an instance of wireframe box shape
|
|
243
|
+
* @param options - The creation options
|
|
244
|
+
*/ constructor(options){
|
|
245
|
+
super(options);
|
|
246
|
+
}
|
|
247
|
+
/** @internal */ createDefaultOptions() {
|
|
248
|
+
const options = super.createDefaultOptions();
|
|
249
|
+
options.size = 1;
|
|
250
|
+
options.needNormal = false;
|
|
251
|
+
options.needTangent = false;
|
|
252
|
+
options.needUV = false;
|
|
253
|
+
return options;
|
|
254
|
+
}
|
|
255
|
+
/** @internal */ _createArrays(vertices, indices, minx, miny, minz, maxx, maxy, maxz) {
|
|
256
|
+
const topFacePos = [
|
|
257
|
+
minx,
|
|
258
|
+
maxy,
|
|
259
|
+
minz,
|
|
260
|
+
minx,
|
|
261
|
+
maxy,
|
|
262
|
+
maxz,
|
|
263
|
+
maxx,
|
|
264
|
+
maxy,
|
|
265
|
+
maxz,
|
|
266
|
+
maxx,
|
|
267
|
+
maxy,
|
|
268
|
+
minz
|
|
269
|
+
];
|
|
270
|
+
const bottomFacePos = [
|
|
271
|
+
minx,
|
|
272
|
+
miny,
|
|
273
|
+
maxz,
|
|
274
|
+
minx,
|
|
275
|
+
miny,
|
|
276
|
+
minz,
|
|
277
|
+
maxx,
|
|
278
|
+
miny,
|
|
279
|
+
minz,
|
|
280
|
+
maxx,
|
|
281
|
+
miny,
|
|
282
|
+
maxz
|
|
283
|
+
];
|
|
284
|
+
indices && indices.push(0, 1, 1, 2, 2, 3, 3, 0, 0, 5, 1, 4, 2, 7, 3, 6, 6, 5, 5, 4, 4, 7, 7, 6);
|
|
285
|
+
vertices && vertices.push(...topFacePos, ...bottomFacePos);
|
|
286
|
+
this.primitiveType = 'line-list';
|
|
287
|
+
}
|
|
288
|
+
/** @internal */ _create() {
|
|
289
|
+
const sizeX = this._options.sizeX ?? this._options.size ?? 1;
|
|
290
|
+
const sizeY = this._options.sizeY ?? this._options.size ?? 1;
|
|
291
|
+
const sizeZ = this._options.sizeZ ?? this._options.size ?? 1;
|
|
292
|
+
const anchorX = this._options.anchorX ?? 0;
|
|
293
|
+
const anchorY = this._options.anchorY ?? 0;
|
|
294
|
+
const anchorZ = this._options.anchorZ ?? 0;
|
|
295
|
+
const minx = -anchorX * sizeX;
|
|
296
|
+
const maxx = minx + sizeX;
|
|
297
|
+
const miny = -anchorY * sizeY;
|
|
298
|
+
const maxy = miny + sizeY;
|
|
299
|
+
const minz = -anchorZ * sizeZ;
|
|
300
|
+
const maxz = minz + sizeZ;
|
|
301
|
+
const vertices = [];
|
|
302
|
+
const indices = [];
|
|
303
|
+
this._createArrays(vertices, indices, minx, miny, minz, maxx, maxy, maxz);
|
|
304
|
+
this.createAndSetVertexBuffer('position_f32x3', new Float32Array(vertices));
|
|
305
|
+
this.createAndSetIndexBuffer(new Uint16Array(indices));
|
|
306
|
+
this.setBoundingVolume(new BoundingBox(new Vector3(minx, miny, minz), new Vector3(maxx, maxy, maxz)));
|
|
307
|
+
this.indexCount = indices.length;
|
|
308
|
+
return true;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export { BoxFrameShape, BoxShape };
|
|
313
|
+
//# sourceMappingURL=box.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"box.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Vector3 } from '@zephyr3d/base';
|
|
2
|
+
import { BoundingBox } from '../utility/bounding_volume.js';
|
|
3
|
+
import { Shape } from './shape.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Box shape
|
|
7
|
+
* @public
|
|
8
|
+
*/ class CylinderShape extends Shape {
|
|
9
|
+
/**
|
|
10
|
+
* Creates an instance of cylinder shape
|
|
11
|
+
* @param options - The creation options
|
|
12
|
+
*/ constructor(options){
|
|
13
|
+
super(options);
|
|
14
|
+
}
|
|
15
|
+
/** @internal */ createDefaultOptions() {
|
|
16
|
+
const options = super.createDefaultOptions();
|
|
17
|
+
options.topRadius = 1;
|
|
18
|
+
options.bottomRadius = 1;
|
|
19
|
+
options.heightDetail = 1;
|
|
20
|
+
options.radialDetail = 20;
|
|
21
|
+
options.height = 1;
|
|
22
|
+
options.anchorX = 0.5;
|
|
23
|
+
options.anchorY = 0;
|
|
24
|
+
options.anchorZ = 0.5;
|
|
25
|
+
return options;
|
|
26
|
+
}
|
|
27
|
+
/** @internal */ addPatch(x, y, indices) {
|
|
28
|
+
const stride = this._options.radialDetail + 1;
|
|
29
|
+
const lt = (y + 1) * stride + x;
|
|
30
|
+
const rt = lt + 1;
|
|
31
|
+
const lb = lt - stride;
|
|
32
|
+
const rb = lb + 1;
|
|
33
|
+
indices.push(lt, lb, rb, lt, rb, rt);
|
|
34
|
+
}
|
|
35
|
+
/** @internal */ _createArrays(vertices, normals, uvs, indices) {
|
|
36
|
+
const slope = (this._options.bottomRadius - this._options.topRadius) / this._options.height;
|
|
37
|
+
for(let y = 0; y <= this._options.heightDetail; y++){
|
|
38
|
+
const v = y / this._options.heightDetail;
|
|
39
|
+
const radius = (this._options.bottomRadius - this._options.topRadius) * v + this._options.topRadius;
|
|
40
|
+
for(let x = 0; x <= this._options.radialDetail; x++){
|
|
41
|
+
const u = x / this._options.radialDetail;
|
|
42
|
+
const theta = u * Math.PI * 2;
|
|
43
|
+
const sinTheta = Math.sin(theta);
|
|
44
|
+
const cosTheta = Math.cos(theta);
|
|
45
|
+
const m = 1 / Math.sqrt(sinTheta * sinTheta + slope * slope + cosTheta * cosTheta);
|
|
46
|
+
vertices.push(radius * sinTheta, v * this._options.height, radius * cosTheta);
|
|
47
|
+
normals.push(sinTheta * m, slope * m, cosTheta * m);
|
|
48
|
+
uvs.push(u, 1 - v);
|
|
49
|
+
if (y < this._options.heightDetail && x < this._options.radialDetail) {
|
|
50
|
+
this.addPatch(x, y, indices);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
this.primitiveType = 'triangle-list';
|
|
55
|
+
}
|
|
56
|
+
/** @internal */ _create() {
|
|
57
|
+
const vertices = [];
|
|
58
|
+
const indices = [];
|
|
59
|
+
const normals = [];
|
|
60
|
+
const uvs = [];
|
|
61
|
+
this._createArrays(vertices, normals, uvs, indices);
|
|
62
|
+
this.createAndSetVertexBuffer('position_f32x3', new Float32Array(vertices));
|
|
63
|
+
this.createAndSetVertexBuffer('normal_f32x3', new Float32Array(normals));
|
|
64
|
+
this.createAndSetVertexBuffer('tex0_f32x2', new Float32Array(uvs));
|
|
65
|
+
this.createAndSetIndexBuffer(new Uint16Array(indices));
|
|
66
|
+
const radiusMax = Math.max(this._options.topRadius, this._options.bottomRadius);
|
|
67
|
+
this.setBoundingVolume(new BoundingBox(new Vector3(-radiusMax, 0, -radiusMax), new Vector3(radiusMax, this._options.height, radiusMax)));
|
|
68
|
+
this.indexCount = indices.length;
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export { CylinderShape };
|
|
74
|
+
//# sourceMappingURL=cylinder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cylinder.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Vector3 } from '@zephyr3d/base';
|
|
2
|
+
import { BoundingBox } from '../utility/bounding_volume.js';
|
|
3
|
+
import { Shape } from './shape.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The plane shape
|
|
7
|
+
* @public
|
|
8
|
+
*/ class PlaneShape extends Shape {
|
|
9
|
+
/**
|
|
10
|
+
* Creates an instance of plane shape
|
|
11
|
+
* @param options - The creation options
|
|
12
|
+
*/ constructor(options){
|
|
13
|
+
super(options);
|
|
14
|
+
}
|
|
15
|
+
/** @internal */ createDefaultOptions() {
|
|
16
|
+
const options = super.createDefaultOptions();
|
|
17
|
+
options.size = 1;
|
|
18
|
+
return options;
|
|
19
|
+
}
|
|
20
|
+
/** @internal */ _createArrays(vertices, normals, uvs, indices, sizeX, sizeY) {
|
|
21
|
+
uvs?.push(0, 1, 0, 0, 1, 0, 1, 1);
|
|
22
|
+
vertices?.push(0, 0, sizeY, sizeX, 0, sizeY, sizeX, 0, 0, 0, 0, 0);
|
|
23
|
+
indices?.push(0, 1, 2, 0, 2, 3);
|
|
24
|
+
normals?.push(0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0);
|
|
25
|
+
this.primitiveType = 'triangle-list';
|
|
26
|
+
}
|
|
27
|
+
/** @internal */ _create() {
|
|
28
|
+
const needNormal = this._options.needNormal;
|
|
29
|
+
const needUV = this._options.needUV;
|
|
30
|
+
const sizeX = Math.abs(this._options.sizeX || this._options.size) || 1;
|
|
31
|
+
const sizeY = Math.abs(this._options.sizeY || this._options.size) || 1;
|
|
32
|
+
const vertices = [];
|
|
33
|
+
const indices = [];
|
|
34
|
+
const normals = needNormal ? [] : null;
|
|
35
|
+
const uvs = needUV ? [] : null;
|
|
36
|
+
this._createArrays(vertices, normals, uvs, indices, sizeX, sizeY);
|
|
37
|
+
this.createAndSetVertexBuffer('position_f32x3', new Float32Array(vertices));
|
|
38
|
+
normals && this.createAndSetVertexBuffer('normal_f32x3', new Float32Array(normals));
|
|
39
|
+
uvs && this.createAndSetVertexBuffer('tex0_f32x2', new Float32Array(uvs));
|
|
40
|
+
this.createAndSetIndexBuffer(new Uint16Array(indices));
|
|
41
|
+
this.setBoundingVolume(new BoundingBox(new Vector3(0, 0, 0), new Vector3(sizeX, 0, sizeY)));
|
|
42
|
+
this.indexCount = indices.length;
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { PlaneShape };
|
|
48
|
+
//# sourceMappingURL=plane.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plane.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Primitive } from '../render/primitive.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Abstract base class for any kind of shapes
|
|
5
|
+
* @public
|
|
6
|
+
*/ class Shape extends Primitive {
|
|
7
|
+
/** @internal */ _options;
|
|
8
|
+
/**
|
|
9
|
+
* Creates an instance of shape
|
|
10
|
+
* @param options - The creation options
|
|
11
|
+
*/ constructor(options){
|
|
12
|
+
super();
|
|
13
|
+
this._options = this.createDefaultOptions();
|
|
14
|
+
this.create(options);
|
|
15
|
+
}
|
|
16
|
+
/** @internal */ create(options) {
|
|
17
|
+
if (options) {
|
|
18
|
+
this._options = this.createDefaultOptions();
|
|
19
|
+
Object.assign(this._options, options);
|
|
20
|
+
}
|
|
21
|
+
return this._create();
|
|
22
|
+
}
|
|
23
|
+
/** @internal */ createDefaultOptions() {
|
|
24
|
+
return {
|
|
25
|
+
needNormal: true,
|
|
26
|
+
needTangent: false,
|
|
27
|
+
needUV: true
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { Shape };
|
|
33
|
+
//# sourceMappingURL=shape.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shape.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Vector3 } from '@zephyr3d/base';
|
|
2
|
+
import { BoundingBox } from '../utility/bounding_volume.js';
|
|
3
|
+
import { Shape } from './shape.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Sphere shape
|
|
7
|
+
* @public
|
|
8
|
+
*/ class SphereShape extends Shape {
|
|
9
|
+
/**
|
|
10
|
+
* Creates an instance of sphere shape
|
|
11
|
+
* @param options - The creation options
|
|
12
|
+
*/ constructor(options){
|
|
13
|
+
super(options);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* {@inheritDoc Primitive.raycast}
|
|
17
|
+
* @override
|
|
18
|
+
*/ raycast(ray) {
|
|
19
|
+
const rSquared = this._options.radius * this._options.radius;
|
|
20
|
+
const eSquared = Vector3.dot(ray.origin, ray.origin);
|
|
21
|
+
if (eSquared < rSquared) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const a = -Vector3.dot(ray.origin, ray.direction);
|
|
25
|
+
const bSquared = eSquared - a * a;
|
|
26
|
+
if (rSquared < bSquared) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return a - Math.sqrt(rSquared - bSquared);
|
|
30
|
+
}
|
|
31
|
+
/** @internal */ createDefaultOptions() {
|
|
32
|
+
const options = super.createDefaultOptions();
|
|
33
|
+
options.radius = 1;
|
|
34
|
+
options.verticalDetail = 20;
|
|
35
|
+
options.horizonalDetail = 20;
|
|
36
|
+
return options;
|
|
37
|
+
}
|
|
38
|
+
/** @internal */ _create() {
|
|
39
|
+
function getVertex(v, h, r) {
|
|
40
|
+
const y = r * Math.cos(v);
|
|
41
|
+
const hRadius = r * Math.sin(v);
|
|
42
|
+
const x = hRadius * Math.sin(h);
|
|
43
|
+
const z = hRadius * Math.cos(h);
|
|
44
|
+
return [
|
|
45
|
+
x,
|
|
46
|
+
y,
|
|
47
|
+
z
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
const radius = this._options.radius ?? 1;
|
|
51
|
+
const verticalDetail = this._options.verticalDetail ?? 20;
|
|
52
|
+
const horizonalDetail = this._options.horizonalDetail ?? 20;
|
|
53
|
+
const vTheta = Math.PI / verticalDetail;
|
|
54
|
+
const hTheta = Math.PI * 2 / horizonalDetail;
|
|
55
|
+
const vertices = [];
|
|
56
|
+
const normals = [];
|
|
57
|
+
const uv = [];
|
|
58
|
+
const indices = [];
|
|
59
|
+
for(let i = 0; i <= verticalDetail; i++){
|
|
60
|
+
for(let j = 0; j <= horizonalDetail; j++){
|
|
61
|
+
const v = getVertex(i * vTheta, j * hTheta, radius);
|
|
62
|
+
vertices.push(...v);
|
|
63
|
+
if (this._options.needUV) {
|
|
64
|
+
uv.push(j / horizonalDetail, i / verticalDetail);
|
|
65
|
+
}
|
|
66
|
+
if (this._options.needNormal) {
|
|
67
|
+
normals.push(v[0] / radius, v[1] / radius, v[2] / radius);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
for(let i = 0; i < verticalDetail; i++){
|
|
72
|
+
for(let j = 0; j <= horizonalDetail; j++){
|
|
73
|
+
const startIndex = i * (horizonalDetail + 1);
|
|
74
|
+
indices.push(startIndex + j, startIndex + j + horizonalDetail + 1);
|
|
75
|
+
}
|
|
76
|
+
indices.push(indices[indices.length - 1]);
|
|
77
|
+
indices.push((i + 1) * (horizonalDetail + 1));
|
|
78
|
+
}
|
|
79
|
+
this.createAndSetVertexBuffer('position_f32x3', new Float32Array(vertices));
|
|
80
|
+
normals?.length > 0 && this.createAndSetVertexBuffer('normal_f32x3', new Float32Array(normals));
|
|
81
|
+
uv?.length > 0 && this.createAndSetVertexBuffer('tex0_f32x2', new Float32Array(uv));
|
|
82
|
+
this.createAndSetIndexBuffer(new Uint32Array(indices));
|
|
83
|
+
this.setBoundingVolume(new BoundingBox(new Vector3(-radius, -radius, -radius), new Vector3(radius, radius, radius)));
|
|
84
|
+
this.primitiveType = 'triangle-strip';
|
|
85
|
+
this.indexCount = indices.length;
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export { SphereShape };
|
|
91
|
+
//# sourceMappingURL=sphere.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sphere.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Vector3 } from '@zephyr3d/base';
|
|
2
|
+
import { BoundingBox } from '../utility/bounding_volume.js';
|
|
3
|
+
import { Shape } from './shape.js';
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
N slices
|
|
7
|
+
M sides
|
|
8
|
+
OR outter radius
|
|
9
|
+
IR inner radius
|
|
10
|
+
Up (0, 1, 0)
|
|
11
|
+
|
|
12
|
+
C(n) = (cos((n/N) * TwoPI) * OR, 0, sin((n/N) * twoPI * OR);
|
|
13
|
+
Theta = m/M * TwoPI
|
|
14
|
+
V(n, m) = C(n) * (1 + IR * cos(Theta) / OR) + Up * IR * sin(Theta)
|
|
15
|
+
N(n, m) = normalize(V(n, m) - C(n))
|
|
16
|
+
TC(n, m) = (m / M, n / N)
|
|
17
|
+
|
|
18
|
+
VIndex(n, m) = n * (M + 1) + m
|
|
19
|
+
Triangle(n, m) = (VIndex(n, m), VIndex(n+1, m), VIndex(n+1, m+1), VIndex(n, m), VIndex(n+1, m+1), VIndex(n, m+1))*/ /**
|
|
20
|
+
*
|
|
21
|
+
* Torus shape
|
|
22
|
+
*
|
|
23
|
+
* @public
|
|
24
|
+
*/ class TorusShape extends Shape {
|
|
25
|
+
/**
|
|
26
|
+
* Creates an instance of torus shape
|
|
27
|
+
* @param options - The creation options
|
|
28
|
+
*/ constructor(options){
|
|
29
|
+
super(options);
|
|
30
|
+
}
|
|
31
|
+
/** @internal */ createDefaultOptions() {
|
|
32
|
+
const options = super.createDefaultOptions();
|
|
33
|
+
options.numSlices = 40;
|
|
34
|
+
options.numSegments = 16;
|
|
35
|
+
options.outerRadius = 10;
|
|
36
|
+
options.innerRadius = 3;
|
|
37
|
+
options.radialDetail = 20;
|
|
38
|
+
return options;
|
|
39
|
+
}
|
|
40
|
+
/** @internal */ _createArrays(vertices, normals, uvs, indices) {
|
|
41
|
+
this.primitiveType = 'triangle-list';
|
|
42
|
+
const N = this._options.numSlices;
|
|
43
|
+
const M = this._options.numSegments;
|
|
44
|
+
const OR = this._options.outerRadius;
|
|
45
|
+
const IR = this._options.innerRadius;
|
|
46
|
+
for(let n = 0; n <= N; n++){
|
|
47
|
+
const alpha = n % N / N * Math.PI * 2;
|
|
48
|
+
const cx = OR * Math.cos(alpha);
|
|
49
|
+
const cy = 0;
|
|
50
|
+
const cz = OR * Math.sin(alpha);
|
|
51
|
+
for(let m = 0; m <= M; m++){
|
|
52
|
+
const theta = m % M / M * Math.PI * 2;
|
|
53
|
+
const idx = n * (M + 1) + m;
|
|
54
|
+
const t = 1 + IR * Math.cos(theta) / OR;
|
|
55
|
+
const s = IR * Math.sin(theta);
|
|
56
|
+
vertices[idx * 3 + 0] = cx * t;
|
|
57
|
+
vertices[idx * 3 + 1] = cy * t + s;
|
|
58
|
+
vertices[idx * 3 + 2] = cz * t;
|
|
59
|
+
const nx = vertices[idx * 3 + 0] - cx;
|
|
60
|
+
const ny = vertices[idx * 3 + 1] - cy;
|
|
61
|
+
const nz = vertices[idx * 3 + 2] - cz;
|
|
62
|
+
const mag = Math.sqrt(nx * nx + ny * ny + nz * nz);
|
|
63
|
+
normals[idx * 3 + 0] = nx / mag;
|
|
64
|
+
normals[idx * 3 + 1] = ny / mag;
|
|
65
|
+
normals[idx * 3 + 2] = nz / mag;
|
|
66
|
+
uvs[idx * 2 + 0] = m / M;
|
|
67
|
+
uvs[idx * 2 + 1] = n / N;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
for(let n = 0; n < N; n++){
|
|
71
|
+
for(let m = 0; m < M; m++){
|
|
72
|
+
indices.push(n * (M + 1) + m);
|
|
73
|
+
indices.push((n + 1) * (M + 1) + m + 1);
|
|
74
|
+
indices.push((n + 1) * (M + 1) + m);
|
|
75
|
+
indices.push(n * (M + 1) + m);
|
|
76
|
+
indices.push(n * (M + 1) + m + 1);
|
|
77
|
+
indices.push((n + 1) * (M + 1) + m + 1);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/** @internal */ _create() {
|
|
82
|
+
const vertices = [];
|
|
83
|
+
const indices = [];
|
|
84
|
+
const normals = [];
|
|
85
|
+
const uvs = [];
|
|
86
|
+
this._createArrays(vertices, normals, uvs, indices);
|
|
87
|
+
this.createAndSetVertexBuffer('position_f32x3', new Float32Array(vertices));
|
|
88
|
+
this.createAndSetVertexBuffer('normal_f32x3', new Float32Array(normals));
|
|
89
|
+
this.createAndSetVertexBuffer('tex0_f32x2', new Float32Array(uvs));
|
|
90
|
+
this.createAndSetIndexBuffer(new Uint16Array(indices));
|
|
91
|
+
const radiusX = this._options.outerRadius + this._options.innerRadius;
|
|
92
|
+
const radiusY = this._options.innerRadius;
|
|
93
|
+
this.setBoundingVolume(new BoundingBox(new Vector3(-radiusX, -radiusY, -radiusX), new Vector3(radiusX, radiusY, radiusX)));
|
|
94
|
+
this.indexCount = indices.length;
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export { TorusShape };
|
|
100
|
+
//# sourceMappingURL=torus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"torus.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|