@realsee/five 5.0.0-alpha.13 → 5.0.0-alpha.132
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 +1413 -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.Five.html +303 -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 +17 -0
- package/docs/classes/five.PBMMesh.html +7 -0
- package/docs/classes/five.PanoCircleMesh.html +7 -0
- package/docs/classes/five.Scene.html +3 -0
- package/docs/classes/five.Subscribe.html +56 -0
- package/docs/classes/five.Tile3DModel.html +15 -0
- package/docs/classes/five.Work.html +30 -0
- package/docs/classes/gltf_loader.GLTFLoader.html +17 -0
- package/docs/classes/gltf_loader.GLTFObject.html +7 -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.DepthPanoramaControllerCustomInitArgs.html +28 -0
- package/docs/interfaces/five.EventCallback.html +391 -0
- package/docs/interfaces/five.FiveInitArgs.html +105 -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.PBMPanoPicture.html +7 -0
- package/docs/interfaces/five.PBMParameters.html +17 -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.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/gltf_loader.GLTF.html +7 -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 +482 -0
- package/docs/modules/gltf_loader.html +1 -0
- package/docs/modules/line.html +1 -0
- package/docs/modules/react.html +130 -1178
- 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/{index.d.ts → five/index.d.ts} +1196 -322
- package/five/index.js +372 -0
- package/gltf-loader/index.d.ts +75 -0
- package/gltf-loader/index.js +260 -0
- package/line/index.d.ts +68 -0
- package/line/index.js +260 -0
- package/package.json +25 -17
- package/react/index.d.ts +160 -92
- 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 +194 -25
- package/server/index.js +367 -1
- package/sticker/index.d.ts +70 -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 +2 -0
- package/umd/five-gltf-loader.js.LICENSE.txt +14 -0
- package/umd/five-line.js +2 -0
- package/umd/five-line.js.LICENSE.txt +14 -0
- package/umd/five-react.js +2 -0
- package/umd/five-react.js.LICENSE.txt +14 -0
- package/umd/five-sticker.js +2 -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 +116 -0
- package/vue/index.d.ts +433 -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.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,602 +0,0 @@
|
|
|
1
|
-
var THREE = require('three')
|
|
2
|
-
/**
|
|
3
|
-
* Loads a Wavefront .mtl file specifying materials
|
|
4
|
-
*
|
|
5
|
-
* @author angelxuanchang
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
THREE.MTLLoader = function ( manager ) {
|
|
9
|
-
|
|
10
|
-
this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
THREE.MTLLoader.prototype = {
|
|
15
|
-
|
|
16
|
-
constructor: THREE.MTLLoader,
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Loads and parses a MTL asset from a URL.
|
|
20
|
-
*
|
|
21
|
-
* @param {String} url - URL to the MTL file.
|
|
22
|
-
* @param {Function} [onLoad] - Callback invoked with the loaded object.
|
|
23
|
-
* @param {Function} [onProgress] - Callback for download progress.
|
|
24
|
-
* @param {Function} [onError] - Callback for download errors.
|
|
25
|
-
*
|
|
26
|
-
* @see setPath setResourcePath
|
|
27
|
-
*
|
|
28
|
-
* @note In order for relative texture references to resolve correctly
|
|
29
|
-
* you must call setResourcePath() explicitly prior to load.
|
|
30
|
-
*/
|
|
31
|
-
load: function ( url, onLoad, onProgress, onError ) {
|
|
32
|
-
|
|
33
|
-
var scope = this;
|
|
34
|
-
|
|
35
|
-
var path = ( this.path === undefined ) ? THREE.LoaderUtils.extractUrlBase( url ) : this.path;
|
|
36
|
-
|
|
37
|
-
var loader = new THREE.FileLoader( this.manager );
|
|
38
|
-
loader.setPath( this.path );
|
|
39
|
-
loader.load( url, function ( text ) {
|
|
40
|
-
|
|
41
|
-
onLoad( scope.parse( text, path ) );
|
|
42
|
-
|
|
43
|
-
}, onProgress, onError );
|
|
44
|
-
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Set base path for resolving references.
|
|
49
|
-
* If set this path will be prepended to each loaded and found reference.
|
|
50
|
-
*
|
|
51
|
-
* @see setResourcePath
|
|
52
|
-
* @param {String} path
|
|
53
|
-
* @return {THREE.MTLLoader}
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* mtlLoader.setPath( 'assets/obj/' );
|
|
57
|
-
* mtlLoader.load( 'my.mtl', ... );
|
|
58
|
-
*/
|
|
59
|
-
setPath: function ( path ) {
|
|
60
|
-
|
|
61
|
-
this.path = path;
|
|
62
|
-
return this;
|
|
63
|
-
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Set base path for additional resources like textures.
|
|
68
|
-
*
|
|
69
|
-
* @see setPath
|
|
70
|
-
* @param {String} path
|
|
71
|
-
* @return {THREE.MTLLoader}
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* mtlLoader.setPath( 'assets/obj/' );
|
|
75
|
-
* mtlLoader.setResourcePath( 'assets/textures/' );
|
|
76
|
-
* mtlLoader.load( 'my.mtl', ... );
|
|
77
|
-
*/
|
|
78
|
-
setResourcePath: function ( path ) {
|
|
79
|
-
|
|
80
|
-
this.resourcePath = path;
|
|
81
|
-
return this;
|
|
82
|
-
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
setTexturePath: function ( path ) {
|
|
86
|
-
|
|
87
|
-
console.warn( 'THREE.MTLLoader: .setTexturePath() has been renamed to .setResourcePath().' );
|
|
88
|
-
return this.setResourcePath( path );
|
|
89
|
-
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
setCrossOrigin: function ( value ) {
|
|
93
|
-
|
|
94
|
-
this.crossOrigin = value;
|
|
95
|
-
return this;
|
|
96
|
-
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
setMaterialOptions: function ( value ) {
|
|
100
|
-
|
|
101
|
-
this.materialOptions = value;
|
|
102
|
-
return this;
|
|
103
|
-
|
|
104
|
-
},
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Parses a MTL file.
|
|
108
|
-
*
|
|
109
|
-
* @param {String} text - Content of MTL file
|
|
110
|
-
* @return {THREE.MTLLoader.MaterialCreator}
|
|
111
|
-
*
|
|
112
|
-
* @see setPath setResourcePath
|
|
113
|
-
*
|
|
114
|
-
* @note In order for relative texture references to resolve correctly
|
|
115
|
-
* you must call setResourcePath() explicitly prior to parse.
|
|
116
|
-
*/
|
|
117
|
-
parse: function ( text, path ) {
|
|
118
|
-
|
|
119
|
-
var lines = text.split( '\n' );
|
|
120
|
-
var info = {};
|
|
121
|
-
var delimiter_pattern = /\s+/;
|
|
122
|
-
var materialsInfo = {};
|
|
123
|
-
|
|
124
|
-
for ( var i = 0; i < lines.length; i ++ ) {
|
|
125
|
-
|
|
126
|
-
var line = lines[ i ];
|
|
127
|
-
line = line.trim();
|
|
128
|
-
|
|
129
|
-
if ( line.length === 0 || line.charAt( 0 ) === '#' ) {
|
|
130
|
-
|
|
131
|
-
// Blank line or comment ignore
|
|
132
|
-
continue;
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
var pos = line.indexOf( ' ' );
|
|
137
|
-
|
|
138
|
-
var key = ( pos >= 0 ) ? line.substring( 0, pos ) : line;
|
|
139
|
-
key = key.toLowerCase();
|
|
140
|
-
|
|
141
|
-
var value = ( pos >= 0 ) ? line.substring( pos + 1 ) : '';
|
|
142
|
-
value = value.trim();
|
|
143
|
-
|
|
144
|
-
if ( key === 'newmtl' ) {
|
|
145
|
-
|
|
146
|
-
// New material
|
|
147
|
-
|
|
148
|
-
info = { name: value };
|
|
149
|
-
materialsInfo[ value ] = info;
|
|
150
|
-
|
|
151
|
-
} else {
|
|
152
|
-
|
|
153
|
-
if ( key === 'ka' || key === 'kd' || key === 'ks' || key ==='ke' ) {
|
|
154
|
-
|
|
155
|
-
var ss = value.split( delimiter_pattern, 3 );
|
|
156
|
-
info[ key ] = [ parseFloat( ss[ 0 ] ), parseFloat( ss[ 1 ] ), parseFloat( ss[ 2 ] ) ];
|
|
157
|
-
|
|
158
|
-
} else {
|
|
159
|
-
|
|
160
|
-
info[ key ] = value;
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
var materialCreator = new THREE.MTLLoader.MaterialCreator(
|
|
169
|
-
this.resourcePath || path,
|
|
170
|
-
this.materialOptions,
|
|
171
|
-
this.resourceURLHandle
|
|
172
|
-
);
|
|
173
|
-
materialCreator.setCrossOrigin( this.crossOrigin );
|
|
174
|
-
materialCreator.setManager( this.manager );
|
|
175
|
-
materialCreator.setMaterials( materialsInfo );
|
|
176
|
-
return materialCreator;
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Create a new THREE-MTLLoader.MaterialCreator
|
|
184
|
-
* @param baseUrl - Url relative to which textures are loaded
|
|
185
|
-
* @param options - Set of options on how to construct the materials
|
|
186
|
-
* side: Which side to apply the material
|
|
187
|
-
* THREE.FrontSide (default), THREE.BackSide, THREE.DoubleSide
|
|
188
|
-
* wrap: What type of wrapping to apply for textures
|
|
189
|
-
* THREE.RepeatWrapping (default), THREE.ClampToEdgeWrapping, THREE.MirroredRepeatWrapping
|
|
190
|
-
* normalizeRGB: RGBs need to be normalized to 0-1 from 0-255
|
|
191
|
-
* Default: false, assumed to be already normalized
|
|
192
|
-
* ignoreZeroRGBs: Ignore values of RGBs (Ka,Kd,Ks) that are all 0's
|
|
193
|
-
* Default: false
|
|
194
|
-
* @constructor
|
|
195
|
-
*/
|
|
196
|
-
|
|
197
|
-
THREE.MTLLoader.MaterialCreator = function ( baseUrl, options, resourceURLHandle ) {
|
|
198
|
-
this.baseUrl = baseUrl || '';
|
|
199
|
-
this.options = options;
|
|
200
|
-
this.materialsInfo = {};
|
|
201
|
-
this.materials = {};
|
|
202
|
-
this.materialsArray = [];
|
|
203
|
-
this.nameLookup = {};
|
|
204
|
-
this.resourceURLHandle = resourceURLHandle;
|
|
205
|
-
|
|
206
|
-
this.side = ( this.options && this.options.side ) ? this.options.side : THREE.FrontSide;
|
|
207
|
-
this.wrap = ( this.options && this.options.wrap ) ? this.options.wrap : THREE.RepeatWrapping;
|
|
208
|
-
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
THREE.MTLLoader.MaterialCreator.prototype = {
|
|
212
|
-
|
|
213
|
-
constructor: THREE.MTLLoader.MaterialCreator,
|
|
214
|
-
|
|
215
|
-
crossOrigin: 'anonymous',
|
|
216
|
-
|
|
217
|
-
setCrossOrigin: function ( value ) {
|
|
218
|
-
|
|
219
|
-
this.crossOrigin = value;
|
|
220
|
-
return this;
|
|
221
|
-
|
|
222
|
-
},
|
|
223
|
-
|
|
224
|
-
setManager: function ( value ) {
|
|
225
|
-
|
|
226
|
-
this.manager = value;
|
|
227
|
-
|
|
228
|
-
},
|
|
229
|
-
|
|
230
|
-
setMaterials: function ( materialsInfo ) {
|
|
231
|
-
|
|
232
|
-
this.materialsInfo = this.convert( materialsInfo );
|
|
233
|
-
this.materials = {};
|
|
234
|
-
this.materialsArray = [];
|
|
235
|
-
this.nameLookup = {};
|
|
236
|
-
|
|
237
|
-
},
|
|
238
|
-
|
|
239
|
-
convert: function ( materialsInfo ) {
|
|
240
|
-
|
|
241
|
-
if ( ! this.options ) return materialsInfo;
|
|
242
|
-
|
|
243
|
-
var converted = {};
|
|
244
|
-
|
|
245
|
-
for ( var mn in materialsInfo ) {
|
|
246
|
-
|
|
247
|
-
// Convert materials info into normalized form based on options
|
|
248
|
-
|
|
249
|
-
var mat = materialsInfo[ mn ];
|
|
250
|
-
|
|
251
|
-
var covmat = {};
|
|
252
|
-
|
|
253
|
-
converted[ mn ] = covmat;
|
|
254
|
-
|
|
255
|
-
for ( var prop in mat ) {
|
|
256
|
-
|
|
257
|
-
var save = true;
|
|
258
|
-
var value = mat[ prop ];
|
|
259
|
-
var lprop = prop.toLowerCase();
|
|
260
|
-
|
|
261
|
-
switch ( lprop ) {
|
|
262
|
-
|
|
263
|
-
case 'kd':
|
|
264
|
-
case 'ka':
|
|
265
|
-
case 'ks':
|
|
266
|
-
|
|
267
|
-
// Diffuse color (color under white light) using RGB values
|
|
268
|
-
|
|
269
|
-
if ( this.options && this.options.normalizeRGB ) {
|
|
270
|
-
|
|
271
|
-
value = [ value[ 0 ] / 255, value[ 1 ] / 255, value[ 2 ] / 255 ];
|
|
272
|
-
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
if ( this.options && this.options.ignoreZeroRGBs ) {
|
|
276
|
-
|
|
277
|
-
if ( value[ 0 ] === 0 && value[ 1 ] === 0 && value[ 2 ] === 0 ) {
|
|
278
|
-
|
|
279
|
-
// ignore
|
|
280
|
-
|
|
281
|
-
save = false;
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
break;
|
|
288
|
-
|
|
289
|
-
default:
|
|
290
|
-
|
|
291
|
-
break;
|
|
292
|
-
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
if ( save ) {
|
|
296
|
-
|
|
297
|
-
covmat[ lprop ] = value;
|
|
298
|
-
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
return converted;
|
|
306
|
-
|
|
307
|
-
},
|
|
308
|
-
|
|
309
|
-
preload: function () {
|
|
310
|
-
|
|
311
|
-
for ( var mn in this.materialsInfo ) {
|
|
312
|
-
|
|
313
|
-
this.create( mn );
|
|
314
|
-
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
},
|
|
318
|
-
|
|
319
|
-
getIndex: function ( materialName ) {
|
|
320
|
-
|
|
321
|
-
return this.nameLookup[ materialName ];
|
|
322
|
-
|
|
323
|
-
},
|
|
324
|
-
|
|
325
|
-
getAsArray: function () {
|
|
326
|
-
|
|
327
|
-
var index = 0;
|
|
328
|
-
|
|
329
|
-
for ( var mn in this.materialsInfo ) {
|
|
330
|
-
|
|
331
|
-
this.materialsArray[ index ] = this.create( mn );
|
|
332
|
-
this.nameLookup[ mn ] = index;
|
|
333
|
-
index ++;
|
|
334
|
-
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
return this.materialsArray;
|
|
338
|
-
|
|
339
|
-
},
|
|
340
|
-
|
|
341
|
-
create: function ( materialName ) {
|
|
342
|
-
|
|
343
|
-
if ( this.materials[ materialName ] === undefined ) {
|
|
344
|
-
|
|
345
|
-
this.createMaterial_( materialName );
|
|
346
|
-
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
return this.materials[ materialName ];
|
|
350
|
-
|
|
351
|
-
},
|
|
352
|
-
|
|
353
|
-
createMaterial_: function ( materialName ) {
|
|
354
|
-
|
|
355
|
-
// Create material
|
|
356
|
-
|
|
357
|
-
var scope = this;
|
|
358
|
-
var mat = this.materialsInfo[ materialName ];
|
|
359
|
-
var params = {
|
|
360
|
-
|
|
361
|
-
name: materialName,
|
|
362
|
-
side: this.side
|
|
363
|
-
|
|
364
|
-
};
|
|
365
|
-
|
|
366
|
-
function resolveURL( baseUrl, url ) {
|
|
367
|
-
|
|
368
|
-
if ( typeof url !== 'string' || url === '' )
|
|
369
|
-
return '';
|
|
370
|
-
|
|
371
|
-
// Absolute URL
|
|
372
|
-
if ( /^https?:\/\//i.test( url ) ) return url;
|
|
373
|
-
|
|
374
|
-
return baseUrl + url;
|
|
375
|
-
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
function setMapForType( mapType, value ) {
|
|
379
|
-
|
|
380
|
-
if ( params[ mapType ] ) return; // Keep the first encountered texture
|
|
381
|
-
|
|
382
|
-
var texParams = scope.getTextureParams( value, params );
|
|
383
|
-
var url = resolveURL( scope.baseUrl, texParams.url );
|
|
384
|
-
|
|
385
|
-
if (scope.resourceURLHandle) {
|
|
386
|
-
url = scope.resourceURLHandle(url);
|
|
387
|
-
}
|
|
388
|
-
var map;
|
|
389
|
-
if (typeof Image === 'undefined') {
|
|
390
|
-
map = new THREE.Texture();
|
|
391
|
-
map.image = { src: url, currentSrc: url };
|
|
392
|
-
} else {
|
|
393
|
-
map = scope.loadTexture( url );
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
map.repeat.copy( texParams.scale );
|
|
397
|
-
map.offset.copy( texParams.offset );
|
|
398
|
-
|
|
399
|
-
map.wrapS = scope.wrap;
|
|
400
|
-
map.wrapT = scope.wrap;
|
|
401
|
-
|
|
402
|
-
params[ mapType ] = map;
|
|
403
|
-
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
for ( var prop in mat ) {
|
|
407
|
-
|
|
408
|
-
var value = mat[ prop ];
|
|
409
|
-
var n;
|
|
410
|
-
|
|
411
|
-
if ( value === '' ) continue;
|
|
412
|
-
|
|
413
|
-
switch ( prop.toLowerCase() ) {
|
|
414
|
-
|
|
415
|
-
// Ns is material specular exponent
|
|
416
|
-
|
|
417
|
-
case 'kd':
|
|
418
|
-
|
|
419
|
-
// Diffuse color (color under white light) using RGB values
|
|
420
|
-
|
|
421
|
-
params.color = new THREE.Color().fromArray( value );
|
|
422
|
-
|
|
423
|
-
break;
|
|
424
|
-
|
|
425
|
-
case 'ks':
|
|
426
|
-
|
|
427
|
-
// Specular color (color when light is reflected from shiny surface) using RGB values
|
|
428
|
-
params.specular = new THREE.Color().fromArray( value );
|
|
429
|
-
|
|
430
|
-
break;
|
|
431
|
-
|
|
432
|
-
case 'ke':
|
|
433
|
-
|
|
434
|
-
// Emissive using RGB values
|
|
435
|
-
params.emissive = new THREE.Color().fromArray( value );
|
|
436
|
-
|
|
437
|
-
break;
|
|
438
|
-
|
|
439
|
-
case 'map_kd':
|
|
440
|
-
|
|
441
|
-
// Diffuse texture map
|
|
442
|
-
setMapForType( "map", value );
|
|
443
|
-
if ( mat.map_kd_repeat ) {
|
|
444
|
-
const repeat = Number( mat.map_kd_repeat );
|
|
445
|
-
params.map.repeat.set( repeat, repeat );
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
break;
|
|
449
|
-
|
|
450
|
-
case 'map_ks':
|
|
451
|
-
|
|
452
|
-
// Specular map
|
|
453
|
-
|
|
454
|
-
setMapForType( "specularMap", value );
|
|
455
|
-
|
|
456
|
-
break;
|
|
457
|
-
|
|
458
|
-
case 'map_ke':
|
|
459
|
-
|
|
460
|
-
// Emissive map
|
|
461
|
-
|
|
462
|
-
setMapForType( "emissiveMap", value );
|
|
463
|
-
|
|
464
|
-
break;
|
|
465
|
-
|
|
466
|
-
case 'norm':
|
|
467
|
-
|
|
468
|
-
setMapForType( "normalMap", value );
|
|
469
|
-
|
|
470
|
-
break;
|
|
471
|
-
|
|
472
|
-
case 'map_bump':
|
|
473
|
-
case 'bump':
|
|
474
|
-
|
|
475
|
-
// Bump texture map
|
|
476
|
-
|
|
477
|
-
setMapForType( "bumpMap", value );
|
|
478
|
-
|
|
479
|
-
break;
|
|
480
|
-
|
|
481
|
-
case 'map_d':
|
|
482
|
-
|
|
483
|
-
// Alpha map
|
|
484
|
-
|
|
485
|
-
setMapForType( "alphaMap", value );
|
|
486
|
-
params.transparent = true;
|
|
487
|
-
|
|
488
|
-
break;
|
|
489
|
-
|
|
490
|
-
case 'ns':
|
|
491
|
-
|
|
492
|
-
// The specular exponent (defines the focus of the specular highlight)
|
|
493
|
-
// A high exponent results in a tight, concentrated highlight. Ns values normally range from 0 to 1000.
|
|
494
|
-
|
|
495
|
-
params.shininess = parseFloat( value );
|
|
496
|
-
|
|
497
|
-
break;
|
|
498
|
-
|
|
499
|
-
case 'd':
|
|
500
|
-
n = parseFloat( value );
|
|
501
|
-
|
|
502
|
-
if ( n < 1 ) {
|
|
503
|
-
|
|
504
|
-
params.opacity = n;
|
|
505
|
-
params.transparent = true;
|
|
506
|
-
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
break;
|
|
510
|
-
|
|
511
|
-
case 'tr':
|
|
512
|
-
n = parseFloat( value );
|
|
513
|
-
|
|
514
|
-
if ( this.options && this.options.invertTrProperty ) n = 1 - n;
|
|
515
|
-
|
|
516
|
-
if ( n > 0 ) {
|
|
517
|
-
|
|
518
|
-
params.opacity = 1 - n;
|
|
519
|
-
params.transparent = true;
|
|
520
|
-
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
break;
|
|
524
|
-
|
|
525
|
-
default:
|
|
526
|
-
break;
|
|
527
|
-
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
this.materials[ materialName ] = new THREE.MeshPhongMaterial( params );
|
|
533
|
-
return this.materials[ materialName ];
|
|
534
|
-
|
|
535
|
-
},
|
|
536
|
-
|
|
537
|
-
getTextureParams: function ( value, matParams ) {
|
|
538
|
-
|
|
539
|
-
var texParams = {
|
|
540
|
-
|
|
541
|
-
scale: new THREE.Vector2( 1, 1 ),
|
|
542
|
-
offset: new THREE.Vector2( 0, 0 )
|
|
543
|
-
|
|
544
|
-
};
|
|
545
|
-
|
|
546
|
-
var items = value.split( /\s+/ );
|
|
547
|
-
var pos;
|
|
548
|
-
|
|
549
|
-
pos = items.indexOf( '-bm' );
|
|
550
|
-
|
|
551
|
-
if ( pos >= 0 ) {
|
|
552
|
-
|
|
553
|
-
matParams.bumpScale = parseFloat( items[ pos + 1 ] );
|
|
554
|
-
items.splice( pos, 2 );
|
|
555
|
-
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
pos = items.indexOf( '-s' );
|
|
559
|
-
|
|
560
|
-
if ( pos >= 0 ) {
|
|
561
|
-
|
|
562
|
-
texParams.scale.set( parseFloat( items[ pos + 1 ] ), parseFloat( items[ pos + 2 ] ) );
|
|
563
|
-
items.splice( pos, 4 ); // we expect 3 parameters here!
|
|
564
|
-
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
pos = items.indexOf( '-o' );
|
|
568
|
-
|
|
569
|
-
if ( pos >= 0 ) {
|
|
570
|
-
|
|
571
|
-
texParams.offset.set( parseFloat( items[ pos + 1 ] ), parseFloat( items[ pos + 2 ] ) );
|
|
572
|
-
items.splice( pos, 4 ); // we expect 3 parameters here!
|
|
573
|
-
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
texParams.url = items.join( ' ' ).trim();
|
|
577
|
-
return texParams;
|
|
578
|
-
|
|
579
|
-
},
|
|
580
|
-
|
|
581
|
-
loadTexture: function ( url, mapping, onLoad, onProgress, onError ) {
|
|
582
|
-
|
|
583
|
-
var texture;
|
|
584
|
-
var loader = null //THREE.Loader.Handlers.get( url );
|
|
585
|
-
var manager = ( this.manager !== undefined ) ? this.manager : THREE.DefaultLoadingManager;
|
|
586
|
-
|
|
587
|
-
if ( loader === null ) {
|
|
588
|
-
|
|
589
|
-
loader = new THREE.TextureLoader( manager );
|
|
590
|
-
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
if ( loader.setCrossOrigin ) loader.setCrossOrigin( this.crossOrigin );
|
|
594
|
-
texture = loader.load( url, onLoad, onProgress, onError );
|
|
595
|
-
|
|
596
|
-
if ( mapping !== undefined ) texture.mapping = mapping;
|
|
597
|
-
|
|
598
|
-
return texture;
|
|
599
|
-
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
};
|