@xort/cga 0.0.93 → 0.1.1
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/THIRD_PARTY_NOTICES.md +76 -0
- package/build/@xort_cga.js +20213 -12091
- package/build/cga.d.ts +3151 -2032
- package/build/cga.esm.js +20175 -0
- package/{src/shader → build/shaders}/cga.glsl +204 -202
- package/build/shaders/common.glsl +36 -0
- package/{src/shader → build/shaders}/noise/GLSL-Noise.md +1108 -1108
- package/build/shaders/noise/LICENSE +20 -0
- package/build/shaders/noise/cellular2D.glsl +69 -0
- package/{src/shader → build/shaders}/noise/cellular2x2.glsl +64 -64
- package/build/shaders/noise/cellular2x2x2.glsl +88 -0
- package/build/shaders/noise/cellular3D.glsl +187 -0
- package/{src/shader → build/shaders}/noise/classicnoise2D.glsl +113 -113
- package/{src/shader → build/shaders}/noise/classicnoise3D.glsl +177 -177
- package/{src/shader → build/shaders}/noise/classicnoise4D.glsl +302 -302
- package/{src/shader → build/shaders}/noise/noise2D.glsl +71 -71
- package/{src/shader → build/shaders}/noise/noise3D.glsl +103 -103
- package/{src/shader → build/shaders}/noise/noise3Dgrad.glsl +111 -111
- package/{src/shader → build/shaders}/noise/noise4D.glsl +129 -129
- package/{src/shader → build/shaders}/noise/psrdnoise2D.glsl +463 -462
- package/dist/THIRD_PARTY_NOTICES.md +76 -0
- package/dist/index.cjs +20352 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +3176 -0
- package/dist/index.d.ts +3176 -38
- package/dist/index.js +20177 -56
- package/dist/index.js.map +1 -0
- package/dist/shaders.cjs +21 -0
- package/dist/shaders.d.cts +20 -0
- package/dist/shaders.d.ts +20 -0
- package/dist/shaders.js +20 -0
- package/dist/three.cjs +3034 -0
- package/dist/three.cjs.map +1 -0
- package/dist/three.d.cts +308 -0
- package/dist/three.d.ts +308 -0
- package/dist/three.js +3007 -0
- package/dist/three.js.map +1 -0
- package/package.json +96 -47
- package/readme.md +111 -247
- package/.github/FUNDING.yml +0 -12
- package/cga/1./347/202/271/344/270/216/347/272/277/346/200/247/345/205/203/347/264/240/347/232/204/350/267/235/347/246/273.html +0 -601
- package/cga/1./347/202/271/344/270/216/347/272/277/346/200/247/345/205/203/347/264/240/347/232/204/350/267/235/347/246/273.md +0 -111
- package/cga/2./347/202/271/344/270/216/351/235/242/346/200/247/345/205/203/347/264/240.md +0 -4
- package/cga/img//347/202/271/344/270/216/345/260/204/347/272/277.png +0 -0
- package/cga/img//347/202/271/344/270/216/347/233/264/347/272/277.png +0 -0
- package/cga/img//347/202/271/344/270/216/347/272/277/346/256/265.png +0 -0
- package/cga/img//347/233/264/347/272/277/347/232/204/350/241/250/350/276/276/345/274/217.png +0 -0
- package/deploy.sh +0 -39
- package/dist/IKanimation/Bone.d.ts +0 -7
- package/dist/IKanimation/Bone.js +0 -20
- package/dist/IKanimation/CCDSolver.d.ts +0 -37
- package/dist/IKanimation/CCDSolver.js +0 -93
- package/dist/IKanimation/Joint.d.ts +0 -3
- package/dist/IKanimation/Joint.js +0 -17
- package/dist/IKanimation/constaint/constraint.d.ts +0 -10
- package/dist/IKanimation/constaint/constraint.js +0 -25
- package/dist/IKanimation/constaint/hinge.d.ts +0 -12
- package/dist/IKanimation/constaint/hinge.js +0 -46
- package/dist/IKanimation/constaint/slider.d.ts +0 -12
- package/dist/IKanimation/constaint/slider.js +0 -44
- package/dist/IKanimation/index.d.ts +0 -0
- package/dist/IKanimation/index.js +0 -9
- package/dist/IKanimation/isolver.d.ts +0 -4
- package/dist/IKanimation/isolver.js +0 -10
- package/dist/IKanimation/skeleton.d.ts +0 -13
- package/dist/IKanimation/skeleton.js +0 -31
- package/dist/alg/common.d.ts +0 -114
- package/dist/alg/common.js +0 -302
- package/dist/alg/curve.d.ts +0 -4
- package/dist/alg/curve.js +0 -11
- package/dist/alg/delaunator.d.ts +0 -29
- package/dist/alg/delaunator.js +0 -442
- package/dist/alg/delaunay.d.ts +0 -20
- package/dist/alg/delaunay.js +0 -199
- package/dist/alg/delaunayslow.d.ts +0 -18
- package/dist/alg/delaunayslow.js +0 -140
- package/dist/alg/extrude/extrude.d.ts +0 -3
- package/dist/alg/extrude/extrude.js +0 -17
- package/dist/alg/extrude.d.ts +0 -199
- package/dist/alg/extrude.js +0 -728
- package/dist/alg/offset/index.d.ts +0 -0
- package/dist/alg/offset/index.js +0 -9
- package/dist/alg/offset.d.ts +0 -0
- package/dist/alg/offset.js +0 -472
- package/dist/alg/pointset.d.ts +0 -94
- package/dist/alg/pointset.js +0 -223
- package/dist/alg/recognition.d.ts +0 -14
- package/dist/alg/recognition.js +0 -37
- package/dist/alg/result.d.ts +0 -22
- package/dist/alg/result.js +0 -2
- package/dist/alg/segmentset.d.ts +0 -11
- package/dist/alg/segmentset.js +0 -45
- package/dist/alg/sort.d.ts +0 -2
- package/dist/alg/sort.js +0 -14
- package/dist/alg/split.d.ts +0 -8
- package/dist/alg/split.js +0 -10
- package/dist/alg/trianglution.d.ts +0 -15
- package/dist/alg/trianglution.js +0 -70
- package/dist/alg/vol.d.ts +0 -6
- package/dist/alg/vol.js +0 -18
- package/dist/alg/voronoi.d.ts +0 -31
- package/dist/alg/voronoi.js +0 -418
- package/dist/app.d.ts +0 -1
- package/dist/app.js +0 -248
- package/dist/basic/distance.d.ts +0 -12
- package/dist/basic/distance.js +0 -39
- package/dist/csg/bsp.d.ts +0 -9
- package/dist/csg/bsp.js +0 -22
- package/dist/csg/node.d.ts +0 -12
- package/dist/csg/node.js +0 -75
- package/dist/csg/polygon.d.ts +0 -43
- package/dist/csg/polygon.js +0 -161
- package/dist/diamondMaterialShader.d.ts +0 -92
- package/dist/diamondMaterialShader.js +0 -118
- package/dist/effect/breath-light.d.ts +0 -4
- package/dist/effect/breath-light.js +0 -39
- package/dist/extends/geometryaid.d.ts +0 -28
- package/dist/extends/geometryaid.js +0 -71
- package/dist/extends/split.d.ts +0 -3
- package/dist/extends/split.js +0 -13
- package/dist/glview.d.ts +0 -112
- package/dist/glview.js +0 -564
- package/dist/math/Color.d.ts +0 -33
- package/dist/math/Color.js +0 -235
- package/dist/math/Euler.d.ts +0 -46
- package/dist/math/Euler.js +0 -225
- package/dist/math/HVec3.d.ts +0 -43
- package/dist/math/HVec3.js +0 -176
- package/dist/math/Mat3.d.ts +0 -29
- package/dist/math/Mat3.js +0 -244
- package/dist/math/Mat4.d.ts +0 -85
- package/dist/math/Mat4.js +0 -791
- package/dist/math/Math.d.ts +0 -130
- package/dist/math/Math.js +0 -198
- package/dist/math/Quat.d.ts +0 -82
- package/dist/math/Quat.js +0 -418
- package/dist/math/Vec2.d.ts +0 -68
- package/dist/math/Vec2.js +0 -328
- package/dist/math/Vec3.d.ts +0 -240
- package/dist/math/Vec3.js +0 -1082
- package/dist/math/Vec4.d.ts +0 -81
- package/dist/math/Vec4.js +0 -475
- package/dist/math/vecs.d.ts +0 -134
- package/dist/math/vecs.js +0 -464
- package/dist/render/bufferAttribute.d.ts +0 -104
- package/dist/render/bufferAttribute.js +0 -344
- package/dist/render/geometry.d.ts +0 -87
- package/dist/render/geometry.js +0 -769
- package/dist/render/mesh.d.ts +0 -30
- package/dist/render/mesh.js +0 -87
- package/dist/render/types.d.ts +0 -3
- package/dist/render/types.js +0 -8
- package/dist/robust/plane.d.ts +0 -7
- package/dist/robust/plane.js +0 -17
- package/dist/robust/vec.d.ts +0 -15
- package/dist/robust/vec.js +0 -71
- package/dist/struct/3d/Box.d.ts +0 -23
- package/dist/struct/3d/Box.js +0 -109
- package/dist/struct/3d/Capsule.d.ts +0 -12
- package/dist/struct/3d/Capsule.js +0 -36
- package/dist/struct/3d/Circle.d.ts +0 -52
- package/dist/struct/3d/Circle.js +0 -138
- package/dist/struct/3d/Disk.d.ts +0 -10
- package/dist/struct/3d/Disk.js +0 -22
- package/dist/struct/3d/Frustum.d.ts +0 -35
- package/dist/struct/3d/Frustum.js +0 -159
- package/dist/struct/3d/Line.d.ts +0 -40
- package/dist/struct/3d/Line.js +0 -340
- package/dist/struct/3d/Path.d.ts +0 -75
- package/dist/struct/3d/Path.js +0 -308
- package/dist/struct/3d/Plane.d.ts +0 -74
- package/dist/struct/3d/Plane.js +0 -298
- package/dist/struct/3d/Point.d.ts +0 -4
- package/dist/struct/3d/Point.js +0 -30
- package/dist/struct/3d/Polygon.d.ts +0 -8
- package/dist/struct/3d/Polygon.js +0 -55
- package/dist/struct/3d/Polyline.d.ts +0 -34
- package/dist/struct/3d/Polyline.js +0 -130
- package/dist/struct/3d/Ray.d.ts +0 -21
- package/dist/struct/3d/Ray.js +0 -262
- package/dist/struct/3d/Rectangle.d.ts +0 -7
- package/dist/struct/3d/Rectangle.js +0 -35
- package/dist/struct/3d/Segment.d.ts +0 -32
- package/dist/struct/3d/Segment.js +0 -334
- package/dist/struct/3d/Shape.d.ts +0 -4
- package/dist/struct/3d/Shape.js +0 -27
- package/dist/struct/3d/Sphere.d.ts +0 -11
- package/dist/struct/3d/Sphere.js +0 -30
- package/dist/struct/3d/Triangle.d.ts +0 -8
- package/dist/struct/3d/Triangle.js +0 -53
- package/dist/struct/bsp.d.ts +0 -9
- package/dist/struct/bsp.js +0 -44
- package/dist/struct/btree.d.ts +0 -0
- package/dist/struct/btree.js +0 -1
- package/dist/struct/data/ArrayList.d.ts +0 -42
- package/dist/struct/data/ArrayList.js +0 -172
- package/dist/struct/data/ArrayObject.d.ts +0 -30
- package/dist/struct/data/ArrayObject.js +0 -131
- package/dist/struct/data/type.d.ts +0 -13
- package/dist/struct/data/type.js +0 -18
- package/dist/struct/kdtree.d.ts +0 -0
- package/dist/struct/kdtree.js +0 -1
- package/dist/struct/polyTree.d.ts +0 -4
- package/dist/struct/polyTree.js +0 -27
- package/dist/struct/quatTree.d.ts +0 -0
- package/dist/struct/quatTree.js +0 -1
- package/dist/struct/tree.d.ts +0 -11
- package/dist/struct/tree.js +0 -26
- package/dist/utils/array.d.ts +0 -24
- package/dist/utils/array.js +0 -89
- package/dist/utils/types.d.ts +0 -24
- package/dist/utils/types.js +0 -20
- package/docs/.vuepress/components/distance.vue +0 -125
- package/docs/.vuepress/components/intersect.vue +0 -0
- package/docs/.vuepress/components/trianglution.vue +0 -121
- package/docs/.vuepress/components/utils.js +0 -314
- package/docs/.vuepress/config.js +0 -99
- package/docs/.vuepress/enhanceApp.js +0 -13
- package/docs/.vuepress/public/delaunay.png +0 -0
- package/docs/.vuepress/public/logo.png +0 -0
- package/docs/.vuepress/public/plane-set-convex.png +0 -0
- package/docs/.vuepress/public/sponsor/alipay.jpg +0 -0
- package/docs/.vuepress/public/sponsor/wechat.png +0 -0
- package/docs/README.md +0 -14
- package/docs/demo/README.md +0 -9
- package/docs/guide/README.md +0 -94
- package/docs/guide/array.md +0 -10
- package/docs/guide/cy/trianglution.html +0 -2
- package/docs/guide/distLineAll.md +0 -85
- package/docs/guide/distPointAll.md +0 -137
- package/docs/guide/distRayAll.md +0 -69
- package/docs/guide/distSegmentAll.md +0 -19
- package/docs/guide/point.vue +0 -12
- package/docs/guide/vector.md +0 -10
- package/docs/guide//345/270/270/347/224/250.md +0 -156
- package/docs/sponsor/README.md +0 -15
- package/docs//345/274/200/345/217/221/346/227/245/345/277/227/2020/345/271/2643/346/234/21013/346/227/245.md +0 -6
- package/effect/common.glsl +0 -34
- package/effect/drawing.glsl +0 -36
- package/effect/shape.arc.glsl +0 -13
- package/effect/shape.circle.glsl +0 -13
- package/effect/shape.grid.glsl +0 -42
- package/effect/shape.line.glsl +0 -18
- package/effect/shape.pie.glsl +0 -18
- package/effect/shape.plot.glsl +0 -10
- package/effect/shape.poly.glsl +0 -15
- package/effect/shape.rect.glsl +0 -14
- package/effect/shape.rectround.glsl +0 -15
- package/effect/shape.segment.glsl +0 -10
- package/effect/shape.spiral.glsl +0 -12
- package/effect/shape.star.glsl +0 -16
- package/examples/index.html +0 -31
- package/git.sh +0 -12
- package/gitproxy.sh +0 -6
- package/image/readme/1640758500266.png +0 -0
- package/image/readme/1640758513361.png +0 -0
- package/index.html +0 -14
- package/linear algorithm//346/225/260/345/255/246/350/241/250/350/276/276/345/274/217.md" +0 -122
- package/linear algorithm//347/237/251/351/230/265.md" +0 -91
- package/rollup.config.js +0 -82
- package/scripttest.html +0 -23
- package/src/IKanimation/Bone.ts +0 -20
- package/src/IKanimation/CCDSolver.ts +0 -114
- package/src/IKanimation/Joint.ts +0 -13
- package/src/IKanimation/constaint/constraint.ts +0 -23
- package/src/IKanimation/constaint/hinge.ts +0 -29
- package/src/IKanimation/constaint/slider.ts +0 -25
- package/src/IKanimation/index.ts +0 -8
- package/src/IKanimation/isolver.ts +0 -13
- package/src/IKanimation/skeleton.ts +0 -30
- package/src/alg/common.ts +0 -304
- package/src/alg/curve.ts +0 -9
- package/src/alg/delaunator.ts +0 -519
- package/src/alg/delaunay.ts +0 -163
- package/src/alg/delaunayslow.ts +0 -183
- package/src/alg/extrude/extrude.ts +0 -19
- package/src/alg/extrude.ts +0 -941
- package/src/alg/offset/index.ts +0 -8
- package/src/alg/offset.ts +0 -501
- package/src/alg/pointset.ts +0 -219
- package/src/alg/recognition.ts +0 -43
- package/src/alg/result.ts +0 -24
- package/src/alg/segmentset.ts +0 -44
- package/src/alg/sort.ts +0 -11
- package/src/alg/split.ts +0 -15
- package/src/alg/trianglution.ts +0 -53
- package/src/alg/vol.ts +0 -18
- package/src/alg/voronoi.ts +0 -303
- package/src/app.css +0 -12
- package/src/app.ts +0 -285
- package/src/assets/color.jpg +0 -0
- package/src/basic/distance.ts +0 -40
- package/src/clipper/clipper.d.ts +0 -323
- package/src/clipper/clipper.js +0 -7626
- package/src/clipper/clipper_float.js +0 -185
- package/src/clipper/clipper_float_unminified.js +0 -5639
- package/src/clipper/clipperint.js +0 -7626
- package/src/csg/bsp.ts +0 -24
- package/src/csg/csg.js +0 -583
- package/src/csg/node.ts +0 -91
- package/src/csg/polygon.ts +0 -177
- package/src/diamondMaterialShader.ts +0 -93
- package/src/effect/breath-light.ts +0 -24
- package/src/extends/geometryaid.ts +0 -86
- package/src/extends/split.ts +0 -15
- package/src/glview.ts +0 -570
- package/src/index.ts +0 -47
- package/src/math/Color.ts +0 -225
- package/src/math/Euler.ts +0 -238
- package/src/math/HVec3.ts +0 -1144
- package/src/math/Mat3.ts +0 -365
- package/src/math/Mat4.ts +0 -1134
- package/src/math/Math.ts +0 -213
- package/src/math/Quat.ts +0 -536
- package/src/math/Vec2.ts +0 -408
- package/src/math/Vec3.ts +0 -1307
- package/src/math/Vec4.ts +0 -587
- package/src/math/vecs.ts +0 -486
- package/src/render/bufferAttribute.ts +0 -491
- package/src/render/geometry.ts +0 -1329
- package/src/render/mesh.ts +0 -82
- package/src/render/types.ts +0 -17
- package/src/robust/plane.ts +0 -12
- package/src/robust/readme.md +0 -1
- package/src/robust/vec.ts +0 -61
- package/src/shader/common.glsl +0 -87
- package/src/shader/noise/cellular2D.glsl +0 -69
- package/src/shader/noise/cellular2x2x2.glsl +0 -88
- package/src/shader/noise/cellular3D.glsl +0 -187
- package/src/struct/3d/Box.ts +0 -124
- package/src/struct/3d/Capsule.ts +0 -18
- package/src/struct/3d/Circle.ts +0 -149
- package/src/struct/3d/Disk.ts +0 -22
- package/src/struct/3d/Frustum.ts +0 -189
- package/src/struct/3d/Line.ts +0 -378
- package/src/struct/3d/Path.ts +0 -314
- package/src/struct/3d/Plane.ts +0 -341
- package/src/struct/3d/Point.ts +0 -7
- package/src/struct/3d/PolyLine.ts +0 -115
- package/src/struct/3d/Polygon.ts +0 -46
- package/src/struct/3d/Ray.ts +0 -285
- package/src/struct/3d/Rectangle.ts +0 -18
- package/src/struct/3d/Segment.ts +0 -330
- package/src/struct/3d/Shape.ts +0 -7
- package/src/struct/3d/Sphere.ts +0 -31
- package/src/struct/3d/Triangle.ts +0 -28
- package/src/struct/bsp.ts +0 -18
- package/src/struct/btree.ts +0 -0
- package/src/struct/data/ArrayList.ts +0 -144
- package/src/struct/data/ArrayObject.ts +0 -105
- package/src/struct/data/type.ts +0 -14
- package/src/struct/kdtree.ts +0 -0
- package/src/struct/polyTree.ts +0 -8
- package/src/struct/quatTree.ts +0 -0
- package/src/struct/tree.ts +0 -30
- package/src/utils/array.ts +0 -106
- package/src/utils/types.ts +0 -42
- package/src-gis/app.ts +0 -7
- package/src-gis/core/Cartographic.ts +0 -48
- package/src-gis/core/EllipsoidGeodesic.ts +0 -56
- package/src-gis/core/EllipsoidTerrainProvider.ts +0 -35
- package/src-gis/core/HeightmapTerrainData.ts +0 -5
- package/src-gis/core/Rectangle.ts +0 -112
- package/src-gis/core/TaskProcessor.ts +0 -222
- package/src-gis/gis.ts +0 -25
- package/src-gis/globe.ts +0 -54
- package/src-gis/math/Cartographic.ts +0 -24
- package/src-gis/math/GVec3.ts +0 -55
- package/src-gis/math/ellipsoid.ts +0 -13
- package/src-gis/provider/DcTerrainProvider.ts +0 -36
- package/src-gis/provider/TerrainProvider.ts +0 -12
- package/src-gis/scene/DcImageryProvider.ts +0 -36
- package/src-gis/scene/GeographicTilingScheme.ts +0 -65
- package/src-gis/scene/Globe.ts +0 -76
- package/src-gis/scene/GlobeSurfaceShaderSet.ts +0 -9
- package/src-gis/scene/GlobeSurfaceTileProvider.ts +0 -25
- package/src-gis/scene/ImageryLayerCollection.ts +0 -75
- package/src-gis/scene/ImageryProvider.ts +0 -28
- package/src-gis/scene/QuadtreeTile.ts +0 -162
- package/src-gis/scene/UrlTemplateImageryProvider.ts +0 -32
- package/src-gis/scene/quadtree_primitive.ts +0 -58
- package/tsconfig.json +0 -77
- package/webpack.config.js +0 -112
- package//350/256/241/347/256/227/345/207/240/344/275/225/351/227/256/351/242/230.md +0 -26
package/dist/render/geometry.js
DELETED
|
@@ -1,769 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BufferGeometry = void 0;
|
|
4
|
-
var Mat3_1 = require("../math/Mat3");
|
|
5
|
-
var Mat4_1 = require("../math/Mat4");
|
|
6
|
-
var Vec3_1 = require("../math/Vec3");
|
|
7
|
-
var Box_1 = require("../struct/3d/Box");
|
|
8
|
-
var Sphere_1 = require("../struct/3d/Sphere");
|
|
9
|
-
var bufferAttribute_1 = require("./bufferAttribute");
|
|
10
|
-
var types_1 = require("./types");
|
|
11
|
-
var Vec2_1 = require("../math/Vec2");
|
|
12
|
-
var Vec4_1 = require("../math/Vec4");
|
|
13
|
-
var vecs_1 = require("../math/vecs");
|
|
14
|
-
var _bufferGeometryId = 1; // BufferGeometry uses odd numbers as Id
|
|
15
|
-
var _m1 = new Mat4_1.Mat4();
|
|
16
|
-
var _offset = new Vec3_1.Vec3();
|
|
17
|
-
var _box = new Box_1.Box();
|
|
18
|
-
var _boxMorphTargets = new Box_1.Box();
|
|
19
|
-
var _vector = new Vec3_1.Vec3();
|
|
20
|
-
/**
|
|
21
|
-
* BufferType 几何体,用于独立计算几何体
|
|
22
|
-
*/
|
|
23
|
-
var BufferGeometry = /** @class */ (function () {
|
|
24
|
-
function BufferGeometry() {
|
|
25
|
-
this.isBufferGeometry = true;
|
|
26
|
-
Object.defineProperty(this, 'id', { value: _bufferGeometryId += 1 });
|
|
27
|
-
this.name = '';
|
|
28
|
-
this.attributes = {};
|
|
29
|
-
this.morphAttributes = {};
|
|
30
|
-
this.morphTargetsRelative = false;
|
|
31
|
-
this.groups = [];
|
|
32
|
-
this.drawRange = { start: 0, count: Infinity };
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* 转化成BufferArray来计算
|
|
36
|
-
* @param geo
|
|
37
|
-
*/
|
|
38
|
-
BufferGeometry.prototype.setFromGeometry = function (geo) {
|
|
39
|
-
this.setAttribute('position', new bufferAttribute_1.Float32BufferAttribute(geo.position, 3));
|
|
40
|
-
if (geo.uv)
|
|
41
|
-
this.setAttribute('uv', new bufferAttribute_1.Float32BufferAttribute(geo.uv, 2));
|
|
42
|
-
if (geo.index)
|
|
43
|
-
this.setIndex(geo.index);
|
|
44
|
-
return this;
|
|
45
|
-
};
|
|
46
|
-
BufferGeometry.prototype.getIndex = function () {
|
|
47
|
-
return this.index;
|
|
48
|
-
};
|
|
49
|
-
BufferGeometry.prototype.setIndex = function (index) {
|
|
50
|
-
if (Array.isArray(index)) {
|
|
51
|
-
this.index = new (vecs_1.vecs.max(index) > 65535 ? bufferAttribute_1.Uint32BufferAttribute : bufferAttribute_1.Uint16BufferAttribute)(index, 1);
|
|
52
|
-
}
|
|
53
|
-
else if (index instanceof bufferAttribute_1.BufferAttribute) {
|
|
54
|
-
this.index = index;
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
this.index = new (vecs_1.vecs.max(index) > 65535 ? bufferAttribute_1.Uint32BufferAttribute : bufferAttribute_1.Uint16BufferAttribute)(index, 1);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
BufferGeometry.prototype.getAttribute = function (name) {
|
|
61
|
-
return this.attributes[name];
|
|
62
|
-
};
|
|
63
|
-
BufferGeometry.prototype.setAttribute = function (name, attribute) {
|
|
64
|
-
this.attributes[name] = attribute;
|
|
65
|
-
return this;
|
|
66
|
-
};
|
|
67
|
-
BufferGeometry.prototype.addAttribute = function (name, attribute, itemSize) {
|
|
68
|
-
if (itemSize === void 0) { itemSize = 1; }
|
|
69
|
-
if (Array.isArray(attribute)) {
|
|
70
|
-
if (attribute[0] instanceof Vec2_1.Vec2) {
|
|
71
|
-
var nums = vecs_1.vecs.verctorToNumbers(attribute);
|
|
72
|
-
this.setAttribute(name, new bufferAttribute_1.Float32BufferAttribute(nums, 2));
|
|
73
|
-
}
|
|
74
|
-
else if (attribute[0] instanceof Vec3_1.Vec3) {
|
|
75
|
-
var nums = vecs_1.vecs.verctorToNumbers(attribute);
|
|
76
|
-
this.setAttribute(name, new bufferAttribute_1.Float32BufferAttribute(nums, 3));
|
|
77
|
-
}
|
|
78
|
-
else if (attribute[0] instanceof Vec4_1.Vec4) {
|
|
79
|
-
var nums = vecs_1.vecs.verctorToNumbers(attribute);
|
|
80
|
-
this.setAttribute(name, new bufferAttribute_1.Float32BufferAttribute(nums, 4));
|
|
81
|
-
}
|
|
82
|
-
else if (!isNaN(attribute[0])) {
|
|
83
|
-
this.setAttribute(name, new bufferAttribute_1.Float32BufferAttribute(attribute, itemSize));
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
console.error("类型不存在");
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
else if (attribute instanceof bufferAttribute_1.BufferAttribute) {
|
|
90
|
-
this.attributes[name] = attribute;
|
|
91
|
-
}
|
|
92
|
-
else if ((0, types_1.isBufferArray)(attribute)) {
|
|
93
|
-
this.setAttribute(name, new bufferAttribute_1.BufferAttribute(attribute, itemSize));
|
|
94
|
-
}
|
|
95
|
-
return this;
|
|
96
|
-
};
|
|
97
|
-
BufferGeometry.prototype.deleteAttribute = function (name) {
|
|
98
|
-
delete this.attributes[name];
|
|
99
|
-
return this;
|
|
100
|
-
};
|
|
101
|
-
BufferGeometry.prototype.addGroup = function (start, count, materialIndex) {
|
|
102
|
-
this.groups.push({
|
|
103
|
-
start: start,
|
|
104
|
-
count: count,
|
|
105
|
-
materialIndex: materialIndex !== undefined ? materialIndex : 0
|
|
106
|
-
});
|
|
107
|
-
};
|
|
108
|
-
BufferGeometry.prototype.clearGroups = function () {
|
|
109
|
-
this.groups = [];
|
|
110
|
-
};
|
|
111
|
-
BufferGeometry.prototype.setDrawRange = function (start, count) {
|
|
112
|
-
this.drawRange.start = start;
|
|
113
|
-
this.drawRange.count = count;
|
|
114
|
-
};
|
|
115
|
-
BufferGeometry.prototype.applyMat4 = function (matrix) {
|
|
116
|
-
var position = this.attributes.position;
|
|
117
|
-
if (position !== undefined) {
|
|
118
|
-
position.applyMat4(matrix);
|
|
119
|
-
position.needsUpdate = true;
|
|
120
|
-
}
|
|
121
|
-
var normal = this.attributes.normal;
|
|
122
|
-
if (normal !== undefined) {
|
|
123
|
-
var normalMatrix = new Mat3_1.Mat3().getNormalMat(matrix);
|
|
124
|
-
normal.applyNormalMat(normalMatrix);
|
|
125
|
-
normal.needsUpdate = true;
|
|
126
|
-
}
|
|
127
|
-
var tangent = this.attributes.tangent;
|
|
128
|
-
if (tangent !== undefined) {
|
|
129
|
-
tangent.transformDirection(matrix);
|
|
130
|
-
tangent.needsUpdate = true;
|
|
131
|
-
}
|
|
132
|
-
if (!this.boundingBox) {
|
|
133
|
-
this.computeBoundingBox();
|
|
134
|
-
}
|
|
135
|
-
if (!this.boundingSphere) {
|
|
136
|
-
this.computeBoundingSphere();
|
|
137
|
-
}
|
|
138
|
-
return this;
|
|
139
|
-
};
|
|
140
|
-
BufferGeometry.prototype.rotateX = function (angle) {
|
|
141
|
-
// rotate geometry around world x-axis
|
|
142
|
-
_m1.makeRotationX(angle);
|
|
143
|
-
this.applyMat4(_m1);
|
|
144
|
-
return this;
|
|
145
|
-
};
|
|
146
|
-
BufferGeometry.prototype.rotateY = function (angle) {
|
|
147
|
-
// rotate geometry around world y-axis
|
|
148
|
-
_m1.makeRotationY(angle);
|
|
149
|
-
this.applyMat4(_m1);
|
|
150
|
-
return this;
|
|
151
|
-
};
|
|
152
|
-
BufferGeometry.prototype.rotateZ = function (angle) {
|
|
153
|
-
// rotate geometry around world z-axis
|
|
154
|
-
_m1.makeRotationZ(angle);
|
|
155
|
-
this.applyMat4(_m1);
|
|
156
|
-
return this;
|
|
157
|
-
};
|
|
158
|
-
BufferGeometry.prototype.translate = function (x, y, z) {
|
|
159
|
-
// translate geometry
|
|
160
|
-
_m1.makeTranslation(x, y, z);
|
|
161
|
-
this.applyMat4(_m1);
|
|
162
|
-
return this;
|
|
163
|
-
};
|
|
164
|
-
BufferGeometry.prototype.scale = function (x, y, z) {
|
|
165
|
-
// scale geometry
|
|
166
|
-
_m1.makeScale(x, y, z);
|
|
167
|
-
this.applyMat4(_m1);
|
|
168
|
-
return this;
|
|
169
|
-
};
|
|
170
|
-
BufferGeometry.prototype.lookAt = function (vector) {
|
|
171
|
-
_m1.lookAt((0, Vec3_1.v3)(), vector, Vec3_1.Vec3.UnitY);
|
|
172
|
-
this.applyMat4(_m1);
|
|
173
|
-
return this;
|
|
174
|
-
};
|
|
175
|
-
BufferGeometry.prototype.center = function () {
|
|
176
|
-
this.computeBoundingBox();
|
|
177
|
-
this.boundingBox.getCenter(_offset).negate();
|
|
178
|
-
this.translate(_offset.x, _offset.y, _offset.z);
|
|
179
|
-
return this;
|
|
180
|
-
};
|
|
181
|
-
BufferGeometry.prototype.setFromObject = function (object) {
|
|
182
|
-
// console.log( 'THREE.BufferGeometry.setFromObject(). Converting', object, this );
|
|
183
|
-
var geometry = object.geometry;
|
|
184
|
-
if (object.isPoints || object.isLine) {
|
|
185
|
-
var positions = new bufferAttribute_1.Float32BufferAttribute(geometry.vertices.length * 3, 3);
|
|
186
|
-
var colors = new bufferAttribute_1.Float32BufferAttribute(geometry.colors.length * 3, 3);
|
|
187
|
-
this.setAttribute('position', positions.copyVec3sArray(geometry.vertices));
|
|
188
|
-
this.setAttribute('color', colors.copyColorsArray(geometry.colors));
|
|
189
|
-
if (geometry.lineDistances && geometry.lineDistances.length === geometry.vertices.length) {
|
|
190
|
-
var lineDistances = new bufferAttribute_1.Float32BufferAttribute(geometry.lineDistances.length, 1);
|
|
191
|
-
this.setAttribute('lineDistance', lineDistances.copyArray(geometry.lineDistances));
|
|
192
|
-
}
|
|
193
|
-
if (geometry.boundingSphere !== null) {
|
|
194
|
-
this.boundingSphere = geometry.boundingSphere.clone();
|
|
195
|
-
}
|
|
196
|
-
if (geometry.boundingBox !== null) {
|
|
197
|
-
this.boundingBox = geometry.boundingBox.clone();
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
else if (object.isMesh) {
|
|
201
|
-
// if (geometry && geometry.isGeometry) {
|
|
202
|
-
// this.fromGeometry(geometry);
|
|
203
|
-
// }
|
|
204
|
-
}
|
|
205
|
-
return this;
|
|
206
|
-
};
|
|
207
|
-
BufferGeometry.prototype.setFromPoints = function (points) {
|
|
208
|
-
var position = [];
|
|
209
|
-
for (var i = 0, l = points.length; i < l; i++) {
|
|
210
|
-
var point = points[i];
|
|
211
|
-
position.push(point.x, point.y, point.z || 0);
|
|
212
|
-
}
|
|
213
|
-
this.setAttribute('position', new bufferAttribute_1.Float32BufferAttribute(position, 3));
|
|
214
|
-
return this;
|
|
215
|
-
};
|
|
216
|
-
BufferGeometry.prototype.updateFromObject = function (object) {
|
|
217
|
-
var geometry = object.geometry;
|
|
218
|
-
if (object.isMesh) {
|
|
219
|
-
var direct = geometry.__directGeometry;
|
|
220
|
-
if (geometry.elementsNeedUpdate === true) {
|
|
221
|
-
direct = undefined;
|
|
222
|
-
geometry.elementsNeedUpdate = false;
|
|
223
|
-
}
|
|
224
|
-
// if (direct === undefined) {
|
|
225
|
-
// return this.fromGeometry(geometry);
|
|
226
|
-
// }
|
|
227
|
-
direct.verticesNeedUpdate = geometry.verticesNeedUpdate;
|
|
228
|
-
direct.normalsNeedUpdate = geometry.normalsNeedUpdate;
|
|
229
|
-
direct.colorsNeedUpdate = geometry.colorsNeedUpdate;
|
|
230
|
-
direct.uvsNeedUpdate = geometry.uvsNeedUpdate;
|
|
231
|
-
direct.groupsNeedUpdate = geometry.groupsNeedUpdate;
|
|
232
|
-
geometry.verticesNeedUpdate = false;
|
|
233
|
-
geometry.normalsNeedUpdate = false;
|
|
234
|
-
geometry.colorsNeedUpdate = false;
|
|
235
|
-
geometry.uvsNeedUpdate = false;
|
|
236
|
-
geometry.groupsNeedUpdate = false;
|
|
237
|
-
geometry = direct;
|
|
238
|
-
}
|
|
239
|
-
var attribute;
|
|
240
|
-
if (geometry.verticesNeedUpdate === true) {
|
|
241
|
-
attribute = this.attributes.position;
|
|
242
|
-
if (attribute !== undefined) {
|
|
243
|
-
attribute.copyVec3sArray(geometry.vertices);
|
|
244
|
-
attribute.needsUpdate = true;
|
|
245
|
-
}
|
|
246
|
-
geometry.verticesNeedUpdate = false;
|
|
247
|
-
}
|
|
248
|
-
if (geometry.normalsNeedUpdate === true) {
|
|
249
|
-
attribute = this.attributes.normal;
|
|
250
|
-
if (attribute !== undefined) {
|
|
251
|
-
attribute.copyVec3sArray(geometry.normals);
|
|
252
|
-
attribute.needsUpdate = true;
|
|
253
|
-
}
|
|
254
|
-
geometry.normalsNeedUpdate = false;
|
|
255
|
-
}
|
|
256
|
-
if (geometry.colorsNeedUpdate === true) {
|
|
257
|
-
attribute = this.attributes.color;
|
|
258
|
-
if (attribute !== undefined) {
|
|
259
|
-
attribute.copyColorsArray(geometry.colors);
|
|
260
|
-
attribute.needsUpdate = true;
|
|
261
|
-
}
|
|
262
|
-
geometry.colorsNeedUpdate = false;
|
|
263
|
-
}
|
|
264
|
-
if (geometry.uvsNeedUpdate) {
|
|
265
|
-
attribute = this.attributes.uv;
|
|
266
|
-
if (attribute !== undefined) {
|
|
267
|
-
attribute.copyVec2sArray(geometry.uvs);
|
|
268
|
-
attribute.needsUpdate = true;
|
|
269
|
-
}
|
|
270
|
-
geometry.uvsNeedUpdate = false;
|
|
271
|
-
}
|
|
272
|
-
if (geometry.lineDistancesNeedUpdate) {
|
|
273
|
-
attribute = this.attributes.lineDistance;
|
|
274
|
-
if (attribute !== undefined) {
|
|
275
|
-
attribute.copyArray(geometry.lineDistances);
|
|
276
|
-
attribute.needsUpdate = true;
|
|
277
|
-
}
|
|
278
|
-
geometry.lineDistancesNeedUpdate = false;
|
|
279
|
-
}
|
|
280
|
-
if (geometry.groupsNeedUpdate) {
|
|
281
|
-
geometry.computeGroups(object.geometry);
|
|
282
|
-
this.groups = geometry.groups;
|
|
283
|
-
geometry.groupsNeedUpdate = false;
|
|
284
|
-
}
|
|
285
|
-
return this;
|
|
286
|
-
};
|
|
287
|
-
// fromGeometry(geometry: any) {
|
|
288
|
-
// geometry.__directGeometry = new DirectGeometry().fromGeometry(geometry);
|
|
289
|
-
// return this.fromDirectGeometry(geometry.__directGeometry);
|
|
290
|
-
// }
|
|
291
|
-
// fromDirectGeometry(geometry) {
|
|
292
|
-
// var positions = new Float32Array(geometry.vertices.length * 3);
|
|
293
|
-
// this.setAttribute('position', new BufferAttribute(positions, 3).copyVec3sArray(geometry.vertices));
|
|
294
|
-
// if (geometry.normals.length > 0) {
|
|
295
|
-
// var normals = new Float32Array(geometry.normals.length * 3);
|
|
296
|
-
// this.setAttribute('normal', new BufferAttribute(normals, 3).copyVec3sArray(geometry.normals));
|
|
297
|
-
// }
|
|
298
|
-
// if (geometry.colors.length > 0) {
|
|
299
|
-
// var colors = new Float32Array(geometry.colors.length * 3);
|
|
300
|
-
// this.setAttribute('color', new BufferAttribute(colors, 3).copyColorsArray(geometry.colors));
|
|
301
|
-
// }
|
|
302
|
-
// if (geometry.uvs.length > 0) {
|
|
303
|
-
// var uvs = new Float32Array(geometry.uvs.length * 2);
|
|
304
|
-
// this.setAttribute('uv', new BufferAttribute(uvs, 2).copyVec2sArray(geometry.uvs));
|
|
305
|
-
// }
|
|
306
|
-
// if (geometry.uvs2.length > 0) {
|
|
307
|
-
// var uvs2 = new Float32Array(geometry.uvs2.length * 2);
|
|
308
|
-
// this.setAttribute('uv2', new BufferAttribute(uvs2, 2).copyVec2sArray(geometry.uvs2));
|
|
309
|
-
// }
|
|
310
|
-
// // groups
|
|
311
|
-
// this.groups = geometry.groups;
|
|
312
|
-
// // morphs
|
|
313
|
-
// for (var name in geometry.morphTargets) {
|
|
314
|
-
// var array = [];
|
|
315
|
-
// var morphTargets = geometry.morphTargets[name];
|
|
316
|
-
// for (var i = 0, l = morphTargets.length; i < l; i++) {
|
|
317
|
-
// var morphTarget = morphTargets[i];
|
|
318
|
-
// var attribute = new Float32BufferAttribute(morphTarget.data.length * 3, 3);
|
|
319
|
-
// attribute.name = morphTarget.name;
|
|
320
|
-
// array.push(attribute.copyVec3sArray(morphTarget.data));
|
|
321
|
-
// }
|
|
322
|
-
// this.morphAttributes[name] = array;
|
|
323
|
-
// }
|
|
324
|
-
// // skinning
|
|
325
|
-
// if (geometry.skinIndices.length > 0) {
|
|
326
|
-
// var skinIndices = new Float32BufferAttribute(geometry.skinIndices.length * 4, 4);
|
|
327
|
-
// this.setAttribute('skinIndex', skinIndices.copyVec4sArray(geometry.skinIndices));
|
|
328
|
-
// }
|
|
329
|
-
// if (geometry.skinWeights.length > 0) {
|
|
330
|
-
// var skinWeights = new Float32BufferAttribute(geometry.skinWeights.length * 4, 4);
|
|
331
|
-
// this.setAttribute('skinWeight', skinWeights.copyVec4sArray(geometry.skinWeights));
|
|
332
|
-
// }
|
|
333
|
-
// //
|
|
334
|
-
// if (geometry.boundingSphere !== null) {
|
|
335
|
-
// this.boundingSphere = geometry.boundingSphere.clone();
|
|
336
|
-
// }
|
|
337
|
-
// if (geometry.boundingBox !== null) {
|
|
338
|
-
// this.boundingBox = geometry.boundingBox.clone();
|
|
339
|
-
// }
|
|
340
|
-
// return this;
|
|
341
|
-
// }
|
|
342
|
-
BufferGeometry.prototype.computeBoundingBox = function () {
|
|
343
|
-
if (!this.boundingBox) {
|
|
344
|
-
this.boundingBox = new Box_1.Box();
|
|
345
|
-
}
|
|
346
|
-
var position = this.attributes.position;
|
|
347
|
-
var morphAttributesPosition = this.morphAttributes.position;
|
|
348
|
-
if (position) {
|
|
349
|
-
this.boundingBox.setFromBufferAttribute(position);
|
|
350
|
-
// process morph attributes if present
|
|
351
|
-
if (morphAttributesPosition) {
|
|
352
|
-
for (var i = 0, il = morphAttributesPosition.length; i < il; i++) {
|
|
353
|
-
var morphAttribute = morphAttributesPosition[i];
|
|
354
|
-
_box.setFromBufferAttribute(morphAttribute);
|
|
355
|
-
if (this.morphTargetsRelative) {
|
|
356
|
-
_vector.addVecs(this.boundingBox.min, _box.min);
|
|
357
|
-
this.boundingBox.expandByPoint(_vector);
|
|
358
|
-
_vector.addVecs(this.boundingBox.max, _box.max);
|
|
359
|
-
this.boundingBox.expandByPoint(_vector);
|
|
360
|
-
}
|
|
361
|
-
else {
|
|
362
|
-
this.boundingBox.expandByPoint(_box.min);
|
|
363
|
-
this.boundingBox.expandByPoint(_box.max);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
else {
|
|
369
|
-
this.boundingBox.makeEmpty();
|
|
370
|
-
}
|
|
371
|
-
if (isNaN(this.boundingBox.min.x) || isNaN(this.boundingBox.min.y) || isNaN(this.boundingBox.min.z)) {
|
|
372
|
-
console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this);
|
|
373
|
-
}
|
|
374
|
-
};
|
|
375
|
-
BufferGeometry.prototype.computeBoundingSphere = function () {
|
|
376
|
-
if (!this.boundingSphere) {
|
|
377
|
-
this.boundingSphere = new Sphere_1.Sphere();
|
|
378
|
-
}
|
|
379
|
-
var position = this.attributes.position;
|
|
380
|
-
var morphAttributesPosition = this.morphAttributes.position;
|
|
381
|
-
if (position) {
|
|
382
|
-
// first, find the center of the bounding sphere
|
|
383
|
-
var center = this.boundingSphere.center;
|
|
384
|
-
_box.setFromBufferAttribute(position);
|
|
385
|
-
// process morph attributes if present
|
|
386
|
-
if (morphAttributesPosition) {
|
|
387
|
-
for (var i = 0, il = morphAttributesPosition.length; i < il; i++) {
|
|
388
|
-
var morphAttribute = morphAttributesPosition[i];
|
|
389
|
-
_boxMorphTargets.setFromBufferAttribute(morphAttribute);
|
|
390
|
-
if (this.morphTargetsRelative) {
|
|
391
|
-
_vector.addVecs(_box.min, _boxMorphTargets.min);
|
|
392
|
-
_box.expandByPoint(_vector);
|
|
393
|
-
_vector.addVecs(_box.max, _boxMorphTargets.max);
|
|
394
|
-
_box.expandByPoint(_vector);
|
|
395
|
-
}
|
|
396
|
-
else {
|
|
397
|
-
_box.expandByPoint(_boxMorphTargets.min);
|
|
398
|
-
_box.expandByPoint(_boxMorphTargets.max);
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
_box.getCenter(center);
|
|
403
|
-
// second, try to find a boundingSphere with a radius smaller than the
|
|
404
|
-
// boundingSphere of the boundingBox: sqrt(3) smaller in the best case
|
|
405
|
-
var maxRadiusSq = 0;
|
|
406
|
-
for (var i = 0, il = position.count; i < il; i++) {
|
|
407
|
-
_vector.fromBufferAttribute(position, i);
|
|
408
|
-
maxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(_vector));
|
|
409
|
-
}
|
|
410
|
-
// process morph attributes if present
|
|
411
|
-
if (morphAttributesPosition) {
|
|
412
|
-
for (var i = 0, il = morphAttributesPosition.length; i < il; i++) {
|
|
413
|
-
var morphAttribute = morphAttributesPosition[i];
|
|
414
|
-
var morphTargetsRelative = this.morphTargetsRelative;
|
|
415
|
-
for (var j = 0, jl = morphAttribute.count; j < jl; j++) {
|
|
416
|
-
_vector.fromBufferAttribute(morphAttribute, j);
|
|
417
|
-
if (morphTargetsRelative) {
|
|
418
|
-
_offset.fromBufferAttribute(position, j);
|
|
419
|
-
_vector.add(_offset);
|
|
420
|
-
}
|
|
421
|
-
maxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(_vector));
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
this.boundingSphere.radius = Math.sqrt(maxRadiusSq);
|
|
426
|
-
if (isNaN(this.boundingSphere.radius)) {
|
|
427
|
-
console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
};
|
|
431
|
-
BufferGeometry.prototype.computeFaceNormals = function () {
|
|
432
|
-
// backwards compatibility
|
|
433
|
-
};
|
|
434
|
-
BufferGeometry.prototype.computeVertexNormals = function () {
|
|
435
|
-
var index = this.index;
|
|
436
|
-
var attributes = this.attributes;
|
|
437
|
-
if (attributes.position) {
|
|
438
|
-
var positions = attributes.position.array;
|
|
439
|
-
if (attributes.normal === undefined) {
|
|
440
|
-
this.setAttribute('normal', new bufferAttribute_1.BufferAttribute(new Float32Array(positions.length), 3));
|
|
441
|
-
}
|
|
442
|
-
else {
|
|
443
|
-
// reset existing normals to zero
|
|
444
|
-
var array = attributes.normal.array;
|
|
445
|
-
for (var i = 0, il = array.length; i < il; i++) {
|
|
446
|
-
array[i] = 0;
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
var normals = attributes.normal.array;
|
|
450
|
-
var vA, vB, vC;
|
|
451
|
-
var pA = new Vec3_1.Vec3(), pB = new Vec3_1.Vec3(), pC = new Vec3_1.Vec3();
|
|
452
|
-
var cb = new Vec3_1.Vec3(), ab = new Vec3_1.Vec3();
|
|
453
|
-
// indexed elements
|
|
454
|
-
if (index) {
|
|
455
|
-
var indices = index.array;
|
|
456
|
-
for (var i = 0, il = index.count; i < il; i += 3) {
|
|
457
|
-
vA = indices[i + 0] * 3;
|
|
458
|
-
vB = indices[i + 1] * 3;
|
|
459
|
-
vC = indices[i + 2] * 3;
|
|
460
|
-
pA.fromArray(positions, vA);
|
|
461
|
-
pB.fromArray(positions, vB);
|
|
462
|
-
pC.fromArray(positions, vC);
|
|
463
|
-
cb.subVecs(pC, pB);
|
|
464
|
-
ab.subVecs(pA, pB);
|
|
465
|
-
cb.cross(ab);
|
|
466
|
-
normals[vA] += cb.x;
|
|
467
|
-
normals[vA + 1] += cb.y;
|
|
468
|
-
normals[vA + 2] += cb.z;
|
|
469
|
-
normals[vB] += cb.x;
|
|
470
|
-
normals[vB + 1] += cb.y;
|
|
471
|
-
normals[vB + 2] += cb.z;
|
|
472
|
-
normals[vC] += cb.x;
|
|
473
|
-
normals[vC + 1] += cb.y;
|
|
474
|
-
normals[vC + 2] += cb.z;
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
else {
|
|
478
|
-
// non-indexed elements (unconnected triangle soup)
|
|
479
|
-
for (var i = 0, il = positions.length; i < il; i += 9) {
|
|
480
|
-
pA.fromArray(positions, i);
|
|
481
|
-
pB.fromArray(positions, i + 3);
|
|
482
|
-
pC.fromArray(positions, i + 6);
|
|
483
|
-
cb.subVecs(pC, pB);
|
|
484
|
-
ab.subVecs(pA, pB);
|
|
485
|
-
cb.cross(ab);
|
|
486
|
-
normals[i] = cb.x;
|
|
487
|
-
normals[i + 1] = cb.y;
|
|
488
|
-
normals[i + 2] = cb.z;
|
|
489
|
-
normals[i + 3] = cb.x;
|
|
490
|
-
normals[i + 4] = cb.y;
|
|
491
|
-
normals[i + 5] = cb.z;
|
|
492
|
-
normals[i + 6] = cb.x;
|
|
493
|
-
normals[i + 7] = cb.y;
|
|
494
|
-
normals[i + 8] = cb.z;
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
this.normalizeNormals();
|
|
498
|
-
attributes.normal.needsUpdate = true;
|
|
499
|
-
}
|
|
500
|
-
};
|
|
501
|
-
BufferGeometry.prototype.merge = function (geometry, offset) {
|
|
502
|
-
if (!(geometry && geometry.isBufferGeometry)) {
|
|
503
|
-
console.error('THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.', geometry);
|
|
504
|
-
return;
|
|
505
|
-
}
|
|
506
|
-
if (offset === undefined) {
|
|
507
|
-
offset = 0;
|
|
508
|
-
console.warn('THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. '
|
|
509
|
-
+ 'Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge.');
|
|
510
|
-
}
|
|
511
|
-
var attributes = this.attributes;
|
|
512
|
-
for (var key in attributes) {
|
|
513
|
-
if (geometry.attributes[key] === undefined)
|
|
514
|
-
continue;
|
|
515
|
-
var attribute1 = attributes[key];
|
|
516
|
-
var attributeArray1 = attribute1.array;
|
|
517
|
-
var attribute2 = geometry.attributes[key];
|
|
518
|
-
var attributeArray2 = attribute2.array;
|
|
519
|
-
var attributeOffset = attribute2.itemSize * offset;
|
|
520
|
-
var length = Math.min(attributeArray2.length, attributeArray1.length - attributeOffset);
|
|
521
|
-
for (var i = 0, j = attributeOffset; i < length; i++, j++) {
|
|
522
|
-
attributeArray1[j] = attributeArray2[i];
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
return this;
|
|
526
|
-
};
|
|
527
|
-
BufferGeometry.prototype.normalizeNormals = function () {
|
|
528
|
-
var normals = this.attributes.normal;
|
|
529
|
-
for (var i = 0, il = normals.count; i < il; i++) {
|
|
530
|
-
_vector.x = normals.getX(i);
|
|
531
|
-
_vector.y = normals.getY(i);
|
|
532
|
-
_vector.z = normals.getZ(i);
|
|
533
|
-
_vector.normalize();
|
|
534
|
-
normals.setXYZ(i, _vector.x, _vector.y, _vector.z);
|
|
535
|
-
}
|
|
536
|
-
};
|
|
537
|
-
BufferGeometry.prototype.toFlat = function () {
|
|
538
|
-
var indices = this.index.array;
|
|
539
|
-
var attributes = this.attributes;
|
|
540
|
-
var geometry2 = new BufferGeometry();
|
|
541
|
-
function convertBufferAttribute(attribute, indices) {
|
|
542
|
-
var array = attribute.array;
|
|
543
|
-
var itemSize = attribute.itemSize;
|
|
544
|
-
var array2 = new array.constructor(indices.length * itemSize);
|
|
545
|
-
var index = 0, index2 = 0;
|
|
546
|
-
for (var i = 0, l = indices.length; i < l; i++) {
|
|
547
|
-
index = indices[i] * itemSize;
|
|
548
|
-
for (var j = 0; j < itemSize; j++) {
|
|
549
|
-
array2[index2++] = array[index++];
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
return new bufferAttribute_1.BufferAttribute(array2, itemSize);
|
|
553
|
-
}
|
|
554
|
-
for (var name in attributes) {
|
|
555
|
-
var attribute = attributes[name];
|
|
556
|
-
var newAttribute = convertBufferAttribute(attribute, indices);
|
|
557
|
-
geometry2.setAttribute(name, newAttribute);
|
|
558
|
-
}
|
|
559
|
-
var indices2 = indices.map(function (v, i) { return i; });
|
|
560
|
-
geometry2.setIndex(indices2);
|
|
561
|
-
return geometry2;
|
|
562
|
-
};
|
|
563
|
-
BufferGeometry.prototype.toNonIndexed = function () {
|
|
564
|
-
function convertBufferAttribute(attribute, indices) {
|
|
565
|
-
var array = attribute.array;
|
|
566
|
-
var itemSize = attribute.itemSize;
|
|
567
|
-
var array2 = new array.constructor(indices.length * itemSize);
|
|
568
|
-
var index = 0, index2 = 0;
|
|
569
|
-
for (var i = 0, l = indices.length; i < l; i++) {
|
|
570
|
-
index = indices[i] * itemSize;
|
|
571
|
-
for (var j = 0; j < itemSize; j++) {
|
|
572
|
-
array2[index2++] = array[index++];
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
return new bufferAttribute_1.BufferAttribute(array2, itemSize);
|
|
576
|
-
}
|
|
577
|
-
//
|
|
578
|
-
if (this.index === undefined) {
|
|
579
|
-
console.warn('THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed.');
|
|
580
|
-
return this;
|
|
581
|
-
}
|
|
582
|
-
var geometry2 = new BufferGeometry();
|
|
583
|
-
var indices = this.index.array;
|
|
584
|
-
var attributes = this.attributes;
|
|
585
|
-
// attributes
|
|
586
|
-
for (var name in attributes) {
|
|
587
|
-
var attribute = attributes[name];
|
|
588
|
-
var newAttribute = convertBufferAttribute(attribute, indices);
|
|
589
|
-
geometry2.setAttribute(name, newAttribute);
|
|
590
|
-
}
|
|
591
|
-
// morph attributes
|
|
592
|
-
var morphAttributes = this.morphAttributes;
|
|
593
|
-
for (name in morphAttributes) {
|
|
594
|
-
var morphArray = [];
|
|
595
|
-
var morphAttribute = morphAttributes[name]; // morphAttribute: array of Float32BufferAttributes
|
|
596
|
-
for (var i = 0, il = morphAttribute.length; i < il; i++) {
|
|
597
|
-
var attribute = morphAttribute[i];
|
|
598
|
-
var newAttribute = convertBufferAttribute(attribute, indices);
|
|
599
|
-
morphArray.push(newAttribute);
|
|
600
|
-
}
|
|
601
|
-
geometry2.morphAttributes[name] = morphArray;
|
|
602
|
-
}
|
|
603
|
-
geometry2.morphTargetsRelative = this.morphTargetsRelative;
|
|
604
|
-
// groups
|
|
605
|
-
var groups = this.groups;
|
|
606
|
-
for (var i = 0, l = groups.length; i < l; i++) {
|
|
607
|
-
var group = groups[i];
|
|
608
|
-
geometry2.addGroup(group.start, group.count, group.materialIndex);
|
|
609
|
-
}
|
|
610
|
-
return geometry2;
|
|
611
|
-
};
|
|
612
|
-
BufferGeometry.prototype.toJSON = function () {
|
|
613
|
-
var data = {
|
|
614
|
-
metadata: {
|
|
615
|
-
version: 4.5,
|
|
616
|
-
type: 'BufferGeometry',
|
|
617
|
-
generator: 'BufferGeometry.toJSON'
|
|
618
|
-
}
|
|
619
|
-
};
|
|
620
|
-
// standard BufferGeometry serialization
|
|
621
|
-
// data.uuid = this.uuid;
|
|
622
|
-
// data.type = this.type;
|
|
623
|
-
if (this.name !== '')
|
|
624
|
-
data.name = this.name;
|
|
625
|
-
if (Object.keys(this.userData).length > 0)
|
|
626
|
-
data.userData = this.userData;
|
|
627
|
-
if (this.parameters !== undefined) {
|
|
628
|
-
var parameters = this.parameters;
|
|
629
|
-
for (var key in parameters) {
|
|
630
|
-
if (parameters[key] !== undefined)
|
|
631
|
-
data[key] = parameters[key];
|
|
632
|
-
}
|
|
633
|
-
return data;
|
|
634
|
-
}
|
|
635
|
-
data.data = { attributes: {} };
|
|
636
|
-
var index = this.index;
|
|
637
|
-
if (index) {
|
|
638
|
-
data.data.index = {
|
|
639
|
-
type: index.array.constructor.name,
|
|
640
|
-
array: Array.prototype.slice.call(index.array)
|
|
641
|
-
};
|
|
642
|
-
}
|
|
643
|
-
var attributes = this.attributes;
|
|
644
|
-
for (var key in attributes) {
|
|
645
|
-
var attribute = attributes[key];
|
|
646
|
-
var attributeData = attribute.toJSON();
|
|
647
|
-
if (attribute.name !== '')
|
|
648
|
-
attributeData.name = attribute.name;
|
|
649
|
-
data.data.attributes[key] = attributeData;
|
|
650
|
-
}
|
|
651
|
-
var morphAttributes = {};
|
|
652
|
-
var hasMorphAttributes = false;
|
|
653
|
-
for (var key in this.morphAttributes) {
|
|
654
|
-
var attributeArray = this.morphAttributes[key];
|
|
655
|
-
var array = [];
|
|
656
|
-
for (var i = 0, il = attributeArray.length; i < il; i++) {
|
|
657
|
-
var attribute = attributeArray[i];
|
|
658
|
-
var attributeData = attribute.toJSON();
|
|
659
|
-
if (attribute.name !== '')
|
|
660
|
-
attributeData.name = attribute.name;
|
|
661
|
-
array.push(attributeData);
|
|
662
|
-
}
|
|
663
|
-
if (array.length > 0) {
|
|
664
|
-
morphAttributes[key] = array;
|
|
665
|
-
hasMorphAttributes = true;
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
if (hasMorphAttributes) {
|
|
669
|
-
data.data.morphAttributes = morphAttributes;
|
|
670
|
-
data.data.morphTargetsRelative = this.morphTargetsRelative;
|
|
671
|
-
}
|
|
672
|
-
var groups = this.groups;
|
|
673
|
-
if (groups.length > 0) {
|
|
674
|
-
data.data.groups = JSON.parse(JSON.stringify(groups));
|
|
675
|
-
}
|
|
676
|
-
var boundingSphere = this.boundingSphere;
|
|
677
|
-
if (boundingSphere) {
|
|
678
|
-
data.data.boundingSphere = {
|
|
679
|
-
center: boundingSphere.center.toArray(),
|
|
680
|
-
radius: boundingSphere.radius
|
|
681
|
-
};
|
|
682
|
-
}
|
|
683
|
-
return data;
|
|
684
|
-
};
|
|
685
|
-
BufferGeometry.prototype.userData = function (userData) {
|
|
686
|
-
throw new Error("Method not implemented.");
|
|
687
|
-
};
|
|
688
|
-
BufferGeometry.prototype.clone = function () {
|
|
689
|
-
/*
|
|
690
|
-
// Handle primitives
|
|
691
|
-
|
|
692
|
-
var parameters = this.parameters;
|
|
693
|
-
|
|
694
|
-
if ( parameters !== undefined ) {
|
|
695
|
-
|
|
696
|
-
var values = [];
|
|
697
|
-
|
|
698
|
-
for ( var key in parameters ) {
|
|
699
|
-
|
|
700
|
-
values.push( parameters[ key ] );
|
|
701
|
-
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
var geometry = Object.create( this.constructor.prototype );
|
|
705
|
-
this.constructor.apply( geometry, values );
|
|
706
|
-
return geometry;
|
|
707
|
-
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
return new this.constructor().copy( this );
|
|
711
|
-
*/
|
|
712
|
-
return new BufferGeometry().copy(this);
|
|
713
|
-
};
|
|
714
|
-
BufferGeometry.prototype.copy = function (source) {
|
|
715
|
-
var name, i, l;
|
|
716
|
-
// reset
|
|
717
|
-
this.attributes = {};
|
|
718
|
-
this.morphAttributes = {};
|
|
719
|
-
this.groups = [];
|
|
720
|
-
// name
|
|
721
|
-
this.name = source.name;
|
|
722
|
-
// index
|
|
723
|
-
var index = source.index;
|
|
724
|
-
if (index) {
|
|
725
|
-
this.setIndex(index.clone());
|
|
726
|
-
}
|
|
727
|
-
// attributes
|
|
728
|
-
var attributes = source.attributes;
|
|
729
|
-
for (name in attributes) {
|
|
730
|
-
var attribute = attributes[name];
|
|
731
|
-
this.setAttribute(name, attribute.clone());
|
|
732
|
-
}
|
|
733
|
-
// morph attributes
|
|
734
|
-
var morphAttributes = source.morphAttributes;
|
|
735
|
-
for (name in morphAttributes) {
|
|
736
|
-
var array = [];
|
|
737
|
-
var morphAttribute = morphAttributes[name]; // morphAttribute: array of Float32BufferAttributes
|
|
738
|
-
for (i = 0, l = morphAttribute.length; i < l; i++) {
|
|
739
|
-
array.push(morphAttribute[i].clone());
|
|
740
|
-
}
|
|
741
|
-
this.morphAttributes[name] = array;
|
|
742
|
-
}
|
|
743
|
-
this.morphTargetsRelative = source.morphTargetsRelative;
|
|
744
|
-
// groups
|
|
745
|
-
var groups = source.groups;
|
|
746
|
-
for (i = 0, l = groups.length; i < l; i++) {
|
|
747
|
-
var group = groups[i];
|
|
748
|
-
this.addGroup(group.start, group.count, group.materialIndex);
|
|
749
|
-
}
|
|
750
|
-
// bounding box
|
|
751
|
-
var boundingBox = source.boundingBox;
|
|
752
|
-
if (boundingBox) {
|
|
753
|
-
this.boundingBox = boundingBox.clone();
|
|
754
|
-
}
|
|
755
|
-
// bounding sphere
|
|
756
|
-
var boundingSphere = source.boundingSphere;
|
|
757
|
-
if (boundingSphere) {
|
|
758
|
-
this.boundingSphere = boundingSphere.clone();
|
|
759
|
-
}
|
|
760
|
-
// draw range
|
|
761
|
-
this.drawRange.start = source.drawRange.start;
|
|
762
|
-
this.drawRange.count = source.drawRange.count;
|
|
763
|
-
// user data
|
|
764
|
-
this.userData = source.userData;
|
|
765
|
-
return this;
|
|
766
|
-
};
|
|
767
|
-
return BufferGeometry;
|
|
768
|
-
}());
|
|
769
|
-
exports.BufferGeometry = BufferGeometry;
|