@realsee/five 5.0.0-alpha.15 → 5.0.0-alpha.150
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/README.md +21 -11
- package/docs/.nojekyll +1 -0
- package/docs/assets/highlight.css +134 -0
- package/docs/assets/icons.css +1043 -0
- package/docs/assets/{images/icons.png → icons.png} +0 -0
- package/docs/assets/{images/icons@2x.png → icons@2x.png} +0 -0
- package/docs/assets/main.js +52 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1414 -0
- package/docs/assets/{images/widgets.png → widgets.png} +0 -0
- package/docs/assets/{images/widgets@2x.png → widgets@2x.png} +0 -0
- package/docs/classes/five.AnimationFrameLoop.html +15 -0
- package/docs/classes/five.BVH.html +10 -0
- package/docs/classes/five.BVHIntersect.html +1 -0
- package/docs/classes/five.BVHNode.html +7 -0
- package/docs/classes/five.BVHVector3.html +1 -0
- package/docs/classes/five.Camera.html +11 -0
- package/docs/classes/five.Clipper.html +1 -0
- package/docs/classes/five.Five.html +323 -0
- package/docs/classes/five.InternalWebGLRenderer.html +1 -0
- package/docs/classes/five.IntersectMesh.html +1 -0
- package/docs/classes/five.LegacyPanoCircleMesh.html +5 -0
- package/docs/classes/five.Model.html +87 -0
- package/docs/classes/five.NetworkSubscribe.html +50 -0
- package/docs/classes/five.PBMContainer.html +17 -0
- package/docs/classes/five.PBMGroup.html +19 -0
- package/docs/classes/five.PBMMaterial.html +27 -0
- package/docs/classes/five.PBMMesh.html +7 -0
- package/docs/classes/five.PanoCircleMesh.html +7 -0
- package/docs/classes/five.PanoCircleMeshDark.html +7 -0
- package/docs/classes/five.PanoCircleMeshSolid.html +7 -0
- package/docs/classes/five.Scene.html +3 -0
- package/docs/classes/five.Subscribe.html +56 -0
- package/docs/classes/five.TextureLoader.html +1 -0
- package/docs/classes/five.Tile3D.html +34 -0
- package/docs/classes/five.Tile3DModel.html +15 -0
- package/docs/classes/five.TileBoundingSphere.html +1 -0
- package/docs/classes/five.TileCacheNode.html +1 -0
- package/docs/classes/five.TileCubeTextureTarget.html +1 -0
- package/docs/classes/five.TileCullingVolume.html +1 -0
- package/docs/classes/five.TileOrientedBoundingBox.html +1 -0
- package/docs/classes/five.TilePlane.html +1 -0
- package/docs/classes/five.TileRequestScheduler.html +16 -0
- package/docs/classes/five.Tileset3D.html +11 -0
- package/docs/classes/five.Tileset3DTraverser.html +1 -0
- package/docs/classes/five.TilesetCache.html +1 -0
- package/docs/classes/five.Work.html +30 -0
- package/docs/classes/five.XRButton.html +1 -0
- package/docs/classes/gltf_loader.DDSLoader.html +1 -0
- package/docs/classes/gltf_loader.DRACOLoader.html +1 -0
- package/docs/classes/gltf_loader.GLTFLoader.html +17 -0
- package/docs/classes/gltf_loader.GLTFObject.html +7 -0
- package/docs/classes/gltf_loader.GLTFParser.html +1 -0
- package/docs/classes/gltf_loader.THREEGLTFLoader.html +1 -0
- package/docs/classes/line.Line.html +1 -0
- package/docs/classes/line.LineGeometry.html +1 -0
- package/docs/classes/line.LineMaterial.html +1 -0
- package/docs/classes/line.LineSegmentsGeometry.html +1 -0
- package/docs/classes/line.THREE_Line2.html +1 -0
- package/docs/classes/line.THREE_LineSegments2.html +1 -0
- package/docs/classes/react.Store.html +29 -0
- package/docs/classes/server.BVH.html +10 -0
- package/docs/classes/server.BVHIntersect.html +1 -0
- package/docs/classes/server.BVHNode.html +7 -0
- package/docs/classes/server.BVHVector3.html +1 -0
- package/docs/classes/server.Model.html +63 -0
- package/docs/classes/server.PBMGroup.html +9 -0
- package/docs/classes/server.PBMMesh.html +7 -0
- package/docs/classes/sticker.Sticker.html +32 -0
- package/docs/index.html +166 -422
- package/docs/interfaces/five.AddableObject.html +1 -0
- package/docs/interfaces/five.AnimationFrame.html +1 -0
- package/docs/interfaces/five.CameraPose.html +1 -0
- package/docs/interfaces/five.ClipperParameter.html +1 -0
- package/docs/interfaces/five.DepthPanoramaControllerCustomInitArgs.html +28 -0
- package/docs/interfaces/five.EventCallback.html +399 -0
- package/docs/interfaces/five.FiveInitArgs.html +109 -0
- package/docs/interfaces/five.FloorplanControllerCustomInitArgs.html +15 -0
- package/docs/interfaces/five.ImageOptions.html +18 -0
- package/docs/interfaces/five.ImageURLMappings.html +1 -0
- package/docs/interfaces/five.ImageURLOptions.html +17 -0
- package/docs/interfaces/five.IntersectMeshInterface.html +3 -0
- package/docs/interfaces/five.Intersection.html +7 -0
- package/docs/interfaces/five.MapviewControllerCustomInitArgs.html +15 -0
- package/docs/interfaces/five.ModelControllerCustomInitArgs.html +20 -0
- package/docs/interfaces/five.ModelEventCallback.html +22 -0
- package/docs/interfaces/five.MovePanoOptions.html +42 -0
- package/docs/interfaces/five.NetworkOptions.html +9 -0
- package/docs/interfaces/five.PBMPanoPicture.html +7 -0
- package/docs/interfaces/five.PBMParameters.html +27 -0
- package/docs/interfaces/five.PanoCircleMeshInterface.html +19 -0
- package/docs/interfaces/five.PanoramaControllerCustomInitArgs.html +33 -0
- package/docs/interfaces/five.PanoramaLikeControllerCustomInitArgs.html +20 -0
- package/docs/interfaces/five.Pose.html +37 -0
- package/docs/interfaces/five.Scissor.html +14 -0
- package/docs/interfaces/five.State.html +21 -0
- package/docs/interfaces/five.SubscribeMixinType.emit.html +1 -0
- package/docs/interfaces/five.SubscribeMixinType.hasListener.html +1 -0
- package/docs/interfaces/five.SubscribeMixinType.off.html +1 -0
- package/docs/interfaces/five.SubscribeMixinType.on.html +1 -0
- package/docs/interfaces/five.SubscribeMixinType.once.html +1 -0
- package/docs/interfaces/five.TextureOptions.html +20 -0
- package/docs/interfaces/five.Tile3DModelLoaderOptions.html +3 -0
- package/docs/interfaces/five.TileBoundingVolume.html +19 -0
- package/docs/interfaces/five.TileContent.html +1 -0
- package/docs/interfaces/five.TileCubeNode.html +1 -0
- package/docs/interfaces/five.TileCubeTree.html +1 -0
- package/docs/interfaces/five.Tileset3dOptions.html +1 -0
- package/docs/interfaces/five.TilesetJSON.html +1 -0
- package/docs/interfaces/five.TilesetJSONNode.html +1 -0
- package/docs/interfaces/five.TopviewControllerCustomInitArgs.html +7 -0
- package/docs/interfaces/five.VRPanoramaControllerCustomInitArgs.html +29 -0
- package/docs/interfaces/five.WorkCubeImage.html +13 -0
- package/docs/interfaces/five.WorkImage.html +21 -0
- package/docs/interfaces/five.WorkInitial.html +13 -0
- package/docs/interfaces/five.WorkModel.html +11 -0
- package/docs/interfaces/five.WorkModelTiles.html +3 -0
- package/docs/interfaces/five.WorkObserver.html +25 -0
- package/docs/interfaces/five.WorkTile.html +1 -0
- package/docs/interfaces/five.WorkVideo.html +9 -0
- package/docs/interfaces/five.XRPanoramaControllerCustomInitArgs.html +29 -0
- package/docs/interfaces/gltf_loader.DDS.html +1 -0
- package/docs/interfaces/gltf_loader.GLTF.html +7 -0
- package/docs/interfaces/gltf_loader.GLTFReference.html +1 -0
- package/docs/interfaces/gltf_loader.THREEGLTF.html +1 -0
- package/docs/interfaces/react.FiveActionReactCallbacks.html +62 -0
- package/docs/interfaces/react.FiveInjectionTypes.html +191 -0
- package/docs/interfaces/react.PropTypeOfFiveFeatures.html +1 -0
- package/docs/interfaces/server.Intersection.html +7 -0
- package/docs/interfaces/server.ModelEventCallback.html +18 -0
- package/docs/interfaces/sticker.IntersectionLike.html +8 -0
- package/docs/interfaces/vue.FiveActionVueCallbacks.html +62 -0
- package/docs/modules/five.SubscribeMixinType.html +1 -0
- package/docs/modules/five.html +496 -0
- package/docs/modules/gltf_loader.html +1 -0
- package/docs/modules/line.html +1 -0
- package/docs/modules/react.html +133 -1374
- package/docs/modules/server.html +18 -0
- package/docs/modules/sticker.html +1 -0
- package/docs/modules/vue.html +112 -0
- package/docs/modules.html +1 -120
- package/exporters/staticify.js +210 -0
- package/five/index.d.ts +2922 -0
- package/five/index.js +372 -0
- package/gltf-loader/index.d.ts +160 -0
- package/gltf-loader/index.js +260 -0
- package/line/index.d.ts +69 -0
- package/line/index.js +260 -0
- package/package.json +25 -17
- package/react/index.d.ts +86 -24
- package/react/index.js +260 -1
- package/resource/{basis_transcoder.js → basis/basis_transcoder.js} +0 -0
- package/resource/{basis_transcoder.wasm → basis/basis_transcoder.wasm} +0 -0
- package/resource/gltf/draco_decoder.js +31 -0
- package/resource/gltf/draco_decoder.wasm +0 -0
- package/resource/gltf/draco_wasm_wrapper.js +119 -0
- package/scripts/five-staticify.js +26 -0
- package/server/index.d.ts +197 -26
- package/server/index.js +367 -1
- package/sticker/index.d.ts +71 -0
- package/sticker/index.js +260 -0
- package/templates/quick-start/README.md +1 -1
- package/templates/quick-start/package.json +1 -1
- package/templates/react-component/lib/index.tsx +3 -3
- package/umd/five-gltf-loader.js +1 -0
- package/umd/five-gltf-loader.js.LICENSE.txt +14 -0
- package/umd/five-line.js +1 -0
- package/umd/five-line.js.LICENSE.txt +14 -0
- package/umd/five-react.js +1 -0
- package/umd/five-react.js.LICENSE.txt +14 -0
- package/umd/five-sticker.js +1 -0
- package/umd/five-sticker.js.LICENSE.txt +14 -0
- package/umd/five-vue.js +1 -0
- package/umd/five.js +2 -0
- package/umd/five.js.LICENSE.txt +107 -0
- package/vue/index.d.ts +440 -0
- package/vue/index.js +260 -0
- package/bundles/five.js +0 -2
- package/bundles/five.js.LICENSE.txt +0 -160
- package/docs/assets/css/main.css +0 -2660
- package/docs/assets/js/main.js +0 -248
- package/docs/assets/js/search.js +0 -1
- package/docs/classes/index.five.html +0 -2498
- package/docs/classes/index.fivecamera.html +0 -311
- package/docs/classes/index.fivehashcubetexture.html +0 -240
- package/docs/classes/index.fiveline.html +0 -342
- package/docs/classes/index.fivelinegeometry.html +0 -500
- package/docs/classes/index.fivelinematerial.html +0 -276
- package/docs/classes/index.fivelinesegmentsgeometry.html +0 -447
- package/docs/classes/index.fivescene.html +0 -186
- package/docs/classes/index.internalwebglrenderer.html +0 -200
- package/docs/classes/index.model.html +0 -883
- package/docs/classes/index.pbmgroup.html +0 -415
- package/docs/classes/index.pbmmaterial.html +0 -521
- package/docs/classes/index.pbmmesh.html +0 -242
- package/docs/classes/index.subscribe.html +0 -556
- package/docs/classes/react.store.html +0 -584
- package/docs/interfaces/index.depthpanoramacontrollercustominitargs.html +0 -408
- package/docs/interfaces/index.eventcallback.html +0 -2452
- package/docs/interfaces/index.fiveinitargs.html +0 -695
- package/docs/interfaces/index.floorplancontrollercustominitargs.html +0 -283
- package/docs/interfaces/index.imageoptions.html +0 -320
- package/docs/interfaces/index.intersection.html +0 -215
- package/docs/interfaces/index.intersectmeshinterface.html +0 -176
- package/docs/interfaces/index.modelcontrollercustominitargs.html +0 -354
- package/docs/interfaces/index.modeleventcallback.html +0 -316
- package/docs/interfaces/index.movepanooptions.html +0 -457
- package/docs/interfaces/index.panocirclemeshinterface.html +0 -349
- package/docs/interfaces/index.panoramacontrollercustominitargs.html +0 -433
- package/docs/interfaces/index.panoramalikecontrollercustominitargs.html +0 -352
- package/docs/interfaces/index.pbmparameters.html +0 -462
- package/docs/interfaces/index.pose.html +0 -258
- package/docs/interfaces/index.scissor.html +0 -240
- package/docs/interfaces/index.state.html +0 -288
- package/docs/interfaces/index.subscribemixintype.emit.html +0 -180
- package/docs/interfaces/index.subscribemixintype.haslistener.html +0 -171
- package/docs/interfaces/index.subscribemixintype.off.html +0 -198
- package/docs/interfaces/index.subscribemixintype.on.html +0 -213
- package/docs/interfaces/index.subscribemixintype.once.html +0 -210
- package/docs/interfaces/index.topviewcontrollercustominitargs.html +0 -214
- package/docs/interfaces/index.vrpanoramacontrollercustominitargs.html +0 -420
- package/docs/interfaces/react.fiveactionreactcallbacks.html +0 -559
- package/docs/interfaces/react.fiveinjectiontypes.html +0 -1473
- package/docs/interfaces/react.injectfivetoprops.html +0 -259
- package/docs/modules/index.html +0 -3027
- package/docs/modules/index.subscribemixintype.html +0 -143
- package/five.js.LICENSE.txt +0 -160
- package/index.d.ts +0 -1807
- package/index.js +0 -1
- package/scripts/export-five-resource/chfs.exe +0 -0
- package/scripts/export-five-resource/fileify.js +0 -192
- package/scripts/export-five-resource/format-work.js +0 -71
- package/scripts/export-five-resource/staticify.js +0 -327
- package/scripts/transcode-model/BufferGeometryUtils.js +0 -832
- package/scripts/transcode-model/LoaderSupport.js +0 -1545
- package/scripts/transcode-model/MTLLoader.js +0 -602
- package/scripts/transcode-model/OBJLoader2.js +0 -1470
- package/scripts/transcode-model/obj2pbm.js +0 -65
|
@@ -1,832 +0,0 @@
|
|
|
1
|
-
var THREE = require('three');
|
|
2
|
-
|
|
3
|
-
( function () {
|
|
4
|
-
|
|
5
|
-
class BufferGeometryUtils {
|
|
6
|
-
|
|
7
|
-
static computeTangents( geometry ) {
|
|
8
|
-
|
|
9
|
-
geometry.computeTangents();
|
|
10
|
-
console.warn( 'THREE.BufferGeometryUtils: .computeTangents() has been removed. Use THREE.BufferGeometry.computeTangents() instead.' );
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* @param {Array<BufferGeometry>} geometries
|
|
15
|
-
* @param {Boolean} useGroups
|
|
16
|
-
* @return {BufferGeometry}
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
static mergeBufferGeometries( geometries, useGroups = false ) {
|
|
21
|
-
|
|
22
|
-
const isIndexed = geometries[ 0 ].index !== null;
|
|
23
|
-
const attributesUsed = new Set( Object.keys( geometries[ 0 ].attributes ) );
|
|
24
|
-
const morphAttributesUsed = new Set( Object.keys( geometries[ 0 ].morphAttributes ) );
|
|
25
|
-
const attributes = {};
|
|
26
|
-
const morphAttributes = {};
|
|
27
|
-
const morphTargetsRelative = geometries[ 0 ].morphTargetsRelative;
|
|
28
|
-
const mergedGeometry = new THREE.BufferGeometry();
|
|
29
|
-
let offset = 0;
|
|
30
|
-
|
|
31
|
-
for ( let i = 0; i < geometries.length; ++ i ) {
|
|
32
|
-
|
|
33
|
-
const geometry = geometries[ i ];
|
|
34
|
-
let attributesCount = 0; // ensure that all geometries are indexed, or none
|
|
35
|
-
|
|
36
|
-
if ( isIndexed !== ( geometry.index !== null ) ) {
|
|
37
|
-
|
|
38
|
-
console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.' );
|
|
39
|
-
return null;
|
|
40
|
-
|
|
41
|
-
} // gather attributes, exit early if they're different
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
for ( const name in geometry.attributes ) {
|
|
45
|
-
|
|
46
|
-
if ( ! attributesUsed.has( name ) ) {
|
|
47
|
-
|
|
48
|
-
console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. All geometries must have compatible attributes; make sure "' + name + '" attribute exists among all geometries, or in none of them.' );
|
|
49
|
-
return null;
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if ( attributes[ name ] === undefined ) attributes[ name ] = [];
|
|
54
|
-
attributes[ name ].push( geometry.attributes[ name ] );
|
|
55
|
-
attributesCount ++;
|
|
56
|
-
|
|
57
|
-
} // ensure geometries have the same number of attributes
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if ( attributesCount !== attributesUsed.size ) {
|
|
61
|
-
|
|
62
|
-
console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. Make sure all geometries have the same number of attributes.' );
|
|
63
|
-
return null;
|
|
64
|
-
|
|
65
|
-
} // gather morph attributes, exit early if they're different
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if ( morphTargetsRelative !== geometry.morphTargetsRelative ) {
|
|
69
|
-
|
|
70
|
-
console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. .morphTargetsRelative must be consistent throughout all geometries.' );
|
|
71
|
-
return null;
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
for ( const name in geometry.morphAttributes ) {
|
|
76
|
-
|
|
77
|
-
if ( ! morphAttributesUsed.has( name ) ) {
|
|
78
|
-
|
|
79
|
-
console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. .morphAttributes must be consistent throughout all geometries.' );
|
|
80
|
-
return null;
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if ( morphAttributes[ name ] === undefined ) morphAttributes[ name ] = [];
|
|
85
|
-
morphAttributes[ name ].push( geometry.morphAttributes[ name ] );
|
|
86
|
-
|
|
87
|
-
} // gather .userData
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
mergedGeometry.userData.mergedUserData = mergedGeometry.userData.mergedUserData || [];
|
|
91
|
-
mergedGeometry.userData.mergedUserData.push( geometry.userData );
|
|
92
|
-
|
|
93
|
-
if ( useGroups ) {
|
|
94
|
-
|
|
95
|
-
let count;
|
|
96
|
-
|
|
97
|
-
if ( isIndexed ) {
|
|
98
|
-
|
|
99
|
-
count = geometry.index.count;
|
|
100
|
-
|
|
101
|
-
} else if ( geometry.attributes.position !== undefined ) {
|
|
102
|
-
|
|
103
|
-
count = geometry.attributes.position.count;
|
|
104
|
-
|
|
105
|
-
} else {
|
|
106
|
-
|
|
107
|
-
console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. The geometry must have either an index or a position attribute' );
|
|
108
|
-
return null;
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
mergedGeometry.addGroup( offset, count, i );
|
|
113
|
-
offset += count;
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
} // merge indices
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
if ( isIndexed ) {
|
|
121
|
-
|
|
122
|
-
let indexOffset = 0;
|
|
123
|
-
const mergedIndex = [];
|
|
124
|
-
|
|
125
|
-
for ( let i = 0; i < geometries.length; ++ i ) {
|
|
126
|
-
|
|
127
|
-
const index = geometries[ i ].index;
|
|
128
|
-
|
|
129
|
-
for ( let j = 0; j < index.count; ++ j ) {
|
|
130
|
-
|
|
131
|
-
mergedIndex.push( index.getX( j ) + indexOffset );
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
indexOffset += geometries[ i ].attributes.position.count;
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
mergedGeometry.setIndex( mergedIndex );
|
|
140
|
-
|
|
141
|
-
} // merge attributes
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
for ( const name in attributes ) {
|
|
145
|
-
|
|
146
|
-
const mergedAttribute = this.mergeBufferAttributes( attributes[ name ] );
|
|
147
|
-
|
|
148
|
-
if ( ! mergedAttribute ) {
|
|
149
|
-
|
|
150
|
-
console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the ' + name + ' attribute.' );
|
|
151
|
-
return null;
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
mergedGeometry.setAttribute( name, mergedAttribute );
|
|
156
|
-
|
|
157
|
-
} // merge morph attributes
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
for ( const name in morphAttributes ) {
|
|
161
|
-
|
|
162
|
-
const numMorphTargets = morphAttributes[ name ][ 0 ].length;
|
|
163
|
-
if ( numMorphTargets === 0 ) break;
|
|
164
|
-
mergedGeometry.morphAttributes = mergedGeometry.morphAttributes || {};
|
|
165
|
-
mergedGeometry.morphAttributes[ name ] = [];
|
|
166
|
-
|
|
167
|
-
for ( let i = 0; i < numMorphTargets; ++ i ) {
|
|
168
|
-
|
|
169
|
-
const morphAttributesToMerge = [];
|
|
170
|
-
|
|
171
|
-
for ( let j = 0; j < morphAttributes[ name ].length; ++ j ) {
|
|
172
|
-
|
|
173
|
-
morphAttributesToMerge.push( morphAttributes[ name ][ j ][ i ] );
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
const mergedMorphAttribute = this.mergeBufferAttributes( morphAttributesToMerge );
|
|
178
|
-
|
|
179
|
-
if ( ! mergedMorphAttribute ) {
|
|
180
|
-
|
|
181
|
-
console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the ' + name + ' morphAttribute.' );
|
|
182
|
-
return null;
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
mergedGeometry.morphAttributes[ name ].push( mergedMorphAttribute );
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
return mergedGeometry;
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* @param {Array<BufferAttribute>} attributes
|
|
197
|
-
* @return {BufferAttribute}
|
|
198
|
-
*/
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
static mergeBufferAttributes( attributes ) {
|
|
202
|
-
|
|
203
|
-
let TypedArray;
|
|
204
|
-
let itemSize;
|
|
205
|
-
let normalized;
|
|
206
|
-
let arrayLength = 0;
|
|
207
|
-
|
|
208
|
-
for ( let i = 0; i < attributes.length; ++ i ) {
|
|
209
|
-
|
|
210
|
-
const attribute = attributes[ i ];
|
|
211
|
-
|
|
212
|
-
if ( attribute.isInterleavedBufferAttribute ) {
|
|
213
|
-
|
|
214
|
-
console.error( 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported.' );
|
|
215
|
-
return null;
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
if ( TypedArray === undefined ) TypedArray = attribute.array.constructor;
|
|
220
|
-
|
|
221
|
-
if ( TypedArray !== attribute.array.constructor ) {
|
|
222
|
-
|
|
223
|
-
console.error( 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. THREE.BufferAttribute.array must be of consistent array types across matching attributes.' );
|
|
224
|
-
return null;
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
if ( itemSize === undefined ) itemSize = attribute.itemSize;
|
|
229
|
-
|
|
230
|
-
if ( itemSize !== attribute.itemSize ) {
|
|
231
|
-
|
|
232
|
-
console.error( 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. THREE.BufferAttribute.itemSize must be consistent across matching attributes.' );
|
|
233
|
-
return null;
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
if ( normalized === undefined ) normalized = attribute.normalized;
|
|
238
|
-
|
|
239
|
-
if ( normalized !== attribute.normalized ) {
|
|
240
|
-
|
|
241
|
-
console.error( 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. THREE.BufferAttribute.normalized must be consistent across matching attributes.' );
|
|
242
|
-
return null;
|
|
243
|
-
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
arrayLength += attribute.array.length;
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
const array = new TypedArray( arrayLength );
|
|
251
|
-
let offset = 0;
|
|
252
|
-
|
|
253
|
-
for ( let i = 0; i < attributes.length; ++ i ) {
|
|
254
|
-
|
|
255
|
-
array.set( attributes[ i ].array, offset );
|
|
256
|
-
offset += attributes[ i ].array.length;
|
|
257
|
-
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
return new THREE.BufferAttribute( array, itemSize, normalized );
|
|
261
|
-
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* @param {Array<BufferAttribute>} attributes
|
|
265
|
-
* @return {Array<InterleavedBufferAttribute>}
|
|
266
|
-
*/
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
static interleaveAttributes( attributes ) {
|
|
270
|
-
|
|
271
|
-
// Interleaves the provided attributes into an THREE.InterleavedBuffer and returns
|
|
272
|
-
// a set of InterleavedBufferAttributes for each attribute
|
|
273
|
-
let TypedArray;
|
|
274
|
-
let arrayLength = 0;
|
|
275
|
-
let stride = 0; // calculate the the length and type of the interleavedBuffer
|
|
276
|
-
|
|
277
|
-
for ( let i = 0, l = attributes.length; i < l; ++ i ) {
|
|
278
|
-
|
|
279
|
-
const attribute = attributes[ i ];
|
|
280
|
-
if ( TypedArray === undefined ) TypedArray = attribute.array.constructor;
|
|
281
|
-
|
|
282
|
-
if ( TypedArray !== attribute.array.constructor ) {
|
|
283
|
-
|
|
284
|
-
console.error( 'AttributeBuffers of different types cannot be interleaved' );
|
|
285
|
-
return null;
|
|
286
|
-
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
arrayLength += attribute.array.length;
|
|
290
|
-
stride += attribute.itemSize;
|
|
291
|
-
|
|
292
|
-
} // Create the set of buffer attributes
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
const interleavedBuffer = new THREE.InterleavedBuffer( new TypedArray( arrayLength ), stride );
|
|
296
|
-
let offset = 0;
|
|
297
|
-
const res = [];
|
|
298
|
-
const getters = [ 'getX', 'getY', 'getZ', 'getW' ];
|
|
299
|
-
const setters = [ 'setX', 'setY', 'setZ', 'setW' ];
|
|
300
|
-
|
|
301
|
-
for ( let j = 0, l = attributes.length; j < l; j ++ ) {
|
|
302
|
-
|
|
303
|
-
const attribute = attributes[ j ];
|
|
304
|
-
const itemSize = attribute.itemSize;
|
|
305
|
-
const count = attribute.count;
|
|
306
|
-
const iba = new THREE.InterleavedBufferAttribute( interleavedBuffer, itemSize, offset, attribute.normalized );
|
|
307
|
-
res.push( iba );
|
|
308
|
-
offset += itemSize; // Move the data for each attribute into the new interleavedBuffer
|
|
309
|
-
// at the appropriate offset
|
|
310
|
-
|
|
311
|
-
for ( let c = 0; c < count; c ++ ) {
|
|
312
|
-
|
|
313
|
-
for ( let k = 0; k < itemSize; k ++ ) {
|
|
314
|
-
|
|
315
|
-
iba[ setters[ k ] ]( c, attribute[ getters[ k ] ]( c ) );
|
|
316
|
-
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
return res;
|
|
324
|
-
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* @param {Array<BufferGeometry>} geometry
|
|
328
|
-
* @return {number}
|
|
329
|
-
*/
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
static estimateBytesUsed( geometry ) {
|
|
333
|
-
|
|
334
|
-
// Return the estimated memory used by this geometry in bytes
|
|
335
|
-
// Calculate using itemSize, count, and BYTES_PER_ELEMENT to account
|
|
336
|
-
// for InterleavedBufferAttributes.
|
|
337
|
-
let mem = 0;
|
|
338
|
-
|
|
339
|
-
for ( const name in geometry.attributes ) {
|
|
340
|
-
|
|
341
|
-
const attr = geometry.getAttribute( name );
|
|
342
|
-
mem += attr.count * attr.itemSize * attr.array.BYTES_PER_ELEMENT;
|
|
343
|
-
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
const indices = geometry.getIndex();
|
|
347
|
-
mem += indices ? indices.count * indices.itemSize * indices.array.BYTES_PER_ELEMENT : 0;
|
|
348
|
-
return mem;
|
|
349
|
-
|
|
350
|
-
}
|
|
351
|
-
/**
|
|
352
|
-
* @param {BufferGeometry} geometry
|
|
353
|
-
* @param {number} tolerance
|
|
354
|
-
* @return {BufferGeometry>}
|
|
355
|
-
*/
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
static mergeVertices( geometry, tolerance = 1e-4 ) {
|
|
359
|
-
|
|
360
|
-
tolerance = Math.max( tolerance, Number.EPSILON ); // Generate an index buffer if the geometry doesn't have one, or optimize it
|
|
361
|
-
// if it's already available.
|
|
362
|
-
|
|
363
|
-
const hashToIndex = {};
|
|
364
|
-
const indices = geometry.getIndex();
|
|
365
|
-
const positions = geometry.getAttribute( 'position' );
|
|
366
|
-
const vertexCount = indices ? indices.count : positions.count; // next value for triangle indices
|
|
367
|
-
|
|
368
|
-
let nextIndex = 0; // attributes and new attribute arrays
|
|
369
|
-
|
|
370
|
-
const attributeNames = Object.keys( geometry.attributes );
|
|
371
|
-
const attrArrays = {};
|
|
372
|
-
const morphAttrsArrays = {};
|
|
373
|
-
const newIndices = [];
|
|
374
|
-
const getters = [ 'getX', 'getY', 'getZ', 'getW' ]; // initialize the arrays
|
|
375
|
-
|
|
376
|
-
for ( let i = 0, l = attributeNames.length; i < l; i ++ ) {
|
|
377
|
-
|
|
378
|
-
const name = attributeNames[ i ];
|
|
379
|
-
attrArrays[ name ] = [];
|
|
380
|
-
const morphAttr = geometry.morphAttributes[ name ];
|
|
381
|
-
|
|
382
|
-
if ( morphAttr ) {
|
|
383
|
-
|
|
384
|
-
morphAttrsArrays[ name ] = new Array( morphAttr.length ).fill().map( () => [] );
|
|
385
|
-
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
} // convert the error tolerance to an amount of decimal places to truncate to
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
const decimalShift = Math.log10( 1 / tolerance );
|
|
392
|
-
const shiftMultiplier = Math.pow( 10, decimalShift );
|
|
393
|
-
|
|
394
|
-
for ( let i = 0; i < vertexCount; i ++ ) {
|
|
395
|
-
|
|
396
|
-
const index = indices ? indices.getX( i ) : i; // Generate a hash for the vertex attributes at the current index 'i'
|
|
397
|
-
|
|
398
|
-
let hash = '';
|
|
399
|
-
|
|
400
|
-
for ( let j = 0, l = attributeNames.length; j < l; j ++ ) {
|
|
401
|
-
|
|
402
|
-
const name = attributeNames[ j ];
|
|
403
|
-
const attribute = geometry.getAttribute( name );
|
|
404
|
-
const itemSize = attribute.itemSize;
|
|
405
|
-
|
|
406
|
-
for ( let k = 0; k < itemSize; k ++ ) {
|
|
407
|
-
|
|
408
|
-
// double tilde truncates the decimal value
|
|
409
|
-
hash += `${~ ~ ( attribute[ getters[ k ] ]( index ) * shiftMultiplier )},`;
|
|
410
|
-
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
} // Add another reference to the vertex if it's already
|
|
414
|
-
// used by another index
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
if ( hash in hashToIndex ) {
|
|
418
|
-
|
|
419
|
-
newIndices.push( hashToIndex[ hash ] );
|
|
420
|
-
|
|
421
|
-
} else {
|
|
422
|
-
|
|
423
|
-
// copy data to the new index in the attribute arrays
|
|
424
|
-
for ( let j = 0, l = attributeNames.length; j < l; j ++ ) {
|
|
425
|
-
|
|
426
|
-
const name = attributeNames[ j ];
|
|
427
|
-
const attribute = geometry.getAttribute( name );
|
|
428
|
-
const morphAttr = geometry.morphAttributes[ name ];
|
|
429
|
-
const itemSize = attribute.itemSize;
|
|
430
|
-
const newarray = attrArrays[ name ];
|
|
431
|
-
const newMorphArrays = morphAttrsArrays[ name ];
|
|
432
|
-
|
|
433
|
-
for ( let k = 0; k < itemSize; k ++ ) {
|
|
434
|
-
|
|
435
|
-
const getterFunc = getters[ k ];
|
|
436
|
-
newarray.push( attribute[ getterFunc ]( index ) );
|
|
437
|
-
|
|
438
|
-
if ( morphAttr ) {
|
|
439
|
-
|
|
440
|
-
for ( let m = 0, ml = morphAttr.length; m < ml; m ++ ) {
|
|
441
|
-
|
|
442
|
-
newMorphArrays[ m ].push( morphAttr[ m ][ getterFunc ]( index ) );
|
|
443
|
-
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
hashToIndex[ hash ] = nextIndex;
|
|
453
|
-
newIndices.push( nextIndex );
|
|
454
|
-
nextIndex ++;
|
|
455
|
-
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
} // Generate typed arrays from new attribute arrays and update
|
|
459
|
-
// the attributeBuffers
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
const result = geometry.clone();
|
|
463
|
-
|
|
464
|
-
for ( let i = 0, l = attributeNames.length; i < l; i ++ ) {
|
|
465
|
-
|
|
466
|
-
const name = attributeNames[ i ];
|
|
467
|
-
const oldAttribute = geometry.getAttribute( name );
|
|
468
|
-
const buffer = new oldAttribute.array.constructor( attrArrays[ name ] );
|
|
469
|
-
const attribute = new THREE.BufferAttribute( buffer, oldAttribute.itemSize, oldAttribute.normalized );
|
|
470
|
-
result.setAttribute( name, attribute ); // Update the attribute arrays
|
|
471
|
-
|
|
472
|
-
if ( name in morphAttrsArrays ) {
|
|
473
|
-
|
|
474
|
-
for ( let j = 0; j < morphAttrsArrays[ name ].length; j ++ ) {
|
|
475
|
-
|
|
476
|
-
const oldMorphAttribute = geometry.morphAttributes[ name ][ j ];
|
|
477
|
-
const buffer = new oldMorphAttribute.array.constructor( morphAttrsArrays[ name ][ j ] );
|
|
478
|
-
const morphAttribute = new THREE.BufferAttribute( buffer, oldMorphAttribute.itemSize, oldMorphAttribute.normalized );
|
|
479
|
-
result.morphAttributes[ name ][ j ] = morphAttribute;
|
|
480
|
-
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
} // indices
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
result.setIndex( newIndices );
|
|
489
|
-
return result;
|
|
490
|
-
|
|
491
|
-
}
|
|
492
|
-
/**
|
|
493
|
-
* @param {BufferGeometry} geometry
|
|
494
|
-
* @param {number} drawMode
|
|
495
|
-
* @return {BufferGeometry>}
|
|
496
|
-
*/
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
static toTrianglesDrawMode( geometry, drawMode ) {
|
|
500
|
-
|
|
501
|
-
if ( drawMode === THREE.TrianglesDrawMode ) {
|
|
502
|
-
|
|
503
|
-
console.warn( 'THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.' );
|
|
504
|
-
return geometry;
|
|
505
|
-
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
if ( drawMode === THREE.TriangleFanDrawMode || drawMode === THREE.TriangleStripDrawMode ) {
|
|
509
|
-
|
|
510
|
-
let index = geometry.getIndex(); // generate index if not present
|
|
511
|
-
|
|
512
|
-
if ( index === null ) {
|
|
513
|
-
|
|
514
|
-
const indices = [];
|
|
515
|
-
const position = geometry.getAttribute( 'position' );
|
|
516
|
-
|
|
517
|
-
if ( position !== undefined ) {
|
|
518
|
-
|
|
519
|
-
for ( let i = 0; i < position.count; i ++ ) {
|
|
520
|
-
|
|
521
|
-
indices.push( i );
|
|
522
|
-
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
geometry.setIndex( indices );
|
|
526
|
-
index = geometry.getIndex();
|
|
527
|
-
|
|
528
|
-
} else {
|
|
529
|
-
|
|
530
|
-
console.error( 'THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.' );
|
|
531
|
-
return geometry;
|
|
532
|
-
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
} //
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
const numberOfTriangles = index.count - 2;
|
|
539
|
-
const newIndices = [];
|
|
540
|
-
|
|
541
|
-
if ( drawMode === THREE.TriangleFanDrawMode ) {
|
|
542
|
-
|
|
543
|
-
// gl.TRIANGLE_FAN
|
|
544
|
-
for ( let i = 1; i <= numberOfTriangles; i ++ ) {
|
|
545
|
-
|
|
546
|
-
newIndices.push( index.getX( 0 ) );
|
|
547
|
-
newIndices.push( index.getX( i ) );
|
|
548
|
-
newIndices.push( index.getX( i + 1 ) );
|
|
549
|
-
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
} else {
|
|
553
|
-
|
|
554
|
-
// gl.TRIANGLE_STRIP
|
|
555
|
-
for ( let i = 0; i < numberOfTriangles; i ++ ) {
|
|
556
|
-
|
|
557
|
-
if ( i % 2 === 0 ) {
|
|
558
|
-
|
|
559
|
-
newIndices.push( index.getX( i ) );
|
|
560
|
-
newIndices.push( index.getX( i + 1 ) );
|
|
561
|
-
newIndices.push( index.getX( i + 2 ) );
|
|
562
|
-
|
|
563
|
-
} else {
|
|
564
|
-
|
|
565
|
-
newIndices.push( index.getX( i + 2 ) );
|
|
566
|
-
newIndices.push( index.getX( i + 1 ) );
|
|
567
|
-
newIndices.push( index.getX( i ) );
|
|
568
|
-
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
if ( newIndices.length / 3 !== numberOfTriangles ) {
|
|
576
|
-
|
|
577
|
-
console.error( 'THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.' );
|
|
578
|
-
|
|
579
|
-
} // build final geometry
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
const newGeometry = geometry.clone();
|
|
583
|
-
newGeometry.setIndex( newIndices );
|
|
584
|
-
newGeometry.clearGroups();
|
|
585
|
-
return newGeometry;
|
|
586
|
-
|
|
587
|
-
} else {
|
|
588
|
-
|
|
589
|
-
console.error( 'THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:', drawMode );
|
|
590
|
-
return geometry;
|
|
591
|
-
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
}
|
|
595
|
-
/**
|
|
596
|
-
* Calculates the morphed attributes of a morphed/skinned THREE.BufferGeometry.
|
|
597
|
-
* Helpful for Raytracing or Decals.
|
|
598
|
-
* @param {Mesh | Line | Points} object An instance of Mesh, Line or Points.
|
|
599
|
-
* @return {Object} An Object with original position/normal attributes and morphed ones.
|
|
600
|
-
*/
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
static computeMorphedAttributes( object ) {
|
|
604
|
-
|
|
605
|
-
if ( object.geometry.isBufferGeometry !== true ) {
|
|
606
|
-
|
|
607
|
-
console.error( 'THREE.BufferGeometryUtils: Geometry is not of type THREE.BufferGeometry.' );
|
|
608
|
-
return null;
|
|
609
|
-
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
const _vA = new THREE.Vector3();
|
|
613
|
-
|
|
614
|
-
const _vB = new THREE.Vector3();
|
|
615
|
-
|
|
616
|
-
const _vC = new THREE.Vector3();
|
|
617
|
-
|
|
618
|
-
const _tempA = new THREE.Vector3();
|
|
619
|
-
|
|
620
|
-
const _tempB = new THREE.Vector3();
|
|
621
|
-
|
|
622
|
-
const _tempC = new THREE.Vector3();
|
|
623
|
-
|
|
624
|
-
const _morphA = new THREE.Vector3();
|
|
625
|
-
|
|
626
|
-
const _morphB = new THREE.Vector3();
|
|
627
|
-
|
|
628
|
-
const _morphC = new THREE.Vector3();
|
|
629
|
-
|
|
630
|
-
function _calculateMorphedAttributeData( object, material, attribute, morphAttribute, morphTargetsRelative, a, b, c, modifiedAttributeArray ) {
|
|
631
|
-
|
|
632
|
-
_vA.fromBufferAttribute( attribute, a );
|
|
633
|
-
|
|
634
|
-
_vB.fromBufferAttribute( attribute, b );
|
|
635
|
-
|
|
636
|
-
_vC.fromBufferAttribute( attribute, c );
|
|
637
|
-
|
|
638
|
-
const morphInfluences = object.morphTargetInfluences;
|
|
639
|
-
|
|
640
|
-
if ( material.morphTargets && morphAttribute && morphInfluences ) {
|
|
641
|
-
|
|
642
|
-
_morphA.set( 0, 0, 0 );
|
|
643
|
-
|
|
644
|
-
_morphB.set( 0, 0, 0 );
|
|
645
|
-
|
|
646
|
-
_morphC.set( 0, 0, 0 );
|
|
647
|
-
|
|
648
|
-
for ( let i = 0, il = morphAttribute.length; i < il; i ++ ) {
|
|
649
|
-
|
|
650
|
-
const influence = morphInfluences[ i ];
|
|
651
|
-
const morph = morphAttribute[ i ];
|
|
652
|
-
if ( influence === 0 ) continue;
|
|
653
|
-
|
|
654
|
-
_tempA.fromBufferAttribute( morph, a );
|
|
655
|
-
|
|
656
|
-
_tempB.fromBufferAttribute( morph, b );
|
|
657
|
-
|
|
658
|
-
_tempC.fromBufferAttribute( morph, c );
|
|
659
|
-
|
|
660
|
-
if ( morphTargetsRelative ) {
|
|
661
|
-
|
|
662
|
-
_morphA.addScaledVector( _tempA, influence );
|
|
663
|
-
|
|
664
|
-
_morphB.addScaledVector( _tempB, influence );
|
|
665
|
-
|
|
666
|
-
_morphC.addScaledVector( _tempC, influence );
|
|
667
|
-
|
|
668
|
-
} else {
|
|
669
|
-
|
|
670
|
-
_morphA.addScaledVector( _tempA.sub( _vA ), influence );
|
|
671
|
-
|
|
672
|
-
_morphB.addScaledVector( _tempB.sub( _vB ), influence );
|
|
673
|
-
|
|
674
|
-
_morphC.addScaledVector( _tempC.sub( _vC ), influence );
|
|
675
|
-
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
_vA.add( _morphA );
|
|
681
|
-
|
|
682
|
-
_vB.add( _morphB );
|
|
683
|
-
|
|
684
|
-
_vC.add( _morphC );
|
|
685
|
-
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
if ( object.isSkinnedMesh ) {
|
|
689
|
-
|
|
690
|
-
object.boneTransform( a, _vA );
|
|
691
|
-
object.boneTransform( b, _vB );
|
|
692
|
-
object.boneTransform( c, _vC );
|
|
693
|
-
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
modifiedAttributeArray[ a * 3 + 0 ] = _vA.x;
|
|
697
|
-
modifiedAttributeArray[ a * 3 + 1 ] = _vA.y;
|
|
698
|
-
modifiedAttributeArray[ a * 3 + 2 ] = _vA.z;
|
|
699
|
-
modifiedAttributeArray[ b * 3 + 0 ] = _vB.x;
|
|
700
|
-
modifiedAttributeArray[ b * 3 + 1 ] = _vB.y;
|
|
701
|
-
modifiedAttributeArray[ b * 3 + 2 ] = _vB.z;
|
|
702
|
-
modifiedAttributeArray[ c * 3 + 0 ] = _vC.x;
|
|
703
|
-
modifiedAttributeArray[ c * 3 + 1 ] = _vC.y;
|
|
704
|
-
modifiedAttributeArray[ c * 3 + 2 ] = _vC.z;
|
|
705
|
-
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
const geometry = object.geometry;
|
|
709
|
-
const material = object.material;
|
|
710
|
-
let a, b, c;
|
|
711
|
-
const index = geometry.index;
|
|
712
|
-
const positionAttribute = geometry.attributes.position;
|
|
713
|
-
const morphPosition = geometry.morphAttributes.position;
|
|
714
|
-
const morphTargetsRelative = geometry.morphTargetsRelative;
|
|
715
|
-
const normalAttribute = geometry.attributes.normal;
|
|
716
|
-
const morphNormal = geometry.morphAttributes.position;
|
|
717
|
-
const groups = geometry.groups;
|
|
718
|
-
const drawRange = geometry.drawRange;
|
|
719
|
-
let i, j, il, jl;
|
|
720
|
-
let group, groupMaterial;
|
|
721
|
-
let start, end;
|
|
722
|
-
const modifiedPosition = new Float32Array( positionAttribute.count * positionAttribute.itemSize );
|
|
723
|
-
const modifiedNormal = new Float32Array( normalAttribute.count * normalAttribute.itemSize );
|
|
724
|
-
|
|
725
|
-
if ( index !== null ) {
|
|
726
|
-
|
|
727
|
-
// indexed buffer geometry
|
|
728
|
-
if ( Array.isArray( material ) ) {
|
|
729
|
-
|
|
730
|
-
for ( i = 0, il = groups.length; i < il; i ++ ) {
|
|
731
|
-
|
|
732
|
-
group = groups[ i ];
|
|
733
|
-
groupMaterial = material[ group.materialIndex ];
|
|
734
|
-
start = Math.max( group.start, drawRange.start );
|
|
735
|
-
end = Math.min( group.start + group.count, drawRange.start + drawRange.count );
|
|
736
|
-
|
|
737
|
-
for ( j = start, jl = end; j < jl; j += 3 ) {
|
|
738
|
-
|
|
739
|
-
a = index.getX( j );
|
|
740
|
-
b = index.getX( j + 1 );
|
|
741
|
-
c = index.getX( j + 2 );
|
|
742
|
-
|
|
743
|
-
_calculateMorphedAttributeData( object, groupMaterial, positionAttribute, morphPosition, morphTargetsRelative, a, b, c, modifiedPosition );
|
|
744
|
-
|
|
745
|
-
_calculateMorphedAttributeData( object, groupMaterial, normalAttribute, morphNormal, morphTargetsRelative, a, b, c, modifiedNormal );
|
|
746
|
-
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
} else {
|
|
752
|
-
|
|
753
|
-
start = Math.max( 0, drawRange.start );
|
|
754
|
-
end = Math.min( index.count, drawRange.start + drawRange.count );
|
|
755
|
-
|
|
756
|
-
for ( i = start, il = end; i < il; i += 3 ) {
|
|
757
|
-
|
|
758
|
-
a = index.getX( i );
|
|
759
|
-
b = index.getX( i + 1 );
|
|
760
|
-
c = index.getX( i + 2 );
|
|
761
|
-
|
|
762
|
-
_calculateMorphedAttributeData( object, material, positionAttribute, morphPosition, morphTargetsRelative, a, b, c, modifiedPosition );
|
|
763
|
-
|
|
764
|
-
_calculateMorphedAttributeData( object, material, normalAttribute, morphNormal, morphTargetsRelative, a, b, c, modifiedNormal );
|
|
765
|
-
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
} else if ( positionAttribute !== undefined ) {
|
|
771
|
-
|
|
772
|
-
// non-indexed buffer geometry
|
|
773
|
-
if ( Array.isArray( material ) ) {
|
|
774
|
-
|
|
775
|
-
for ( i = 0, il = groups.length; i < il; i ++ ) {
|
|
776
|
-
|
|
777
|
-
group = groups[ i ];
|
|
778
|
-
groupMaterial = material[ group.materialIndex ];
|
|
779
|
-
start = Math.max( group.start, drawRange.start );
|
|
780
|
-
end = Math.min( group.start + group.count, drawRange.start + drawRange.count );
|
|
781
|
-
|
|
782
|
-
for ( j = start, jl = end; j < jl; j += 3 ) {
|
|
783
|
-
|
|
784
|
-
a = j;
|
|
785
|
-
b = j + 1;
|
|
786
|
-
c = j + 2;
|
|
787
|
-
|
|
788
|
-
_calculateMorphedAttributeData( object, groupMaterial, positionAttribute, morphPosition, morphTargetsRelative, a, b, c, modifiedPosition );
|
|
789
|
-
|
|
790
|
-
_calculateMorphedAttributeData( object, groupMaterial, normalAttribute, morphNormal, morphTargetsRelative, a, b, c, modifiedNormal );
|
|
791
|
-
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
} else {
|
|
797
|
-
|
|
798
|
-
start = Math.max( 0, drawRange.start );
|
|
799
|
-
end = Math.min( positionAttribute.count, drawRange.start + drawRange.count );
|
|
800
|
-
|
|
801
|
-
for ( i = start, il = end; i < il; i += 3 ) {
|
|
802
|
-
|
|
803
|
-
a = i;
|
|
804
|
-
b = i + 1;
|
|
805
|
-
c = i + 2;
|
|
806
|
-
|
|
807
|
-
_calculateMorphedAttributeData( object, material, positionAttribute, morphPosition, morphTargetsRelative, a, b, c, modifiedPosition );
|
|
808
|
-
|
|
809
|
-
_calculateMorphedAttributeData( object, material, normalAttribute, morphNormal, morphTargetsRelative, a, b, c, modifiedNormal );
|
|
810
|
-
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
const morphedPositionAttribute = new THREE.Float32BufferAttribute( modifiedPosition, 3 );
|
|
818
|
-
const morphedNormalAttribute = new THREE.Float32BufferAttribute( modifiedNormal, 3 );
|
|
819
|
-
return {
|
|
820
|
-
positionAttribute: positionAttribute,
|
|
821
|
-
normalAttribute: normalAttribute,
|
|
822
|
-
morphedPositionAttribute: morphedPositionAttribute,
|
|
823
|
-
morphedNormalAttribute: morphedNormalAttribute
|
|
824
|
-
};
|
|
825
|
-
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
THREE.BufferGeometryUtils = BufferGeometryUtils;
|
|
831
|
-
|
|
832
|
-
} )();
|