@realsee/five 6.0.0-alpha.7 → 6.0.0-alpha.71

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.
Files changed (324) hide show
  1. package/TERMS.txt +0 -2
  2. package/docs/assets/highlight.css +20 -20
  3. package/docs/assets/main.js +59 -52
  4. package/docs/assets/navigation.js +1 -0
  5. package/docs/assets/search.js +1 -1
  6. package/docs/assets/style.css +805 -825
  7. package/docs/classes/five.AnimationFrameLoop.html +16 -15
  8. package/docs/classes/five.BoxBoundingVolume.html +18 -1
  9. package/docs/classes/five.Camera.html +37 -11
  10. package/docs/classes/five.CullingVolume.html +10 -1
  11. package/docs/classes/five.Fetcher.html +5 -0
  12. package/docs/classes/five.Five.html +237 -287
  13. package/docs/classes/five.InternalWebGLRenderer.html +2 -1
  14. package/docs/classes/five.IntersectMesh.html +4 -1
  15. package/docs/classes/five.Model.html +62 -55
  16. package/docs/classes/five.NetworkAbortError.html +2 -0
  17. package/docs/classes/five.NetworkFirbiddenError.html +2 -0
  18. package/docs/classes/five.NetworkResponseError.html +3 -0
  19. package/docs/classes/five.NetworkSubscribe.html +42 -56
  20. package/docs/classes/five.NetworkTimeoutError.html +2 -0
  21. package/docs/classes/five.PBMContainer.html +12 -13
  22. package/docs/classes/five.PBMGroup.html +3 -3
  23. package/docs/classes/five.PBMMesh.html +4 -5
  24. package/docs/classes/five.PBMMeshMaterial.html +50 -45
  25. package/docs/classes/five.PanoCircleMesh.html +30 -7
  26. package/docs/classes/five.PanoCircleMeshCustom.html +30 -7
  27. package/docs/classes/five.PanoCircleMeshSolid.html +30 -7
  28. package/docs/classes/five.RegionBoundingVolume.html +21 -1
  29. package/docs/classes/five.RequestScheduler.html +13 -12
  30. package/docs/classes/five.Scene.html +5 -3
  31. package/docs/classes/five.SphereBoundingVolume.html +17 -1
  32. package/docs/classes/five.Subscribe.html +43 -62
  33. package/docs/classes/five.TextureLoader.html +5 -1
  34. package/docs/classes/five.Tile.html +30 -1
  35. package/docs/classes/five.Tile3DModel.html +28 -1
  36. package/docs/classes/five.TileCubeTextureTarget.html +9 -1
  37. package/docs/classes/five.TileNode.html +4 -1
  38. package/docs/classes/five.Tileset.html +31 -5
  39. package/docs/classes/five.TilesetCache.html +8 -1
  40. package/docs/classes/five.TilesetTraverser.html +19 -1
  41. package/docs/classes/five.Work.html +28 -28
  42. package/docs/classes/five.XRButton.html +3 -1
  43. package/docs/classes/gltf_loader.DDSLoader.html +3 -1
  44. package/docs/classes/gltf_loader.DRACOLoader.html +8 -1
  45. package/docs/classes/gltf_loader.GLTFLoader.html +18 -17
  46. package/docs/classes/gltf_loader.GLTFObject.html +8 -6
  47. package/docs/classes/gltf_loader.GLTFParser.html +6 -1
  48. package/docs/classes/gltf_loader.THREEGLTFLoader.html +8 -1
  49. package/docs/classes/line.Line.html +10 -1
  50. package/docs/classes/line.LineGeometry.html +14 -1
  51. package/docs/classes/line.LineMaterial.html +8 -1
  52. package/docs/classes/line.LineSegmentsGeometry.html +12 -1
  53. package/docs/classes/line.THREE_Line2.html +4 -1
  54. package/docs/classes/line.THREE_LineSegments2.html +4 -1
  55. package/docs/classes/react.Store.html +23 -29
  56. package/docs/classes/sticker.Sticker.html +25 -32
  57. package/docs/classes/vfx.Airflow.html +8 -1
  58. package/docs/classes/vfx.Flame.html +10 -1
  59. package/docs/classes/vfx.Particle.html +79 -82
  60. package/docs/classes/vfx.SpotLight.html +7 -1
  61. package/docs/enums/five.VolumePlaneIntersect.html +4 -1
  62. package/docs/functions/five.defaultImageURLTransform.html +5 -0
  63. package/docs/functions/five.getViewportScale.html +1 -0
  64. package/docs/functions/five.imageSupport.html +1 -0
  65. package/docs/functions/five.isPanoId.html +1 -0
  66. package/docs/functions/five.loadAt3d.html +1 -0
  67. package/docs/functions/five.loadB3dm.html +1 -0
  68. package/docs/functions/five.loadDome.html +1 -0
  69. package/docs/functions/five.loadDomez.html +1 -0
  70. package/docs/functions/five.loadPbm.html +1 -0
  71. package/docs/functions/five.loadPnts.html +1 -0
  72. package/docs/functions/five.panoEqual.html +1 -0
  73. package/docs/functions/five.panoParse.html +1 -0
  74. package/docs/functions/five.panoStringify.html +1 -0
  75. package/docs/functions/five.parseWork.html +7 -0
  76. package/docs/functions/react.FiveCanvas-1.html +6 -0
  77. package/docs/functions/react.createFiveFeature.html +1 -0
  78. package/docs/functions/react.createFiveProvider.html +9 -0
  79. package/docs/functions/react.createStore.html +15 -0
  80. package/docs/functions/react.unsafe__useFiveInstance.html +5 -0
  81. package/docs/functions/react.useFiveAction.html +19 -0
  82. package/docs/functions/react.useFiveCameraDirection.html +3 -0
  83. package/docs/functions/react.useFiveCameraRaycaster.html +3 -0
  84. package/docs/functions/react.useFiveCurrentObserver.html +5 -0
  85. package/docs/functions/react.useFiveCurrentState.html +5 -0
  86. package/docs/functions/react.useFiveEventCallback.html +5 -0
  87. package/docs/functions/react.useFiveFloor.html +5 -0
  88. package/docs/functions/react.useFiveHelper.html +5 -0
  89. package/docs/functions/react.useFiveModelIntersectRaycaster.html +7 -0
  90. package/docs/functions/react.useFiveModelReadyState.html +4 -0
  91. package/docs/functions/react.useFiveProject2d.html +7 -0
  92. package/docs/functions/react.useFiveScene.html +2 -0
  93. package/docs/functions/react.useFiveSceneEffect.html +5 -0
  94. package/docs/functions/react.useFiveState.html +1 -0
  95. package/docs/functions/react.useFiveWork.html +8 -0
  96. package/docs/functions/react.withFive.html +1 -0
  97. package/docs/functions/vue.unsafe__useFiveInject.html +5 -0
  98. package/docs/functions/vue.useFiveAction.html +25 -0
  99. package/docs/functions/vue.useFiveCameraDirection.html +3 -0
  100. package/docs/functions/vue.useFiveCameraRaycaster.html +3 -0
  101. package/docs/functions/vue.useFiveCurrentObserver.html +5 -0
  102. package/docs/functions/vue.useFiveCurrentState.html +5 -0
  103. package/docs/functions/vue.useFiveEventCallback.html +5 -0
  104. package/docs/functions/vue.useFiveFloor.html +5 -0
  105. package/docs/functions/vue.useFiveHelper.html +5 -0
  106. package/docs/functions/vue.useFiveModel.html +2 -0
  107. package/docs/functions/vue.useFiveModelBounding.html +2 -0
  108. package/docs/functions/vue.useFiveModelIntersectRaycaster.html +7 -0
  109. package/docs/functions/vue.useFiveModelReadyState.html +4 -0
  110. package/docs/functions/vue.useFiveProject2d.html +7 -0
  111. package/docs/functions/vue.useFiveScene.html +2 -0
  112. package/docs/functions/vue.useFiveState.html +5 -0
  113. package/docs/functions/vue.useFiveWorks.html +8 -0
  114. package/docs/index.html +35 -79
  115. package/docs/interfaces/five.AddableObject.html +9 -9
  116. package/docs/interfaces/five.AjaxOptions.html +11 -0
  117. package/docs/interfaces/five.AnimationFrame.html +5 -1
  118. package/docs/interfaces/five.BaseEvent.html +5 -1
  119. package/docs/interfaces/five.BoundingVolume.html +14 -1
  120. package/docs/interfaces/five.CameraPose.html +6 -1
  121. package/docs/interfaces/five.ClipperParameter.html +3 -1
  122. package/docs/interfaces/five.DepthPanoramaControllerCustomInitArgs.html +25 -25
  123. package/docs/interfaces/five.EventCallback.html +355 -452
  124. package/docs/interfaces/five.FiveInitArgs.html +84 -86
  125. package/docs/interfaces/five.FloorplanControllerCustomInitArgs.html +17 -15
  126. package/docs/interfaces/five.GestureEvent.html +19 -1
  127. package/docs/interfaces/five.ImageOptions.html +16 -18
  128. package/docs/interfaces/five.ImageURLMappings.html +1 -1
  129. package/docs/interfaces/five.ImageURLOptions.html +15 -15
  130. package/docs/interfaces/five.IntersectEvent.html +8 -1
  131. package/docs/interfaces/five.IntersectMeshInterface.html +3 -3
  132. package/docs/interfaces/five.Intersection.html +3 -7
  133. package/docs/interfaces/five.MapviewControllerCustomInitArgs.html +13 -11
  134. package/docs/interfaces/five.ModeChangeEvent.html +9 -1
  135. package/docs/interfaces/five.ModelControllerCustomInitArgs.html +18 -18
  136. package/docs/interfaces/five.ModelEvent.html +8 -1
  137. package/docs/interfaces/five.ModelLodOptions.html +2 -1
  138. package/docs/interfaces/five.ModelsEvent.html +6 -1
  139. package/docs/interfaces/five.MotionKeyframe.html +4 -1
  140. package/docs/interfaces/five.MovePanoOptions.html +29 -30
  141. package/docs/interfaces/five.NetworkOptions.html +9 -9
  142. package/docs/interfaces/five.NetworkResourceEvent.html +9 -1
  143. package/docs/interfaces/five.ObjectEvent.html +6 -1
  144. package/docs/interfaces/five.PBMPanoPicture.html +7 -7
  145. package/docs/interfaces/five.PBMParameters.html +42 -43
  146. package/docs/interfaces/five.PanoCircleMeshCustomOptions.html +9 -1
  147. package/docs/interfaces/five.PanoCircleMeshInterface.html +21 -10
  148. package/docs/interfaces/five.PanoCircleMeshOptions.html +3 -1
  149. package/docs/interfaces/five.PanoCircleMeshSolidOptions.html +3 -1
  150. package/docs/interfaces/five.PanoEvent.html +11 -1
  151. package/docs/interfaces/five.PanoTextureEvent.html +9 -1
  152. package/docs/interfaces/five.PanoramaControllerCustomInitArgs.html +32 -32
  153. package/docs/interfaces/five.PanoramaLikeControllerCustomInitArgs.html +18 -18
  154. package/docs/interfaces/five.Pose.html +15 -32
  155. package/docs/interfaces/five.RenderEvent.html +7 -1
  156. package/docs/interfaces/five.Scissor.html +11 -12
  157. package/docs/interfaces/five.State.html +20 -21
  158. package/docs/interfaces/five.StateEvent.html +7 -1
  159. package/docs/interfaces/five.SubscribeMixinType.emit.html +1 -1
  160. package/docs/interfaces/five.SubscribeMixinType.hasListener.html +1 -1
  161. package/docs/interfaces/five.SubscribeMixinType.off.html +1 -1
  162. package/docs/interfaces/five.SubscribeMixinType.on.html +1 -1
  163. package/docs/interfaces/five.SubscribeMixinType.once.html +1 -1
  164. package/docs/interfaces/five.SubscribeMixinType.waitUnitl.html +1 -1
  165. package/docs/interfaces/five.TextureOptions.html +18 -20
  166. package/docs/interfaces/five.Tile3DModelLoaderOptions.html +6 -3
  167. package/docs/interfaces/five.TileCubeNode.html +7 -1
  168. package/docs/interfaces/five.TileCubeTree.html +2 -1
  169. package/docs/interfaces/five.TileHeader.html +9 -1
  170. package/docs/interfaces/five.TilesetHeader.html +5 -1
  171. package/docs/interfaces/five.TilesetOptions.html +5 -1
  172. package/docs/interfaces/five.TopviewControllerCustomInitArgs.html +9 -9
  173. package/docs/interfaces/five.VRPanoramaControllerCustomInitArgs.html +28 -28
  174. package/docs/interfaces/five.WebXRAxesParams.html +4 -0
  175. package/docs/interfaces/five.WebXRControllerParams.html +2 -1
  176. package/docs/interfaces/five.WorkCubeImage.html +13 -13
  177. package/docs/interfaces/five.WorkImage.html +20 -21
  178. package/docs/interfaces/five.WorkInitial.html +17 -17
  179. package/docs/interfaces/five.WorkModel.html +12 -13
  180. package/docs/interfaces/five.WorkObserver.html +40 -39
  181. package/docs/interfaces/five.WorkOptions.html +17 -15
  182. package/docs/interfaces/five.WorkResolvedObserver.html +41 -37
  183. package/docs/interfaces/five.WorkTile.html +9 -1
  184. package/docs/interfaces/five.WorkVideo.html +8 -9
  185. package/docs/interfaces/five.WorksEvent.html +9 -1
  186. package/docs/interfaces/five.XRControllerEvent.html +8 -0
  187. package/docs/interfaces/five.XRGestureEvent.html +11 -1
  188. package/docs/interfaces/five.XRPanoramaControllerCustomInitArgs.html +29 -28
  189. package/docs/interfaces/five.XRSessionEvent.html +7 -1
  190. package/docs/interfaces/gltf_loader.DDS.html +7 -1
  191. package/docs/interfaces/gltf_loader.GLTF.html +10 -4
  192. package/docs/interfaces/gltf_loader.GLTFReference.html +3 -1
  193. package/docs/interfaces/gltf_loader.THREEGLTF.html +8 -1
  194. package/docs/interfaces/react.FiveActionReactCallbacks.html +27 -37
  195. package/docs/interfaces/react.FiveInjectionTypes.html +113 -138
  196. package/docs/interfaces/react.PropTypeOfFiveFeatures.html +2 -1
  197. package/docs/interfaces/sticker.IntersectionLike.html +7 -8
  198. package/docs/interfaces/vfx.ParticleArgs.html +67 -68
  199. package/docs/interfaces/vfx.ParticleTweenKeyframe.html +3 -1
  200. package/docs/interfaces/vue.FiveActionVueCallbacks.html +31 -42
  201. package/docs/modules/five.SubscribeMixinType.html +7 -1
  202. package/docs/modules/five.html +171 -631
  203. package/docs/modules/gltf_loader.html +11 -1
  204. package/docs/modules/line.html +8 -1
  205. package/docs/modules/react.FiveCanvas.html +8 -0
  206. package/docs/modules/react.html +37 -130
  207. package/docs/modules/sticker.html +3 -1
  208. package/docs/modules/vfx.html +8 -1
  209. package/docs/modules/vue.html +24 -115
  210. package/docs/types/five.AjaxResponseType.html +1 -0
  211. package/docs/types/five.AjaxResponseTypeMapping.html +1 -0
  212. package/docs/types/five.BoundingVolumeJson.html +1 -0
  213. package/docs/types/five.BoxBoundingVolumeJson.html +1 -0
  214. package/docs/types/five.ControllerCustomInitTypes.html +1 -0
  215. package/docs/types/five.ControllerEventTypes.html +32 -0
  216. package/docs/types/five.CoordinatesSystemTransformer.html +1 -0
  217. package/docs/types/five.EventTypes.html +26 -0
  218. package/docs/types/five.FivePlugin.html +71 -0
  219. package/docs/types/five.FivePluginInit.html +3 -0
  220. package/docs/types/five.FivePluginInstance.html +3 -0
  221. package/docs/types/five.GestureTypes.html +1 -0
  222. package/docs/types/five.LegacyEventType.html +203 -0
  223. package/docs/types/five.LooseWork.html +1 -0
  224. package/docs/types/five.LooseWorkInitial.html +1 -0
  225. package/docs/types/five.LooseWorkModel.html +1 -0
  226. package/docs/types/five.LooseWorkObserver.html +1 -0
  227. package/docs/types/five.LooseWorkPanorama.html +1 -0
  228. package/docs/types/five.LooseWorkVideo.html +1 -0
  229. package/docs/types/five.LooseWorkWithExtrinsics.html +8 -0
  230. package/docs/types/five.Mirror.html +1 -0
  231. package/docs/types/five.Mode.html +11 -0
  232. package/docs/types/five.ModelMaterialValues.html +1 -0
  233. package/docs/types/five.Models.html +12 -0
  234. package/docs/types/five.MotionValue.html +1 -0
  235. package/docs/types/five.NetWorkMeta.html +1 -0
  236. package/docs/types/five.NetworkError.html +1 -0
  237. package/docs/types/five.NetworkErrorCallback.html +1 -0
  238. package/docs/types/five.NetworkProgressCallback.html +1 -0
  239. package/docs/types/five.NetworkResponse.html +1 -0
  240. package/docs/types/five.NetworkState.html +1 -0
  241. package/docs/types/five.NetworkSuccessCallback.html +1 -0
  242. package/docs/types/five.NetworkType.html +1 -0
  243. package/docs/types/five.Pano.html +1 -0
  244. package/docs/types/five.PanoId.html +1 -0
  245. package/docs/types/five.ParseWorkOptions.html +13 -0
  246. package/docs/types/five.ParsedResultType.html +1 -0
  247. package/docs/types/five.PostProcessingType.html +1 -0
  248. package/docs/types/five.RegionBoundingVolumeJson.html +1 -0
  249. package/docs/types/five.RequestResult.html +1 -0
  250. package/docs/types/five.SphereBoundingVolumeJson.html +1 -0
  251. package/docs/types/five.SubscribeEventMap.html +1 -0
  252. package/docs/types/five.TileContentData.html +1 -0
  253. package/docs/types/five.TilesetFrameState.html +1 -0
  254. package/docs/types/five.WebXRControllerKey.html +1 -0
  255. package/docs/types/five.WebXRControllerType.html +1 -0
  256. package/docs/types/five.Works.html +1 -0
  257. package/docs/types/line.LineMaterialParameters.html +1 -0
  258. package/docs/types/react.FiveInjectionActionFeature.html +1 -0
  259. package/docs/types/react.FiveInjectionDataFeature.html +1 -0
  260. package/docs/types/react.FiveInjectionFeature.html +1 -0
  261. package/docs/types/react.FiveProviderPropTypes.html +1 -0
  262. package/docs/types/react.FiveProviderType.html +1 -0
  263. package/docs/types/react.StoreActionMapHanlder.html +1 -0
  264. package/docs/types/react.StoreActionMapType.html +1 -0
  265. package/docs/types/react.StoreProviderType.html +1 -0
  266. package/docs/types/react.StoreValueMapType.html +1 -0
  267. package/docs/types/vfx.ParticleType.html +1 -0
  268. package/docs/types/vue.FiveModelIntersectRaycaster.html +1 -0
  269. package/docs/types/vue.FiveProviderComponent.html +1 -0
  270. package/docs/types/vue.Project2d.html +1 -0
  271. package/docs/variables/five.PROXY_CONTROLLER_EVENT_NAMES.html +1 -0
  272. package/docs/variables/five.defaultPbmParameters.html +1 -0
  273. package/docs/variables/react.INJECTION_PROPNAME.html +1 -0
  274. package/docs/variables/vue.FiveCanvas.html +8 -0
  275. package/docs/variables/vue.FiveProvider.html +8 -0
  276. package/five/index.d.ts +381 -240
  277. package/five/index.js +203 -208
  278. package/five/index.mjs +36481 -0
  279. package/gltf-loader/index.js +198 -203
  280. package/gltf-loader/index.mjs +2696 -0
  281. package/line/index.js +198 -203
  282. package/line/index.mjs +790 -0
  283. package/package.json +43 -7
  284. package/react/index.js +198 -203
  285. package/react/index.mjs +1365 -0
  286. package/scripts/five-plugin-init.js +1 -1
  287. package/scripts/five-quick-start-init.js +1 -1
  288. package/scripts/five-react-component-init.js +1 -1
  289. package/sticker/index.js +198 -203
  290. package/sticker/index.mjs +464 -0
  291. package/templates/plugin/devtools/webpack.example.js +1 -1
  292. package/templates/react-component/devtools/webpack.example.js +1 -1
  293. package/umd/five-gltf-loader.js +255 -1
  294. package/umd/five-line.js +255 -1
  295. package/umd/five-react.js +255 -1
  296. package/umd/five-sticker.js +255 -1
  297. package/umd/five-vfx.js +255 -1
  298. package/umd/five-vue.js +255 -1
  299. package/umd/five.js +357 -2
  300. package/vfx/index.js +198 -203
  301. package/vfx/index.mjs +972 -0
  302. package/vue/index.d.ts +1 -1
  303. package/vue/index.js +198 -203
  304. package/vue/index.mjs +715 -0
  305. package/docs/assets/icons.css +0 -1043
  306. package/docs/assets/icons.png +0 -0
  307. package/docs/assets/icons@2x.png +0 -0
  308. package/docs/assets/widgets.png +0 -0
  309. package/docs/assets/widgets@2x.png +0 -0
  310. package/docs/classes/five.BVH.html +0 -10
  311. package/docs/classes/five.BVHIntersect.html +0 -1
  312. package/docs/classes/five.BVHNode.html +0 -7
  313. package/docs/classes/five.BVHVector3.html +0 -1
  314. package/docs/classes/five.Clipper.html +0 -1
  315. package/docs/classes/five.PBMMaterialReferenceCache.html +0 -1
  316. package/docs/enums/five.PBMPointColorType.html +0 -1
  317. package/docs/enums/five.PBMPointShapeType.html +0 -1
  318. package/docs/enums/five.PBMPointSizeType.html +0 -1
  319. package/docs/modules.html +0 -1
  320. package/umd/five-gltf-loader.js.LICENSE.txt +0 -14
  321. package/umd/five-line.js.LICENSE.txt +0 -14
  322. package/umd/five-react.js.LICENSE.txt +0 -14
  323. package/umd/five-sticker.js.LICENSE.txt +0 -14
  324. package/umd/five.js.LICENSE.txt +0 -100
@@ -0,0 +1,2696 @@
1
+ /**
2
+ * @license
3
+ * @realsee/five
4
+ * Generated: 12/20/2023
5
+ * Version: 6.0.0-alpha.71
6
+ * Terms:
7
+ * Realsee SDK License Agreement
8
+ * Update: July 28, 2021
9
+ * THIS LICENSE AGREEMENT BETWEEN YOU AND 【BEIKE REALSEE TECHNOLOGY (HK)
10
+ * LIMITED】(“Realsee”) FORMS A LEGALLY BINDING CONTRACT BETWEEN YOU AND REALSEE IN
11
+ * RELATION TO YOUR USE OF THE SDK. This License Agreement accompanies the Realsee
12
+ * Software Development Kit(s) for the software and related explanatory materials
13
+ * (the "SDK") and includes any upgrades, modified versions, updates, additions,
14
+ * and copies of the SDK licensed to You by Realsee.
15
+ * BY DOWNLOADING, INSTALLING, OR OTHERWISE ACCESSING OR USING THE SDK, YOU AGREE
16
+ * THAT YOU HAVE READ, UNDERSTOOD, AND AGREE TO BE BOUND BY THIS AGREEMENT. YOU ARE
17
+ * AGREEING ON YOUR OWN BEHALF AND/OR ON BEHALF OF YOUR COMPANY OR ORGANIZATION TO
18
+ * THE TERMS AND CONDITIONS STATED BELOW.
19
+ * This Agreement applies to Your use of the SDK in the country in which You
20
+ * legally install it (“Territory”) and is subject to the laws of such Territory
21
+ * and further subject to Section 12 below. Different terms, conditions, and
22
+ * limitations may apply to the use of the SDK in any additional countries.
23
+ * 1. DEFINITIONS.
24
+ * “Agreement” means this Realsee SDK License Agreement.
25
+ * “Developer”, “You” and “Your” means the person(s) or entity acquiring or using
26
+ * the SDK or otherwise exercising rights under the terms of this Agreement.
27
+ * “Documentation” means the technical or other specifications or documentation
28
+ * that Realsee may provide to You for use in connection with the SDK.
29
+ * “Integrated Product” means any software, website, or on-line service developed
30
+ * by You based on or using the SDK (collectively, the “Integrated Product”).
31
+ * “Intellectual Property” means any patents, patent rights, trademarks, service
32
+ * marks, registered and unregistered designs, applications for any of the
33
+ * foregoing, copyright, and any other similar protected rights in any country and
34
+ * to the extent recognised by any relevant jurisdiction as intellectual property,
35
+ * trade secrets, know-how and confidential information. Realsee reserves all
36
+ * rights not expressly granted to You.
37
+ * “Realsee” means [Beike Realsee Technology (HK) Limited, a company incorporated
38
+ * and validly existing under the laws of Hong Kong].
39
+ * “SDK” means the Realsee-proprietary Software Development Kits (SDK) provided
40
+ * hereunder, includes all development tools (including any compiler and debugger),
41
+ * application programming interfaces (“APIs”), libraries, binary utilities, header
42
+ * files, Documentation, content, data, code samples, and other materials provided
43
+ * to You in connection with this Agreement, whether delivered through a download,
44
+ * or any other media or form, and is licensed, not sold, to You by Realsee for use
45
+ * only under the terms of this Agreement. The terms of this Agreement will govern
46
+ * any updates provided by Realsee that replace and/or supplement the original SDK
47
+ * delivered to You, unless such update is accompanied by a separate license, in
48
+ * which case the terms of such license will govern.
49
+ * 2. LICENSED USES AND RESTRICTIONS.
50
+ * 2.1 Subject to the restrictions contained in this Section 2, Realsee grants to
51
+ * You during the term, a limited, non-exclusive, revocable, non-sublicensable,
52
+ * non-transferable license to install and use the SDK within the Territory only
53
+ * for the purpose of internal development.
54
+ * 2.2 Restrictions. You acknowledge and agree that, You shall not, and shall
55
+ * ensure that Your affiliates, employees, agents, representatives, officers,
56
+ * representatives, and subcontractors do not (directly or indirectly):
57
+ * 2.2.1 decompile, reverse engineer, disassemble or attempt to derive the source
58
+ * code of, those components of the SDK provided in object code form, or any part
59
+ * thereof;
60
+ * 2.2.2 remove, alter, or obscure any copyright notice or other proprietary rights
61
+ * notice on any part of the SDK;
62
+ * 2.2.3 sell, assign, pledge, rent, lease, lend, upload to or host on any website
63
+ * or server for use by any third party except You, redistribute, or sublicense the
64
+ * SDK (or any part thereof), or operate the SDK (or any part thereof) in the
65
+ * capacity of a service bureau or other hosted services provider, in whole or in
66
+ * part, nor may You enable others to do so;
67
+ * 2.2.4 or alter, modify, customize or improve the SDK, or any part thereof;
68
+ * 2.2.5 use the SDK (or any part thereof) for any illegal purpose, in any manner
69
+ * that is inconsistent with the terms of this Agreement, or to engage in any
70
+ * illegal activity;
71
+ * 2.2.6 use the SDK (or any part thereof) in any manner that may damage the
72
+ * operation of Realsee’s products or services; or
73
+ * 2.2.7 use the SDK or any information contained therein or otherwise provided by
74
+ * Realsee for the purpose of developing, or having developed, any product
75
+ * competitive with any Realsee product or service, as determined by Realsee in its
76
+ * sole discretion;
77
+ * 2.2.8 include any portion of the SDK in Your Developer products.
78
+ * 2.3 Realsee has the right to impose reasonable conditions such as a reasonable
79
+ * fee for use of the SDK in Integrated Product in the future.
80
+ * 2.4 You may make a limited number of copies of the SDK to be used by Your
81
+ * employees or consultants as provided herein, and not for general business
82
+ * purposes, and such employees or consultants shall be subject to the obligations
83
+ * and restrictions in this Agreement.
84
+ * 2.5 All licenses not expressly granted in this Agreement are reserved and no
85
+ * other licenses, immunity, or rights, express or implied, are granted by Realsee,
86
+ * by implication, estoppel, or otherwise.
87
+ * 3. CONFIDENTIALITY.
88
+ * The SDK and all source code, Documentation, specifications, engineering details,
89
+ * and related information pertaining to the SDK, whether in oral, written,
90
+ * graphic, or electronic form, are and shall remain the confidential and
91
+ * proprietary information of Realsee or its licensors (collectively, the
92
+ * “Confidential Information”). You shall (i) disclose Confidential Information to
93
+ * only those directors and employees (collectively, “Affiliates”) whose duties
94
+ * justify their need to know such information and who have been clearly informed
95
+ * of their obligation to maintain the confidential, proprietary, and/or trade
96
+ * secret status of such Confidential Information; and (ii) use Confidential
97
+ * Information solely in accordance with the license granted hereunder. In any
98
+ * event, You and Your Affiliates shall treat Confidential Information as strictly
99
+ * confidential and shall use the same care to prevent disclosure of such
100
+ * information as You use with respect to Your own similar confidential and/or
101
+ * proprietary information, which shall not be less than the care a reasonable
102
+ * person would use under similar circumstances. All Confidential Information, and
103
+ * any copies thereof, shall be returned promptly to Realsee upon request. You
104
+ * shall ensure that Your Affiliates comply with the provisions of this Section 3,
105
+ * and You shall be liable for any breach of this Section 3 resulting from the act
106
+ * or omission of any of Your Affiliates. You shall not disclose Confidential
107
+ * Information to any third party, including, without limitation, any of Your
108
+ * subcontractors.
109
+ * 4. PROPRIETARY RIGHTS.
110
+ * 4.1 As between You and Realsee, Realsee and/or its licensors retain ownership of
111
+ * all right, title, and interest in, to, and under the SDK, including, without
112
+ * limitation, all patents, copyrights, trade secrets, trademarks and other
113
+ * intellectual property and other proprietary rights therein, and reserve all
114
+ * rights not expressly granted to You.
115
+ * 4.2 The items contained in the SDK are the intellectual property of Realsee and
116
+ * its licensors and are protected by PRC copyright and patent law, international
117
+ * treaty provisions and applicable laws of the country in which it is being used.
118
+ * You agree to protect all copyright and other ownership interests of Realsee
119
+ * and/or its licensors in all items in the SDK supplied under this License
120
+ * Agreement. You agree that all copies of the items in the SDK, reproduced for any
121
+ * reason by You, contain the same copyright notices, and other proprietary notices
122
+ * as appropriate, as appear on or in the original items delivered by Realsee in
123
+ * the SDK. Realsee and/or its licensors retain title and ownership of the items in
124
+ * the SDK, the media on which it is loaded, and all subsequent copies, regardless
125
+ * of the form or media in or on which the original and other copies may exist.
126
+ * Except as stated above, this Agreement does not grant You any rights to patents,
127
+ * copyrights, trade secrets, trademarks or any other rights in respect to the
128
+ * items in the SDK.
129
+ * 5. TERM AND TERMINATION.
130
+ * 5.1 This Agreement is effective until terminated. Realsee has the right to
131
+ * terminate this Agreement immediately, without judicial intervention, if You fail
132
+ * to comply with any term herein. Upon any such termination You must remove all
133
+ * full and partial copies of the items in the SDK from Your computer and
134
+ * discontinue the use of the items in the SDK.
135
+ * 5.2 Realsee may at any time, terminate the Agreement with You if: (A) You have
136
+ * breached any provision of the Agreement; or (B) Realsee is required to do so by
137
+ * law; or (C) Realsee decides to no longer provide the SDK or certain parts of the
138
+ * SDK to users in the country in which You are resident or from which You use the
139
+ * service, or the provision of the SDK or certain SDK services to You by Realsee
140
+ * is, in Realsee's sole discretion, no longer legally or commercially viable.
141
+ * 5.3 When the Agreement comes to an end, all of the legal rights, obligations and
142
+ * liabilities that You and Realsee have benefited from, been subject to (or which
143
+ * have accrued over time whilst the Agreement has been in force) or which are
144
+ * expressed to continue indefinitely, shall be unaffected by this cessation, and
145
+ * the provisions of Section 3, 4, 6, 7 and 8 shall continue to apply to such
146
+ * rights, obligations and liabilities indefinitely.
147
+ * 6. DISCLAIMER OF WARRANTY.
148
+ * YOU EXPRESSLY ACKNOWLEDGE AND AGREE THAT, TO THE EXTENT PERMITTED BY APPLICABLE
149
+ * LAW, USE OF THE SDK (OR ANY PART THEREOF) IS AT YOUR SOLE RISK AND THAT THE
150
+ * ENTIRE RISK AS TO SATISFACTORY QUALITY, PERFORMANCE, ACCURACY, AND EFFORT IS
151
+ * WITH YOU. REALSEE LICENSES THE SDK TO YOU ONLY ON AN "AS-IS" BASIS. REALSEE
152
+ * MAKES NO REPRESENTATION WITH RESPECT TO THE ADEQUACY OF ANY ITEMS IN THE SDK,
153
+ * WHETHER OR NOT USED BY YOU IN THE DEVELOPMENT OF INTEGRATED PRODUCT, FOR ANY
154
+ * PARTICULAR PURPOSE OR WITH RESPECT TO THEIR ADEQUACY TO PRODUCE ANY PARTICULAR
155
+ * RESULT. REALSEE AND ITS LICENSORS SHALL NOT BE LIABLE FOR LOSS OR DAMAGE ARISING
156
+ * OUT OF THIS AGREEMENT OR FROM THE DISTRIBUTION OR USE OF INTEGRATED PRODUCT
157
+ * CONTAINING PORTIONS OF THE SDK. REALSEE AND ITS LICENSORS DISCLAIM ALL
158
+ * WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED
159
+ * CONDITIONS OR WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
160
+ * OR NONINFRINGEMENT OF ANY THIRD PARTY RIGHT IN RESPECT OF THE ITEMS IN THE SDK
161
+ * OR ANY SERVICES RELATED TO THE SDK.
162
+ * REALSEE IS UNDER NO OBLIGATION TO PROVIDE ANY SUPPORT UNDER THIS LICENSE
163
+ * AGREEMENT, INCLUDING UPGRADES OR FUTURE VERSIONS OF THE SDK OR ANY PORTIONS
164
+ * THEREOF, TO YOU, END USER OR TO ANY OTHER PARTY.
165
+ * 7. LIMITATION OF LIABILITY.
166
+ * TO THE EXTENT NOT PROHIBITED BY APPLICABLE LAW, IN NO EVENT WILL REALSEE OR ITS
167
+ * LICENSORS BE LIABLE FOR ANY DIRECT, INCIDENTAL, SPECIAL, INDIRECT, OR
168
+ * CONSEQUENTIAL DAMAGES, INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF USE,
169
+ * LOSS OF BUSINESS, REVENUE, OR PROFITS, LOSS OF OPPORTUNITY (WHETHER DIRECT OR
170
+ * INDIRECT), CORRUPTION OR LOSS OF DATA, LOSS OF REPUTATION OR SAVINGS, DOWNTIME,
171
+ * OR DAMAGE TO, LOSS OF OR REPLACEMENT OF DATA OR TRANSACTIONS, COST OF
172
+ * PROCUREMENT OF SUBSTITUTE SERVICES, BUSINESS INTERRUPTION, OR ANY OTHER
173
+ * COMMERCIAL DAMAGES OR LOSSES, ARISING OUT OF OR RELATED TO YOUR USE OR INABILITY
174
+ * TO USE THE SDK (OR ANY PART THEREOF), ANY INTEGRATED PRODUCT, OR ANY THIRD PARTY
175
+ * SOFTWARE, APPLICATIONS, OR SERVICES IN CONJUNCTION WITH THE SDK (OR ANY PART
176
+ * THEREOF), HOWEVER CAUSED, REGARDLESS OF THE THEORY OF LIABILITY (CONTRACT, TORT,
177
+ * OR OTHERWISE) AND EVEN IF REALSEE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
178
+ * DAMAGES. IN NO EVENT WILL REALSEE’S TOTAL LIABILITY TO YOU FOR ALL DAMAGES
179
+ * EXCEED ONE HUNDRED DOLLARS ($100.00). THE FOREGOING LIMITATIONS WILL APPLY EVEN
180
+ * IF THE ABOVE STATED REMEDY FAILS OF ITS ESSENTIAL PURPOSE. THE LIMITATIONS
181
+ * CONTAINED IN SECTIONS 6 AND THIS SECTION 7 ARE A FUNDAMENTAL PART OF THE BASIS
182
+ * OF REALSEE’S BARGAIN HEREUNDER, AND REALSEE WOULD NOT ENTER INTO THIS AGREEMENT
183
+ * OR PROVIDE YOU WITH ACCESS TO THE SDK ABSENT SUCH LIMITATIONS.
184
+ * 8. INDEMNIFICATION.
185
+ * To the extent permitted by applicable law, You agree to indemnify, defend and
186
+ * hold harmless Realsee, its affiliates and each of their directors, officers,
187
+ * employees, independent contractors, and agents (each a “Realsee Indemnified
188
+ * Party”) from any and all claims, losses, liabilities, damages, expenses, and
189
+ * costs (including without limitation attorneys’ fees and court costs) incurred by
190
+ * a Realsee Indemnified Party as a result of: (i) Your non-compliance with any
191
+ * terms of this Agreement; (ii) Your use of the SDK (or any part thereof); or
192
+ * (iii) Your use of any Integrated Product, including any claim that Integrated
193
+ * Product infringes the copyright, trademark, trade secret or other intellectual
194
+ * property right of a third party.
195
+ * 9. ACKNOWLEDGEMENTS.
196
+ * Portions of the SDK may utilize or include third party software and other
197
+ * copyrighted material. Acknowledgments, licensing terms, and disclaimers for such
198
+ * material are contained in Documentation for the SDK or may otherwise accompany
199
+ * such material, and Your use of such materials governed by their respective
200
+ * terms. In the event of conflict between the terms of this Agreement and an
201
+ * applicable open source or third party agreement, the open source or third party
202
+ * agreement will control solely with respect to the open source software or third
203
+ * party software. Moreover, You shall not subject any items (including not limited
204
+ * to source code, object code, and any software) included in the SDK to any open
205
+ * source license.
206
+ * 10. NON-BLOCKING OF REALSEE DEVELOPMENT.
207
+ * You acknowledge that Realsee is currently developing or may develop technologies
208
+ * and products in the future that have or may have design and/or functionality
209
+ * similar to Integrated Product that You may develop based on Your license herein.
210
+ * Nothing in this Agreement shall impair, limit or curtail Realsee's right to
211
+ * continue with its development, maintenance and/or distribution of Realsee's
212
+ * technology or products.
213
+ * 11. GENERAL.
214
+ * 11.1 Export Control. You may not use or otherwise export or re-export the SDK
215
+ * (or any part thereof) except as authorized by United States law and the laws of
216
+ * the jurisdiction(s) in which the SDK (or any part thereof) was obtained. In
217
+ * particular, but without limitation, the SDK may not be exported or re-exported
218
+ * (i) into any U.S. embargoed countries or (ii) to anyone on the U.S. Treasury
219
+ * Department's list of Specially Designated Nationals or the U.S. Department of
220
+ * Commerce Denied Person's List or Entity List. By using the SDK (or any part
221
+ * thereof), You represent and warrant that You are not located in any such country
222
+ * or on any such list.
223
+ * 11.2 Governing Law. This Agreement and the rights of the parties hereunder shall
224
+ * be governed by and construed in accordance with the laws of People’s Republic of
225
+ * China (for purpose of this Agreement, excluding Hong Kong, Taiwan, and Macau),
226
+ * without reference to its conflict of laws principles. Any dispute, controversy
227
+ * or claim arising from or in connection with this Agreement, or the breach,
228
+ * termination or invalidity thereof, shall be submitted to China International
229
+ * Economic and Trade Arbitration Commission (“CIETAC”) for arbitration in Beijing
230
+ * which shall be conducted in accordance with the CIETAC's arbitration rules in
231
+ * effect at the time of applying for arbitration. The arbitral award is final and
232
+ * binding upon both parties.
233
+ * 11.3 Severability. If any provision of this Agreement is held by a court of
234
+ * competent jurisdiction to be unenforceable for any reason, the remaining
235
+ * provisions hereof will be unaffected and remain in full force and effect.
236
+ * 11.4. Modifications. Realsee reserves the right, from time to time, with or
237
+ * without notice to You, to make revisions to this Agreement in our sole and
238
+ * absolute discretion. The most current version of this Agreement will supersede
239
+ * all previous versions and shall be made available on the website where the SDK
240
+ * is made available, or by such other means as Realsee may determine in its
241
+ * discretion. Any modified versions of this Agreement hereto shall take effect
242
+ * from the time that it is made available. You shall be responsible for regularly
243
+ * checking for notice of any such modifications. You agree that Your continued use
244
+ * of the SDK constitutes Your agreement to the modified Agreement.
245
+ * 11.5 Relationship of the Parties. This Agreement will not be construed as
246
+ * creating an agency, partnership, joint venture, fiduciary duty, or any other
247
+ * form of legal association between You and Realsee, and You will not represent to
248
+ * the contrary, whether expressly, by implication, appearance, or otherwise.
249
+ * 11.6 Entire Agreement; Governing Language. This Agreement constitutes the entire
250
+ * agreement between You and Realsee with respect to the use of the SDK licensed
251
+ * hereunder and supersedes all prior understandings regarding such subject matter.
252
+ * No amendment to or modification of this Agreement will be binding unless in
253
+ * writing and signed by Realsee. You and Realsee hereto confirm that this
254
+ * Agreement and all related documents shall be drafted in English.
255
+ */import * as THREE from "three";
256
+ import { Loader, LoaderUtils, FileLoader, Color, SpotLight, PointLight, DirectionalLight, MeshBasicMaterial, MeshPhysicalMaterial, Vector2, MeshStandardMaterial, TangentSpaceNormalMap, Interpolant, TextureLoader, InterleavedBuffer, InterleavedBufferAttribute, BufferAttribute, LinearFilter, LinearMipmapLinearFilter, RepeatWrapping, RGBFormat, PointsMaterial, Material, LineBasicMaterial, DoubleSide, sRGBEncoding, BufferGeometry, SkinnedMesh, Mesh, LineSegments, Line, LineLoop, Points, Group, PerspectiveCamera, MathUtils, OrthographicCamera, InterpolateLinear, AnimationClip, Bone, Object3D, PropertyBinding, Matrix4, NearestFilter, NearestMipmapNearestFilter, LinearMipmapNearestFilter, NearestMipmapLinearFilter, ClampToEdgeWrapping, MirroredRepeatWrapping, InterpolateDiscrete, RGBAFormat, FrontSide, TriangleFanDrawMode, TriangleStripDrawMode, VectorKeyframeTrack, QuaternionKeyframeTrack, NumberKeyframeTrack, Skeleton, Box3, Vector3, Sphere, CompressedTextureLoader, RGB_ETC1_Format, RGBA_S3TC_DXT5_Format, RGBA_S3TC_DXT3_Format, RGB_S3TC_DXT1_Format } from "three";
257
+ var extendStatics = function(d, b) {
258
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
259
+ d2.__proto__ = b2;
260
+ } || function(d2, b2) {
261
+ for (var p in b2)
262
+ if (Object.prototype.hasOwnProperty.call(b2, p))
263
+ d2[p] = b2[p];
264
+ };
265
+ return extendStatics(d, b);
266
+ };
267
+ function __extends(d, b) {
268
+ if (typeof b !== "function" && b !== null)
269
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
270
+ extendStatics(d, b);
271
+ function __() {
272
+ this.constructor = d;
273
+ }
274
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
275
+ }
276
+ typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
277
+ var e = new Error(message);
278
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
279
+ };
280
+ var GLTFLoader$1 = function() {
281
+ function GLTFLoader2(manager) {
282
+ Loader.call(this, manager);
283
+ this.dracoLoader = null;
284
+ this.ddsLoader = null;
285
+ }
286
+ GLTFLoader2.prototype = Object.assign(Object.create(Loader.prototype), {
287
+ constructor: GLTFLoader2,
288
+ load: function(url, onLoad, onProgress, onError) {
289
+ var scope = this;
290
+ var resourcePath;
291
+ if (this.resourcePath !== "") {
292
+ resourcePath = this.resourcePath;
293
+ } else if (this.path !== "") {
294
+ resourcePath = this.path;
295
+ } else {
296
+ resourcePath = LoaderUtils.extractUrlBase(url);
297
+ }
298
+ scope.manager.itemStart(url);
299
+ var _onError = function(e) {
300
+ if (onError) {
301
+ onError(e);
302
+ } else {
303
+ console.error(e);
304
+ }
305
+ scope.manager.itemError(url);
306
+ scope.manager.itemEnd(url);
307
+ };
308
+ var loader = new FileLoader(scope.manager);
309
+ loader.setPath(this.path);
310
+ loader.setResponseType("arraybuffer");
311
+ loader.setRequestHeader(this.requestHeader);
312
+ if (scope.crossOrigin === "use-credentials") {
313
+ loader.setWithCredentials(true);
314
+ }
315
+ loader.load(url, function(data) {
316
+ try {
317
+ scope.parse(data, resourcePath, function(gltf) {
318
+ onLoad(gltf);
319
+ scope.manager.itemEnd(url);
320
+ }, _onError);
321
+ } catch (e) {
322
+ _onError(e);
323
+ }
324
+ }, onProgress, _onError);
325
+ },
326
+ setDRACOLoader: function(dracoLoader) {
327
+ this.dracoLoader = dracoLoader;
328
+ return this;
329
+ },
330
+ setDDSLoader: function(ddsLoader) {
331
+ this.ddsLoader = ddsLoader;
332
+ return this;
333
+ },
334
+ parse: function(data, path, onLoad, onError) {
335
+ var content;
336
+ var extensions = {};
337
+ if (typeof data === "string") {
338
+ content = data;
339
+ } else {
340
+ var magic = LoaderUtils.decodeText(new Uint8Array(data, 0, 4));
341
+ if (magic === BINARY_EXTENSION_HEADER_MAGIC) {
342
+ try {
343
+ extensions[EXTENSIONS.KHR_BINARY_GLTF] = new GLTFBinaryExtension(data);
344
+ } catch (error) {
345
+ if (onError)
346
+ onError(error);
347
+ return;
348
+ }
349
+ content = extensions[EXTENSIONS.KHR_BINARY_GLTF].content;
350
+ } else {
351
+ content = LoaderUtils.decodeText(new Uint8Array(data));
352
+ }
353
+ }
354
+ var json = JSON.parse(content);
355
+ if (json.asset === void 0 || json.asset.version[0] < 2) {
356
+ if (onError)
357
+ onError(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));
358
+ return;
359
+ }
360
+ if (json.extensionsUsed) {
361
+ for (var i = 0; i < json.extensionsUsed.length; ++i) {
362
+ var extensionName = json.extensionsUsed[i];
363
+ var extensionsRequired = json.extensionsRequired || [];
364
+ switch (extensionName) {
365
+ case EXTENSIONS.KHR_LIGHTS_PUNCTUAL:
366
+ extensions[extensionName] = new GLTFLightsExtension(json);
367
+ break;
368
+ case EXTENSIONS.KHR_MATERIALS_CLEARCOAT:
369
+ extensions[extensionName] = new GLTFMaterialsClearcoatExtension();
370
+ break;
371
+ case EXTENSIONS.KHR_MATERIALS_TRANSMISSION:
372
+ extensions[extensionName] = new GLTFMaterialsTransmissionExtension();
373
+ break;
374
+ case EXTENSIONS.KHR_MATERIALS_UNLIT:
375
+ extensions[extensionName] = new GLTFMaterialsUnlitExtension();
376
+ break;
377
+ case EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:
378
+ extensions[extensionName] = new GLTFMaterialsPbrSpecularGlossinessExtension();
379
+ break;
380
+ case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:
381
+ extensions[extensionName] = new GLTFDracoMeshCompressionExtension(json, this.dracoLoader);
382
+ break;
383
+ case EXTENSIONS.MSFT_TEXTURE_DDS:
384
+ extensions[extensionName] = new GLTFTextureDDSExtension(this.ddsLoader);
385
+ break;
386
+ case EXTENSIONS.KHR_TEXTURE_TRANSFORM:
387
+ extensions[extensionName] = new GLTFTextureTransformExtension();
388
+ break;
389
+ case EXTENSIONS.KHR_MESH_QUANTIZATION:
390
+ extensions[extensionName] = new GLTFMeshQuantizationExtension();
391
+ break;
392
+ default:
393
+ if (extensionsRequired.indexOf(extensionName) >= 0) {
394
+ console.warn('THREE.GLTFLoader: Unknown extension "' + extensionName + '".');
395
+ }
396
+ }
397
+ }
398
+ }
399
+ var parser = new GLTFParser(json, extensions, {
400
+ path: path || this.resourcePath || "",
401
+ crossOrigin: this.crossOrigin,
402
+ manager: this.manager
403
+ });
404
+ parser.fileLoader.setRequestHeader(this.requestHeader);
405
+ parser.parse(onLoad, onError);
406
+ }
407
+ });
408
+ function GLTFRegistry() {
409
+ var objects = {};
410
+ return {
411
+ get: function(key) {
412
+ return objects[key];
413
+ },
414
+ add: function(key, object) {
415
+ objects[key] = object;
416
+ },
417
+ remove: function(key) {
418
+ delete objects[key];
419
+ },
420
+ removeAll: function() {
421
+ objects = {};
422
+ }
423
+ };
424
+ }
425
+ var EXTENSIONS = {
426
+ KHR_BINARY_GLTF: "KHR_binary_glTF",
427
+ KHR_DRACO_MESH_COMPRESSION: "KHR_draco_mesh_compression",
428
+ KHR_LIGHTS_PUNCTUAL: "KHR_lights_punctual",
429
+ KHR_MATERIALS_CLEARCOAT: "KHR_materials_clearcoat",
430
+ KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS: "KHR_materials_pbrSpecularGlossiness",
431
+ KHR_MATERIALS_TRANSMISSION: "KHR_materials_transmission",
432
+ KHR_MATERIALS_UNLIT: "KHR_materials_unlit",
433
+ KHR_TEXTURE_TRANSFORM: "KHR_texture_transform",
434
+ KHR_MESH_QUANTIZATION: "KHR_mesh_quantization",
435
+ MSFT_TEXTURE_DDS: "MSFT_texture_dds"
436
+ };
437
+ function GLTFTextureDDSExtension(ddsLoader) {
438
+ if (!ddsLoader) {
439
+ throw new Error("THREE.GLTFLoader: Attempting to load .dds texture without importing DDSLoader");
440
+ }
441
+ this.name = EXTENSIONS.MSFT_TEXTURE_DDS;
442
+ this.ddsLoader = ddsLoader;
443
+ }
444
+ function GLTFLightsExtension(json) {
445
+ this.name = EXTENSIONS.KHR_LIGHTS_PUNCTUAL;
446
+ var extension = json.extensions && json.extensions[EXTENSIONS.KHR_LIGHTS_PUNCTUAL] || {};
447
+ this.lightDefs = extension.lights || [];
448
+ }
449
+ GLTFLightsExtension.prototype.loadLight = function(lightIndex) {
450
+ var lightDef = this.lightDefs[lightIndex];
451
+ var lightNode;
452
+ var color = new Color(16777215);
453
+ if (lightDef.color !== void 0)
454
+ color.fromArray(lightDef.color);
455
+ var range = lightDef.range !== void 0 ? lightDef.range : 0;
456
+ switch (lightDef.type) {
457
+ case "directional":
458
+ lightNode = new DirectionalLight(color);
459
+ lightNode.target.position.set(0, 0, -1);
460
+ lightNode.add(lightNode.target);
461
+ break;
462
+ case "point":
463
+ lightNode = new PointLight(color);
464
+ lightNode.distance = range;
465
+ break;
466
+ case "spot":
467
+ lightNode = new SpotLight(color);
468
+ lightNode.distance = range;
469
+ lightDef.spot = lightDef.spot || {};
470
+ lightDef.spot.innerConeAngle = lightDef.spot.innerConeAngle !== void 0 ? lightDef.spot.innerConeAngle : 0;
471
+ lightDef.spot.outerConeAngle = lightDef.spot.outerConeAngle !== void 0 ? lightDef.spot.outerConeAngle : Math.PI / 4;
472
+ lightNode.angle = lightDef.spot.outerConeAngle;
473
+ lightNode.penumbra = 1 - lightDef.spot.innerConeAngle / lightDef.spot.outerConeAngle;
474
+ lightNode.target.position.set(0, 0, -1);
475
+ lightNode.add(lightNode.target);
476
+ break;
477
+ default:
478
+ throw new Error('THREE.GLTFLoader: Unexpected light type, "' + lightDef.type + '".');
479
+ }
480
+ lightNode.position.set(0, 0, 0);
481
+ lightNode.decay = 2;
482
+ if (lightDef.intensity !== void 0)
483
+ lightNode.intensity = lightDef.intensity;
484
+ lightNode.name = lightDef.name || "light_" + lightIndex;
485
+ return Promise.resolve(lightNode);
486
+ };
487
+ function GLTFMaterialsUnlitExtension() {
488
+ this.name = EXTENSIONS.KHR_MATERIALS_UNLIT;
489
+ }
490
+ GLTFMaterialsUnlitExtension.prototype.getMaterialType = function() {
491
+ return MeshBasicMaterial;
492
+ };
493
+ GLTFMaterialsUnlitExtension.prototype.extendParams = function(materialParams, materialDef, parser) {
494
+ var pending = [];
495
+ materialParams.color = new Color(1, 1, 1);
496
+ materialParams.opacity = 1;
497
+ var metallicRoughness = materialDef.pbrMetallicRoughness;
498
+ if (metallicRoughness) {
499
+ if (Array.isArray(metallicRoughness.baseColorFactor)) {
500
+ var array = metallicRoughness.baseColorFactor;
501
+ materialParams.color.fromArray(array);
502
+ materialParams.opacity = array[3];
503
+ }
504
+ if (metallicRoughness.baseColorTexture !== void 0) {
505
+ pending.push(parser.assignTexture(materialParams, "map", metallicRoughness.baseColorTexture));
506
+ }
507
+ }
508
+ return Promise.all(pending);
509
+ };
510
+ function GLTFMaterialsClearcoatExtension() {
511
+ this.name = EXTENSIONS.KHR_MATERIALS_CLEARCOAT;
512
+ }
513
+ GLTFMaterialsClearcoatExtension.prototype.getMaterialType = function() {
514
+ return MeshPhysicalMaterial;
515
+ };
516
+ GLTFMaterialsClearcoatExtension.prototype.extendParams = function(materialParams, materialDef, parser) {
517
+ var pending = [];
518
+ var extension = materialDef.extensions[this.name];
519
+ if (extension.clearcoatFactor !== void 0) {
520
+ materialParams.clearcoat = extension.clearcoatFactor;
521
+ }
522
+ if (extension.clearcoatTexture !== void 0) {
523
+ pending.push(parser.assignTexture(materialParams, "clearcoatMap", extension.clearcoatTexture));
524
+ }
525
+ if (extension.clearcoatRoughnessFactor !== void 0) {
526
+ materialParams.clearcoatRoughness = extension.clearcoatRoughnessFactor;
527
+ }
528
+ if (extension.clearcoatRoughnessTexture !== void 0) {
529
+ pending.push(parser.assignTexture(materialParams, "clearcoatRoughnessMap", extension.clearcoatRoughnessTexture));
530
+ }
531
+ if (extension.clearcoatNormalTexture !== void 0) {
532
+ pending.push(parser.assignTexture(materialParams, "clearcoatNormalMap", extension.clearcoatNormalTexture));
533
+ if (extension.clearcoatNormalTexture.scale !== void 0) {
534
+ var scale = extension.clearcoatNormalTexture.scale;
535
+ materialParams.clearcoatNormalScale = new Vector2(scale, scale);
536
+ }
537
+ }
538
+ return Promise.all(pending);
539
+ };
540
+ function GLTFMaterialsTransmissionExtension() {
541
+ this.name = EXTENSIONS.KHR_MATERIALS_TRANSMISSION;
542
+ }
543
+ GLTFMaterialsTransmissionExtension.prototype.getMaterialType = function() {
544
+ return MeshPhysicalMaterial;
545
+ };
546
+ GLTFMaterialsTransmissionExtension.prototype.extendParams = function(materialParams, materialDef, parser) {
547
+ var pending = [];
548
+ var extension = materialDef.extensions[this.name];
549
+ if (extension.transmissionFactor !== void 0) {
550
+ materialParams.premultipliedAlpha = true;
551
+ materialParams.transparent = true;
552
+ materialParams.opacity = 1;
553
+ materialParams.transparency = extension.transmissionFactor;
554
+ if (materialParams.map || materialParams.color.r * materialParams.color.g * materialParams.color.b < 0.99) {
555
+ materialParams.transparency *= 0.75;
556
+ }
557
+ }
558
+ return Promise.all(pending);
559
+ };
560
+ var BINARY_EXTENSION_HEADER_MAGIC = "glTF";
561
+ var BINARY_EXTENSION_HEADER_LENGTH = 12;
562
+ var BINARY_EXTENSION_CHUNK_TYPES = { JSON: 1313821514, BIN: 5130562 };
563
+ function GLTFBinaryExtension(data) {
564
+ this.name = EXTENSIONS.KHR_BINARY_GLTF;
565
+ this.content = null;
566
+ this.body = null;
567
+ var headerView = new DataView(data, 0, BINARY_EXTENSION_HEADER_LENGTH);
568
+ this.header = {
569
+ magic: LoaderUtils.decodeText(new Uint8Array(data.slice(0, 4))),
570
+ version: headerView.getUint32(4, true),
571
+ length: headerView.getUint32(8, true)
572
+ };
573
+ if (this.header.magic !== BINARY_EXTENSION_HEADER_MAGIC) {
574
+ throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");
575
+ } else if (this.header.version < 2) {
576
+ throw new Error("THREE.GLTFLoader: Legacy binary file detected.");
577
+ }
578
+ var chunkView = new DataView(data, BINARY_EXTENSION_HEADER_LENGTH);
579
+ var chunkIndex = 0;
580
+ while (chunkIndex < chunkView.byteLength) {
581
+ var chunkLength = chunkView.getUint32(chunkIndex, true);
582
+ chunkIndex += 4;
583
+ var chunkType = chunkView.getUint32(chunkIndex, true);
584
+ chunkIndex += 4;
585
+ if (chunkType === BINARY_EXTENSION_CHUNK_TYPES.JSON) {
586
+ var contentArray = new Uint8Array(data, BINARY_EXTENSION_HEADER_LENGTH + chunkIndex, chunkLength);
587
+ this.content = LoaderUtils.decodeText(contentArray);
588
+ } else if (chunkType === BINARY_EXTENSION_CHUNK_TYPES.BIN) {
589
+ var byteOffset = BINARY_EXTENSION_HEADER_LENGTH + chunkIndex;
590
+ this.body = data.slice(byteOffset, byteOffset + chunkLength);
591
+ }
592
+ chunkIndex += chunkLength;
593
+ }
594
+ if (this.content === null) {
595
+ throw new Error("THREE.GLTFLoader: JSON content not found.");
596
+ }
597
+ }
598
+ function GLTFDracoMeshCompressionExtension(json, dracoLoader) {
599
+ if (!dracoLoader) {
600
+ throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");
601
+ }
602
+ this.name = EXTENSIONS.KHR_DRACO_MESH_COMPRESSION;
603
+ this.json = json;
604
+ this.dracoLoader = dracoLoader;
605
+ this.dracoLoader.preload();
606
+ }
607
+ GLTFDracoMeshCompressionExtension.prototype.decodePrimitive = function(primitive, parser) {
608
+ var json = this.json;
609
+ var dracoLoader = this.dracoLoader;
610
+ var bufferViewIndex = primitive.extensions[this.name].bufferView;
611
+ var gltfAttributeMap = primitive.extensions[this.name].attributes;
612
+ var threeAttributeMap = {};
613
+ var attributeNormalizedMap = {};
614
+ var attributeTypeMap = {};
615
+ for (var attributeName in gltfAttributeMap) {
616
+ var threeAttributeName = ATTRIBUTES[attributeName] || attributeName.toLowerCase();
617
+ threeAttributeMap[threeAttributeName] = gltfAttributeMap[attributeName];
618
+ }
619
+ for (attributeName in primitive.attributes) {
620
+ var threeAttributeName = ATTRIBUTES[attributeName] || attributeName.toLowerCase();
621
+ if (gltfAttributeMap[attributeName] !== void 0) {
622
+ var accessorDef = json.accessors[primitive.attributes[attributeName]];
623
+ var componentType = WEBGL_COMPONENT_TYPES[accessorDef.componentType];
624
+ attributeTypeMap[threeAttributeName] = componentType;
625
+ attributeNormalizedMap[threeAttributeName] = accessorDef.normalized === true;
626
+ }
627
+ }
628
+ return parser.getDependency("bufferView", bufferViewIndex).then(function(bufferView) {
629
+ return new Promise(function(resolve) {
630
+ dracoLoader.decodeDracoFile(bufferView, function(geometry) {
631
+ for (var attributeName2 in geometry.attributes) {
632
+ var attribute = geometry.attributes[attributeName2];
633
+ var normalized = attributeNormalizedMap[attributeName2];
634
+ if (normalized !== void 0)
635
+ attribute.normalized = normalized;
636
+ }
637
+ resolve(geometry);
638
+ }, threeAttributeMap, attributeTypeMap);
639
+ });
640
+ });
641
+ };
642
+ function GLTFTextureTransformExtension() {
643
+ this.name = EXTENSIONS.KHR_TEXTURE_TRANSFORM;
644
+ }
645
+ GLTFTextureTransformExtension.prototype.extendTexture = function(texture, transform) {
646
+ texture = texture.clone();
647
+ if (transform.offset !== void 0) {
648
+ texture.offset.fromArray(transform.offset);
649
+ }
650
+ if (transform.rotation !== void 0) {
651
+ texture.rotation = transform.rotation;
652
+ }
653
+ if (transform.scale !== void 0) {
654
+ texture.repeat.fromArray(transform.scale);
655
+ }
656
+ if (transform.texCoord !== void 0) {
657
+ console.warn('THREE.GLTFLoader: Custom UV sets in "' + this.name + '" extension not yet supported.');
658
+ }
659
+ texture.needsUpdate = true;
660
+ return texture;
661
+ };
662
+ function GLTFMeshStandardSGMaterial(params) {
663
+ MeshStandardMaterial.call(this);
664
+ this.isGLTFSpecularGlossinessMaterial = true;
665
+ var specularMapParsFragmentChunk = [
666
+ "#ifdef USE_SPECULARMAP",
667
+ " uniform sampler2D specularMap;",
668
+ "#endif"
669
+ ].join("\n");
670
+ var glossinessMapParsFragmentChunk = [
671
+ "#ifdef USE_GLOSSINESSMAP",
672
+ " uniform sampler2D glossinessMap;",
673
+ "#endif"
674
+ ].join("\n");
675
+ var specularMapFragmentChunk = [
676
+ "vec3 specularFactor = specular;",
677
+ "#ifdef USE_SPECULARMAP",
678
+ " vec4 texelSpecular = texture2D( specularMap, vUv );",
679
+ " texelSpecular = sRGBToLinear( texelSpecular );",
680
+ " // reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture",
681
+ " specularFactor *= texelSpecular.rgb;",
682
+ "#endif"
683
+ ].join("\n");
684
+ var glossinessMapFragmentChunk = [
685
+ "float glossinessFactor = glossiness;",
686
+ "#ifdef USE_GLOSSINESSMAP",
687
+ " vec4 texelGlossiness = texture2D( glossinessMap, vUv );",
688
+ " // reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture",
689
+ " glossinessFactor *= texelGlossiness.a;",
690
+ "#endif"
691
+ ].join("\n");
692
+ var lightPhysicalFragmentChunk = [
693
+ "PhysicalMaterial material;",
694
+ "material.diffuseColor = diffuseColor.rgb;",
695
+ "vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );",
696
+ "float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );",
697
+ "material.specularRoughness = max( 1.0 - glossinessFactor, 0.0525 );// 0.0525 corresponds to the base mip of a 256 cubemap.",
698
+ "material.specularRoughness += geometryRoughness;",
699
+ "material.specularRoughness = min( material.specularRoughness, 1.0 );",
700
+ "material.specularColor = specularFactor.rgb;"
701
+ ].join("\n");
702
+ var uniforms = {
703
+ specular: { value: new Color().setHex(16777215) },
704
+ glossiness: { value: 1 },
705
+ specularMap: { value: null },
706
+ glossinessMap: { value: null }
707
+ };
708
+ this._extraUniforms = uniforms;
709
+ this.onBeforeCompile = function(shader) {
710
+ for (var uniformName in uniforms) {
711
+ shader.uniforms[uniformName] = uniforms[uniformName];
712
+ }
713
+ shader.fragmentShader = shader.fragmentShader.replace("uniform float roughness;", "uniform vec3 specular;");
714
+ shader.fragmentShader = shader.fragmentShader.replace("uniform float metalness;", "uniform float glossiness;");
715
+ shader.fragmentShader = shader.fragmentShader.replace("#include <roughnessmap_pars_fragment>", specularMapParsFragmentChunk);
716
+ shader.fragmentShader = shader.fragmentShader.replace("#include <metalnessmap_pars_fragment>", glossinessMapParsFragmentChunk);
717
+ shader.fragmentShader = shader.fragmentShader.replace("#include <roughnessmap_fragment>", specularMapFragmentChunk);
718
+ shader.fragmentShader = shader.fragmentShader.replace("#include <metalnessmap_fragment>", glossinessMapFragmentChunk);
719
+ shader.fragmentShader = shader.fragmentShader.replace("#include <lights_physical_fragment>", lightPhysicalFragmentChunk);
720
+ };
721
+ Object.defineProperties(
722
+ this,
723
+ {
724
+ specular: {
725
+ get: function() {
726
+ return uniforms.specular.value;
727
+ },
728
+ set: function(v) {
729
+ uniforms.specular.value = v;
730
+ }
731
+ },
732
+ specularMap: {
733
+ get: function() {
734
+ return uniforms.specularMap.value;
735
+ },
736
+ set: function(v) {
737
+ uniforms.specularMap.value = v;
738
+ }
739
+ },
740
+ glossiness: {
741
+ get: function() {
742
+ return uniforms.glossiness.value;
743
+ },
744
+ set: function(v) {
745
+ uniforms.glossiness.value = v;
746
+ }
747
+ },
748
+ glossinessMap: {
749
+ get: function() {
750
+ return uniforms.glossinessMap.value;
751
+ },
752
+ set: function(v) {
753
+ uniforms.glossinessMap.value = v;
754
+ if (v) {
755
+ this.defines.USE_GLOSSINESSMAP = "";
756
+ this.defines.USE_ROUGHNESSMAP = "";
757
+ } else {
758
+ delete this.defines.USE_ROUGHNESSMAP;
759
+ delete this.defines.USE_GLOSSINESSMAP;
760
+ }
761
+ }
762
+ }
763
+ }
764
+ );
765
+ delete this.metalness;
766
+ delete this.roughness;
767
+ delete this.metalnessMap;
768
+ delete this.roughnessMap;
769
+ this.setValues(params);
770
+ }
771
+ GLTFMeshStandardSGMaterial.prototype = Object.create(MeshStandardMaterial.prototype);
772
+ GLTFMeshStandardSGMaterial.prototype.constructor = GLTFMeshStandardSGMaterial;
773
+ GLTFMeshStandardSGMaterial.prototype.copy = function(source) {
774
+ MeshStandardMaterial.prototype.copy.call(this, source);
775
+ this.specularMap = source.specularMap;
776
+ this.specular.copy(source.specular);
777
+ this.glossinessMap = source.glossinessMap;
778
+ this.glossiness = source.glossiness;
779
+ delete this.metalness;
780
+ delete this.roughness;
781
+ delete this.metalnessMap;
782
+ delete this.roughnessMap;
783
+ return this;
784
+ };
785
+ function GLTFMaterialsPbrSpecularGlossinessExtension() {
786
+ return {
787
+ name: EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,
788
+ specularGlossinessParams: [
789
+ "color",
790
+ "map",
791
+ "lightMap",
792
+ "lightMapIntensity",
793
+ "aoMap",
794
+ "aoMapIntensity",
795
+ "emissive",
796
+ "emissiveIntensity",
797
+ "emissiveMap",
798
+ "bumpMap",
799
+ "bumpScale",
800
+ "normalMap",
801
+ "normalMapType",
802
+ "displacementMap",
803
+ "displacementScale",
804
+ "displacementBias",
805
+ "specularMap",
806
+ "specular",
807
+ "glossinessMap",
808
+ "glossiness",
809
+ "alphaMap",
810
+ "envMap",
811
+ "envMapIntensity",
812
+ "refractionRatio"
813
+ ],
814
+ getMaterialType: function() {
815
+ return GLTFMeshStandardSGMaterial;
816
+ },
817
+ extendParams: function(materialParams, materialDef, parser) {
818
+ var pbrSpecularGlossiness = materialDef.extensions[this.name];
819
+ materialParams.color = new Color(1, 1, 1);
820
+ materialParams.opacity = 1;
821
+ var pending = [];
822
+ if (Array.isArray(pbrSpecularGlossiness.diffuseFactor)) {
823
+ var array = pbrSpecularGlossiness.diffuseFactor;
824
+ materialParams.color.fromArray(array);
825
+ materialParams.opacity = array[3];
826
+ }
827
+ if (pbrSpecularGlossiness.diffuseTexture !== void 0) {
828
+ pending.push(parser.assignTexture(materialParams, "map", pbrSpecularGlossiness.diffuseTexture));
829
+ }
830
+ materialParams.emissive = new Color(0, 0, 0);
831
+ materialParams.glossiness = pbrSpecularGlossiness.glossinessFactor !== void 0 ? pbrSpecularGlossiness.glossinessFactor : 1;
832
+ materialParams.specular = new Color(1, 1, 1);
833
+ if (Array.isArray(pbrSpecularGlossiness.specularFactor)) {
834
+ materialParams.specular.fromArray(pbrSpecularGlossiness.specularFactor);
835
+ }
836
+ if (pbrSpecularGlossiness.specularGlossinessTexture !== void 0) {
837
+ var specGlossMapDef = pbrSpecularGlossiness.specularGlossinessTexture;
838
+ pending.push(parser.assignTexture(materialParams, "glossinessMap", specGlossMapDef));
839
+ pending.push(parser.assignTexture(materialParams, "specularMap", specGlossMapDef));
840
+ }
841
+ return Promise.all(pending);
842
+ },
843
+ createMaterial: function(materialParams) {
844
+ var material = new GLTFMeshStandardSGMaterial(materialParams);
845
+ material.fog = true;
846
+ material.color = materialParams.color;
847
+ material.map = materialParams.map === void 0 ? null : materialParams.map;
848
+ material.lightMap = null;
849
+ material.lightMapIntensity = 1;
850
+ material.aoMap = materialParams.aoMap === void 0 ? null : materialParams.aoMap;
851
+ material.aoMapIntensity = 1;
852
+ material.emissive = materialParams.emissive;
853
+ material.emissiveIntensity = 1;
854
+ material.emissiveMap = materialParams.emissiveMap === void 0 ? null : materialParams.emissiveMap;
855
+ material.bumpMap = materialParams.bumpMap === void 0 ? null : materialParams.bumpMap;
856
+ material.bumpScale = 1;
857
+ material.normalMap = materialParams.normalMap === void 0 ? null : materialParams.normalMap;
858
+ material.normalMapType = TangentSpaceNormalMap;
859
+ if (materialParams.normalScale)
860
+ material.normalScale = materialParams.normalScale;
861
+ material.displacementMap = null;
862
+ material.displacementScale = 1;
863
+ material.displacementBias = 0;
864
+ material.specularMap = materialParams.specularMap === void 0 ? null : materialParams.specularMap;
865
+ material.specular = materialParams.specular;
866
+ material.glossinessMap = materialParams.glossinessMap === void 0 ? null : materialParams.glossinessMap;
867
+ material.glossiness = materialParams.glossiness;
868
+ material.alphaMap = null;
869
+ material.envMap = materialParams.envMap === void 0 ? null : materialParams.envMap;
870
+ material.envMapIntensity = 1;
871
+ material.refractionRatio = 0.98;
872
+ return material;
873
+ }
874
+ };
875
+ }
876
+ function GLTFMeshQuantizationExtension() {
877
+ this.name = EXTENSIONS.KHR_MESH_QUANTIZATION;
878
+ }
879
+ function GLTFCubicSplineInterpolant(parameterPositions, sampleValues, sampleSize, resultBuffer) {
880
+ Interpolant.call(this, parameterPositions, sampleValues, sampleSize, resultBuffer);
881
+ }
882
+ GLTFCubicSplineInterpolant.prototype = Object.create(Interpolant.prototype);
883
+ GLTFCubicSplineInterpolant.prototype.constructor = GLTFCubicSplineInterpolant;
884
+ GLTFCubicSplineInterpolant.prototype.copySampleValue_ = function(index) {
885
+ var result = this.resultBuffer, values = this.sampleValues, valueSize = this.valueSize, offset = index * valueSize * 3 + valueSize;
886
+ for (var i = 0; i !== valueSize; i++) {
887
+ result[i] = values[offset + i];
888
+ }
889
+ return result;
890
+ };
891
+ GLTFCubicSplineInterpolant.prototype.beforeStart_ = GLTFCubicSplineInterpolant.prototype.copySampleValue_;
892
+ GLTFCubicSplineInterpolant.prototype.afterEnd_ = GLTFCubicSplineInterpolant.prototype.copySampleValue_;
893
+ GLTFCubicSplineInterpolant.prototype.interpolate_ = function(i1, t0, t, t1) {
894
+ var result = this.resultBuffer;
895
+ var values = this.sampleValues;
896
+ var stride = this.valueSize;
897
+ var stride2 = stride * 2;
898
+ var stride3 = stride * 3;
899
+ var td = t1 - t0;
900
+ var p = (t - t0) / td;
901
+ var pp = p * p;
902
+ var ppp = pp * p;
903
+ var offset1 = i1 * stride3;
904
+ var offset0 = offset1 - stride3;
905
+ var s2 = -2 * ppp + 3 * pp;
906
+ var s3 = ppp - pp;
907
+ var s0 = 1 - s2;
908
+ var s1 = s3 - pp + p;
909
+ for (var i = 0; i !== stride; i++) {
910
+ var p0 = values[offset0 + i + stride];
911
+ var m0 = values[offset0 + i + stride2] * td;
912
+ var p1 = values[offset1 + i + stride];
913
+ var m1 = values[offset1 + i] * td;
914
+ result[i] = s0 * p0 + s1 * m0 + s2 * p1 + s3 * m1;
915
+ }
916
+ return result;
917
+ };
918
+ var WEBGL_CONSTANTS = {
919
+ FLOAT: 5126,
920
+ //FLOAT_MAT2: 35674,
921
+ FLOAT_MAT3: 35675,
922
+ FLOAT_MAT4: 35676,
923
+ FLOAT_VEC2: 35664,
924
+ FLOAT_VEC3: 35665,
925
+ FLOAT_VEC4: 35666,
926
+ LINEAR: 9729,
927
+ REPEAT: 10497,
928
+ SAMPLER_2D: 35678,
929
+ POINTS: 0,
930
+ LINES: 1,
931
+ LINE_LOOP: 2,
932
+ LINE_STRIP: 3,
933
+ TRIANGLES: 4,
934
+ TRIANGLE_STRIP: 5,
935
+ TRIANGLE_FAN: 6,
936
+ UNSIGNED_BYTE: 5121,
937
+ UNSIGNED_SHORT: 5123
938
+ };
939
+ var WEBGL_COMPONENT_TYPES = {
940
+ 5120: Int8Array,
941
+ 5121: Uint8Array,
942
+ 5122: Int16Array,
943
+ 5123: Uint16Array,
944
+ 5125: Uint32Array,
945
+ 5126: Float32Array
946
+ };
947
+ var WEBGL_FILTERS = {
948
+ 9728: NearestFilter,
949
+ 9729: LinearFilter,
950
+ 9984: NearestMipmapNearestFilter,
951
+ 9985: LinearMipmapNearestFilter,
952
+ 9986: NearestMipmapLinearFilter,
953
+ 9987: LinearMipmapLinearFilter
954
+ };
955
+ var WEBGL_WRAPPINGS = {
956
+ 33071: ClampToEdgeWrapping,
957
+ 33648: MirroredRepeatWrapping,
958
+ 10497: RepeatWrapping
959
+ };
960
+ var WEBGL_TYPE_SIZES = {
961
+ "SCALAR": 1,
962
+ "VEC2": 2,
963
+ "VEC3": 3,
964
+ "VEC4": 4,
965
+ "MAT2": 4,
966
+ "MAT3": 9,
967
+ "MAT4": 16
968
+ };
969
+ var ATTRIBUTES = {
970
+ POSITION: "position",
971
+ NORMAL: "normal",
972
+ TANGENT: "tangent",
973
+ TEXCOORD_0: "uv",
974
+ TEXCOORD_1: "uv2",
975
+ COLOR_0: "color",
976
+ WEIGHTS_0: "skinWeight",
977
+ JOINTS_0: "skinIndex"
978
+ };
979
+ var PATH_PROPERTIES = {
980
+ scale: "scale",
981
+ translation: "position",
982
+ rotation: "quaternion",
983
+ weights: "morphTargetInfluences"
984
+ };
985
+ var INTERPOLATION = {
986
+ CUBICSPLINE: void 0,
987
+ // We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each
988
+ // keyframe track will be initialized with a default interpolation type, then modified.
989
+ LINEAR: InterpolateLinear,
990
+ STEP: InterpolateDiscrete
991
+ };
992
+ var ALPHA_MODES = {
993
+ OPAQUE: "OPAQUE",
994
+ MASK: "MASK",
995
+ BLEND: "BLEND"
996
+ };
997
+ var MIME_TYPE_FORMATS = {
998
+ "image/png": RGBAFormat,
999
+ "image/jpeg": RGBFormat
1000
+ };
1001
+ function resolveURL(url, path) {
1002
+ if (typeof url !== "string" || url === "")
1003
+ return "";
1004
+ if (/^https?:\/\//i.test(path) && /^\//.test(url)) {
1005
+ path = path.replace(/(^https?:\/\/[^\/]+).*/i, "$1");
1006
+ }
1007
+ if (/^(https?:)?\/\//i.test(url))
1008
+ return url;
1009
+ if (/^data:.*,.*$/i.test(url))
1010
+ return url;
1011
+ if (/^blob:.*$/i.test(url))
1012
+ return url;
1013
+ return path + url;
1014
+ }
1015
+ function createDefaultMaterial(cache) {
1016
+ if (cache["DefaultMaterial"] === void 0) {
1017
+ cache["DefaultMaterial"] = new MeshStandardMaterial({
1018
+ color: 16777215,
1019
+ emissive: 0,
1020
+ metalness: 1,
1021
+ roughness: 1,
1022
+ transparent: false,
1023
+ depthTest: true,
1024
+ side: FrontSide
1025
+ });
1026
+ }
1027
+ return cache["DefaultMaterial"];
1028
+ }
1029
+ function addUnknownExtensionsToUserData(knownExtensions, object, objectDef) {
1030
+ for (var name in objectDef.extensions) {
1031
+ if (knownExtensions[name] === void 0) {
1032
+ object.userData.gltfExtensions = object.userData.gltfExtensions || {};
1033
+ object.userData.gltfExtensions[name] = objectDef.extensions[name];
1034
+ }
1035
+ }
1036
+ }
1037
+ function assignExtrasToUserData(object, gltfDef) {
1038
+ if (gltfDef.extras !== void 0) {
1039
+ if (typeof gltfDef.extras === "object") {
1040
+ Object.assign(object.userData, gltfDef.extras);
1041
+ } else {
1042
+ console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, " + gltfDef.extras);
1043
+ }
1044
+ }
1045
+ }
1046
+ function addMorphTargets(geometry, targets, parser) {
1047
+ var hasMorphPosition = false;
1048
+ var hasMorphNormal = false;
1049
+ for (var i = 0, il = targets.length; i < il; i++) {
1050
+ var target = targets[i];
1051
+ if (target.POSITION !== void 0)
1052
+ hasMorphPosition = true;
1053
+ if (target.NORMAL !== void 0)
1054
+ hasMorphNormal = true;
1055
+ if (hasMorphPosition && hasMorphNormal)
1056
+ break;
1057
+ }
1058
+ if (!hasMorphPosition && !hasMorphNormal)
1059
+ return Promise.resolve(geometry);
1060
+ var pendingPositionAccessors = [];
1061
+ var pendingNormalAccessors = [];
1062
+ for (var i = 0, il = targets.length; i < il; i++) {
1063
+ var target = targets[i];
1064
+ if (hasMorphPosition) {
1065
+ var pendingAccessor = target.POSITION !== void 0 ? parser.getDependency("accessor", target.POSITION) : geometry.attributes.position;
1066
+ pendingPositionAccessors.push(pendingAccessor);
1067
+ }
1068
+ if (hasMorphNormal) {
1069
+ var pendingAccessor = target.NORMAL !== void 0 ? parser.getDependency("accessor", target.NORMAL) : geometry.attributes.normal;
1070
+ pendingNormalAccessors.push(pendingAccessor);
1071
+ }
1072
+ }
1073
+ return Promise.all([
1074
+ Promise.all(pendingPositionAccessors),
1075
+ Promise.all(pendingNormalAccessors)
1076
+ ]).then(function(accessors) {
1077
+ var morphPositions = accessors[0];
1078
+ var morphNormals = accessors[1];
1079
+ if (hasMorphPosition)
1080
+ geometry.morphAttributes.position = morphPositions;
1081
+ if (hasMorphNormal)
1082
+ geometry.morphAttributes.normal = morphNormals;
1083
+ geometry.morphTargetsRelative = true;
1084
+ return geometry;
1085
+ });
1086
+ }
1087
+ function updateMorphTargets(mesh, meshDef) {
1088
+ mesh.updateMorphTargets();
1089
+ if (meshDef.weights !== void 0) {
1090
+ for (var i = 0, il = meshDef.weights.length; i < il; i++) {
1091
+ mesh.morphTargetInfluences[i] = meshDef.weights[i];
1092
+ }
1093
+ }
1094
+ if (meshDef.extras && Array.isArray(meshDef.extras.targetNames)) {
1095
+ var targetNames = meshDef.extras.targetNames;
1096
+ if (mesh.morphTargetInfluences.length === targetNames.length) {
1097
+ mesh.morphTargetDictionary = {};
1098
+ for (var i = 0, il = targetNames.length; i < il; i++) {
1099
+ mesh.morphTargetDictionary[targetNames[i]] = i;
1100
+ }
1101
+ } else {
1102
+ console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.");
1103
+ }
1104
+ }
1105
+ }
1106
+ function createPrimitiveKey(primitiveDef) {
1107
+ var dracoExtension = primitiveDef.extensions && primitiveDef.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION];
1108
+ var geometryKey;
1109
+ if (dracoExtension) {
1110
+ geometryKey = "draco:" + dracoExtension.bufferView + ":" + dracoExtension.indices + ":" + createAttributesKey(dracoExtension.attributes);
1111
+ } else {
1112
+ geometryKey = primitiveDef.indices + ":" + createAttributesKey(primitiveDef.attributes) + ":" + primitiveDef.mode;
1113
+ }
1114
+ return geometryKey;
1115
+ }
1116
+ function createAttributesKey(attributes) {
1117
+ var attributesKey = "";
1118
+ var keys = Object.keys(attributes).sort();
1119
+ for (var i = 0, il = keys.length; i < il; i++) {
1120
+ attributesKey += keys[i] + ":" + attributes[keys[i]] + ";";
1121
+ }
1122
+ return attributesKey;
1123
+ }
1124
+ function GLTFParser(json, extensions, options) {
1125
+ this.json = json || {};
1126
+ this.extensions = extensions || {};
1127
+ this.options = options || {};
1128
+ this.cache = new GLTFRegistry();
1129
+ this.associations = /* @__PURE__ */ new Map();
1130
+ this.primitiveCache = {};
1131
+ this.textureLoader = new TextureLoader(this.options.manager);
1132
+ this.textureLoader.setCrossOrigin(this.options.crossOrigin);
1133
+ this.fileLoader = new FileLoader(this.options.manager);
1134
+ this.fileLoader.setResponseType("arraybuffer");
1135
+ if (this.options.crossOrigin === "use-credentials") {
1136
+ this.fileLoader.setWithCredentials(true);
1137
+ }
1138
+ }
1139
+ GLTFParser.prototype.parse = function(onLoad, onError) {
1140
+ var parser = this;
1141
+ var json = this.json;
1142
+ var extensions = this.extensions;
1143
+ this.cache.removeAll();
1144
+ this.markDefs();
1145
+ Promise.all([
1146
+ this.getDependencies("scene"),
1147
+ this.getDependencies("animation"),
1148
+ this.getDependencies("camera")
1149
+ ]).then(function(dependencies) {
1150
+ var result = {
1151
+ scene: dependencies[0][json.scene || 0],
1152
+ scenes: dependencies[0],
1153
+ animations: dependencies[1],
1154
+ cameras: dependencies[2],
1155
+ asset: json.asset,
1156
+ parser,
1157
+ userData: {}
1158
+ };
1159
+ addUnknownExtensionsToUserData(extensions, result, json);
1160
+ assignExtrasToUserData(result, json);
1161
+ onLoad(result);
1162
+ }).catch(onError);
1163
+ };
1164
+ GLTFParser.prototype.markDefs = function() {
1165
+ var nodeDefs = this.json.nodes || [];
1166
+ var skinDefs = this.json.skins || [];
1167
+ var meshDefs = this.json.meshes || [];
1168
+ var meshReferences = {};
1169
+ var meshUses = {};
1170
+ for (var skinIndex = 0, skinLength = skinDefs.length; skinIndex < skinLength; skinIndex++) {
1171
+ var joints = skinDefs[skinIndex].joints;
1172
+ for (var i = 0, il = joints.length; i < il; i++) {
1173
+ nodeDefs[joints[i]].isBone = true;
1174
+ }
1175
+ }
1176
+ for (var nodeIndex = 0, nodeLength = nodeDefs.length; nodeIndex < nodeLength; nodeIndex++) {
1177
+ var nodeDef = nodeDefs[nodeIndex];
1178
+ if (nodeDef.mesh !== void 0) {
1179
+ if (meshReferences[nodeDef.mesh] === void 0) {
1180
+ meshReferences[nodeDef.mesh] = meshUses[nodeDef.mesh] = 0;
1181
+ }
1182
+ meshReferences[nodeDef.mesh]++;
1183
+ if (nodeDef.skin !== void 0) {
1184
+ meshDefs[nodeDef.mesh].isSkinnedMesh = true;
1185
+ }
1186
+ }
1187
+ }
1188
+ this.json.meshReferences = meshReferences;
1189
+ this.json.meshUses = meshUses;
1190
+ };
1191
+ GLTFParser.prototype.getDependency = function(type, index) {
1192
+ var cacheKey = type + ":" + index;
1193
+ var dependency = this.cache.get(cacheKey);
1194
+ if (!dependency) {
1195
+ switch (type) {
1196
+ case "scene":
1197
+ dependency = this.loadScene(index);
1198
+ break;
1199
+ case "node":
1200
+ dependency = this.loadNode(index);
1201
+ break;
1202
+ case "mesh":
1203
+ dependency = this.loadMesh(index);
1204
+ break;
1205
+ case "accessor":
1206
+ dependency = this.loadAccessor(index);
1207
+ break;
1208
+ case "bufferView":
1209
+ dependency = this.loadBufferView(index);
1210
+ break;
1211
+ case "buffer":
1212
+ dependency = this.loadBuffer(index);
1213
+ break;
1214
+ case "material":
1215
+ dependency = this.loadMaterial(index);
1216
+ break;
1217
+ case "texture":
1218
+ dependency = this.loadTexture(index);
1219
+ break;
1220
+ case "skin":
1221
+ dependency = this.loadSkin(index);
1222
+ break;
1223
+ case "animation":
1224
+ dependency = this.loadAnimation(index);
1225
+ break;
1226
+ case "camera":
1227
+ dependency = this.loadCamera(index);
1228
+ break;
1229
+ case "light":
1230
+ dependency = this.extensions[EXTENSIONS.KHR_LIGHTS_PUNCTUAL].loadLight(index);
1231
+ break;
1232
+ default:
1233
+ throw new Error("Unknown type: " + type);
1234
+ }
1235
+ this.cache.add(cacheKey, dependency);
1236
+ }
1237
+ return dependency;
1238
+ };
1239
+ GLTFParser.prototype.getDependencies = function(type) {
1240
+ var dependencies = this.cache.get(type);
1241
+ if (!dependencies) {
1242
+ var parser = this;
1243
+ var defs = this.json[type + (type === "mesh" ? "es" : "s")] || [];
1244
+ dependencies = Promise.all(defs.map(function(def, index) {
1245
+ return parser.getDependency(type, index);
1246
+ }));
1247
+ this.cache.add(type, dependencies);
1248
+ }
1249
+ return dependencies;
1250
+ };
1251
+ GLTFParser.prototype.loadBuffer = function(bufferIndex) {
1252
+ var bufferDef = this.json.buffers[bufferIndex];
1253
+ var loader = this.fileLoader;
1254
+ if (bufferDef.type && bufferDef.type !== "arraybuffer") {
1255
+ throw new Error("THREE.GLTFLoader: " + bufferDef.type + " buffer type is not supported.");
1256
+ }
1257
+ if (bufferDef.uri === void 0 && bufferIndex === 0) {
1258
+ return Promise.resolve(this.extensions[EXTENSIONS.KHR_BINARY_GLTF].body);
1259
+ }
1260
+ var options = this.options;
1261
+ return new Promise(function(resolve, reject) {
1262
+ loader.load(resolveURL(bufferDef.uri, options.path), resolve, void 0, function() {
1263
+ reject(new Error('THREE.GLTFLoader: Failed to load buffer "' + bufferDef.uri + '".'));
1264
+ });
1265
+ });
1266
+ };
1267
+ GLTFParser.prototype.loadBufferView = function(bufferViewIndex) {
1268
+ var bufferViewDef = this.json.bufferViews[bufferViewIndex];
1269
+ return this.getDependency("buffer", bufferViewDef.buffer).then(function(buffer) {
1270
+ var byteLength = bufferViewDef.byteLength || 0;
1271
+ var byteOffset = bufferViewDef.byteOffset || 0;
1272
+ return buffer.slice(byteOffset, byteOffset + byteLength);
1273
+ });
1274
+ };
1275
+ GLTFParser.prototype.loadAccessor = function(accessorIndex) {
1276
+ var parser = this;
1277
+ var json = this.json;
1278
+ var accessorDef = this.json.accessors[accessorIndex];
1279
+ if (accessorDef.bufferView === void 0 && accessorDef.sparse === void 0) {
1280
+ return Promise.resolve(null);
1281
+ }
1282
+ var pendingBufferViews = [];
1283
+ if (accessorDef.bufferView !== void 0) {
1284
+ pendingBufferViews.push(this.getDependency("bufferView", accessorDef.bufferView));
1285
+ } else {
1286
+ pendingBufferViews.push(null);
1287
+ }
1288
+ if (accessorDef.sparse !== void 0) {
1289
+ pendingBufferViews.push(this.getDependency("bufferView", accessorDef.sparse.indices.bufferView));
1290
+ pendingBufferViews.push(this.getDependency("bufferView", accessorDef.sparse.values.bufferView));
1291
+ }
1292
+ return Promise.all(pendingBufferViews).then(function(bufferViews) {
1293
+ var bufferView = bufferViews[0];
1294
+ var itemSize = WEBGL_TYPE_SIZES[accessorDef.type];
1295
+ var TypedArray = WEBGL_COMPONENT_TYPES[accessorDef.componentType];
1296
+ var elementBytes = TypedArray.BYTES_PER_ELEMENT;
1297
+ var itemBytes = elementBytes * itemSize;
1298
+ var byteOffset = accessorDef.byteOffset || 0;
1299
+ var byteStride = accessorDef.bufferView !== void 0 ? json.bufferViews[accessorDef.bufferView].byteStride : void 0;
1300
+ var normalized = accessorDef.normalized === true;
1301
+ var array, bufferAttribute;
1302
+ if (byteStride && byteStride !== itemBytes) {
1303
+ var ibSlice = Math.floor(byteOffset / byteStride);
1304
+ var ibCacheKey = "InterleavedBuffer:" + accessorDef.bufferView + ":" + accessorDef.componentType + ":" + ibSlice + ":" + accessorDef.count;
1305
+ var ib = parser.cache.get(ibCacheKey);
1306
+ if (!ib) {
1307
+ array = new TypedArray(bufferView, ibSlice * byteStride, accessorDef.count * byteStride / elementBytes);
1308
+ ib = new InterleavedBuffer(array, byteStride / elementBytes);
1309
+ parser.cache.add(ibCacheKey, ib);
1310
+ }
1311
+ bufferAttribute = new InterleavedBufferAttribute(ib, itemSize, byteOffset % byteStride / elementBytes, normalized);
1312
+ } else {
1313
+ if (bufferView === null) {
1314
+ array = new TypedArray(accessorDef.count * itemSize);
1315
+ } else {
1316
+ array = new TypedArray(bufferView, byteOffset, accessorDef.count * itemSize);
1317
+ }
1318
+ bufferAttribute = new BufferAttribute(array, itemSize, normalized);
1319
+ }
1320
+ if (accessorDef.sparse !== void 0) {
1321
+ var itemSizeIndices = WEBGL_TYPE_SIZES.SCALAR;
1322
+ var TypedArrayIndices = WEBGL_COMPONENT_TYPES[accessorDef.sparse.indices.componentType];
1323
+ var byteOffsetIndices = accessorDef.sparse.indices.byteOffset || 0;
1324
+ var byteOffsetValues = accessorDef.sparse.values.byteOffset || 0;
1325
+ var sparseIndices = new TypedArrayIndices(bufferViews[1], byteOffsetIndices, accessorDef.sparse.count * itemSizeIndices);
1326
+ var sparseValues = new TypedArray(bufferViews[2], byteOffsetValues, accessorDef.sparse.count * itemSize);
1327
+ if (bufferView !== null) {
1328
+ bufferAttribute = new BufferAttribute(bufferAttribute.array.slice(), bufferAttribute.itemSize, bufferAttribute.normalized);
1329
+ }
1330
+ for (var i = 0, il = sparseIndices.length; i < il; i++) {
1331
+ var index = sparseIndices[i];
1332
+ bufferAttribute.setX(index, sparseValues[i * itemSize]);
1333
+ if (itemSize >= 2)
1334
+ bufferAttribute.setY(index, sparseValues[i * itemSize + 1]);
1335
+ if (itemSize >= 3)
1336
+ bufferAttribute.setZ(index, sparseValues[i * itemSize + 2]);
1337
+ if (itemSize >= 4)
1338
+ bufferAttribute.setW(index, sparseValues[i * itemSize + 3]);
1339
+ if (itemSize >= 5)
1340
+ throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.");
1341
+ }
1342
+ }
1343
+ return bufferAttribute;
1344
+ });
1345
+ };
1346
+ GLTFParser.prototype.loadTexture = function(textureIndex) {
1347
+ var parser = this;
1348
+ var json = this.json;
1349
+ var options = this.options;
1350
+ var textureLoader = this.textureLoader;
1351
+ var URL2 = self.URL || self.webkitURL;
1352
+ var textureDef = json.textures[textureIndex];
1353
+ var textureExtensions = textureDef.extensions || {};
1354
+ var source;
1355
+ if (textureExtensions[EXTENSIONS.MSFT_TEXTURE_DDS]) {
1356
+ source = json.images[textureExtensions[EXTENSIONS.MSFT_TEXTURE_DDS].source];
1357
+ } else {
1358
+ source = json.images[textureDef.source];
1359
+ }
1360
+ var sourceURI = source.uri;
1361
+ var isObjectURL = false;
1362
+ if (source.bufferView !== void 0) {
1363
+ sourceURI = parser.getDependency("bufferView", source.bufferView).then(function(bufferView) {
1364
+ isObjectURL = true;
1365
+ var blob = new Blob([bufferView], { type: source.mimeType });
1366
+ sourceURI = URL2.createObjectURL(blob);
1367
+ return sourceURI;
1368
+ });
1369
+ }
1370
+ return Promise.resolve(sourceURI).then(function(sourceURI2) {
1371
+ var loader = options.manager.getHandler(sourceURI2);
1372
+ if (!loader) {
1373
+ loader = textureExtensions[EXTENSIONS.MSFT_TEXTURE_DDS] ? parser.extensions[EXTENSIONS.MSFT_TEXTURE_DDS].ddsLoader : textureLoader;
1374
+ }
1375
+ return new Promise(function(resolve, reject) {
1376
+ loader.load(resolveURL(sourceURI2, options.path), resolve, void 0, reject);
1377
+ });
1378
+ }).then(function(texture) {
1379
+ if (isObjectURL === true) {
1380
+ URL2.revokeObjectURL(sourceURI);
1381
+ }
1382
+ texture.flipY = false;
1383
+ if (textureDef.name)
1384
+ texture.name = textureDef.name;
1385
+ if (source.mimeType in MIME_TYPE_FORMATS) {
1386
+ texture.format = MIME_TYPE_FORMATS[source.mimeType];
1387
+ }
1388
+ var samplers = json.samplers || {};
1389
+ var sampler = samplers[textureDef.sampler] || {};
1390
+ texture.magFilter = WEBGL_FILTERS[sampler.magFilter] || LinearFilter;
1391
+ texture.minFilter = WEBGL_FILTERS[sampler.minFilter] || LinearMipmapLinearFilter;
1392
+ texture.wrapS = WEBGL_WRAPPINGS[sampler.wrapS] || RepeatWrapping;
1393
+ texture.wrapT = WEBGL_WRAPPINGS[sampler.wrapT] || RepeatWrapping;
1394
+ parser.associations.set(texture, {
1395
+ type: "textures",
1396
+ index: textureIndex
1397
+ });
1398
+ return texture;
1399
+ });
1400
+ };
1401
+ GLTFParser.prototype.assignTexture = function(materialParams, mapName, mapDef) {
1402
+ var parser = this;
1403
+ return this.getDependency("texture", mapDef.index).then(function(texture) {
1404
+ if (!texture.isCompressedTexture) {
1405
+ switch (mapName) {
1406
+ case "aoMap":
1407
+ case "emissiveMap":
1408
+ case "metalnessMap":
1409
+ case "normalMap":
1410
+ case "roughnessMap":
1411
+ texture.format = RGBFormat;
1412
+ break;
1413
+ }
1414
+ }
1415
+ if (mapDef.texCoord !== void 0 && mapDef.texCoord != 0 && !(mapName === "aoMap" && mapDef.texCoord == 1)) {
1416
+ console.warn("THREE.GLTFLoader: Custom UV set " + mapDef.texCoord + " for texture " + mapName + " not yet supported.");
1417
+ }
1418
+ if (parser.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM]) {
1419
+ var transform = mapDef.extensions !== void 0 ? mapDef.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM] : void 0;
1420
+ if (transform) {
1421
+ var gltfReference = this.associations.get(texture);
1422
+ texture = parser.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM].extendTexture(texture, transform);
1423
+ this.associations.set(texture, gltfReference);
1424
+ }
1425
+ }
1426
+ materialParams[mapName] = texture;
1427
+ });
1428
+ };
1429
+ GLTFParser.prototype.assignFinalMaterial = function(mesh) {
1430
+ var geometry = mesh.geometry;
1431
+ var material = mesh.material;
1432
+ var useVertexTangents = geometry.attributes.tangent !== void 0;
1433
+ var useVertexColors = geometry.attributes.color !== void 0;
1434
+ var useFlatShading = geometry.attributes.normal === void 0;
1435
+ var useSkinning = mesh.isSkinnedMesh === true;
1436
+ var useMorphTargets = Object.keys(geometry.morphAttributes).length > 0;
1437
+ var useMorphNormals = useMorphTargets && geometry.morphAttributes.normal !== void 0;
1438
+ if (mesh.isPoints) {
1439
+ var cacheKey = "PointsMaterial:" + material.uuid;
1440
+ var pointsMaterial = this.cache.get(cacheKey);
1441
+ if (!pointsMaterial) {
1442
+ pointsMaterial = new PointsMaterial();
1443
+ Material.prototype.copy.call(pointsMaterial, material);
1444
+ pointsMaterial.color.copy(material.color);
1445
+ pointsMaterial.map = material.map;
1446
+ pointsMaterial.sizeAttenuation = false;
1447
+ this.cache.add(cacheKey, pointsMaterial);
1448
+ }
1449
+ material = pointsMaterial;
1450
+ } else if (mesh.isLine) {
1451
+ var cacheKey = "LineBasicMaterial:" + material.uuid;
1452
+ var lineMaterial = this.cache.get(cacheKey);
1453
+ if (!lineMaterial) {
1454
+ lineMaterial = new LineBasicMaterial();
1455
+ Material.prototype.copy.call(lineMaterial, material);
1456
+ lineMaterial.color.copy(material.color);
1457
+ this.cache.add(cacheKey, lineMaterial);
1458
+ }
1459
+ material = lineMaterial;
1460
+ }
1461
+ if (useVertexTangents || useVertexColors || useFlatShading || useSkinning || useMorphTargets) {
1462
+ var cacheKey = "ClonedMaterial:" + material.uuid + ":";
1463
+ if (material.isGLTFSpecularGlossinessMaterial)
1464
+ cacheKey += "specular-glossiness:";
1465
+ if (useSkinning)
1466
+ cacheKey += "skinning:";
1467
+ if (useVertexTangents)
1468
+ cacheKey += "vertex-tangents:";
1469
+ if (useVertexColors)
1470
+ cacheKey += "vertex-colors:";
1471
+ if (useFlatShading)
1472
+ cacheKey += "flat-shading:";
1473
+ if (useMorphTargets)
1474
+ cacheKey += "morph-targets:";
1475
+ if (useMorphNormals)
1476
+ cacheKey += "morph-normals:";
1477
+ var cachedMaterial = this.cache.get(cacheKey);
1478
+ if (!cachedMaterial) {
1479
+ cachedMaterial = material.clone();
1480
+ if (useSkinning)
1481
+ cachedMaterial.skinning = true;
1482
+ if (useVertexTangents)
1483
+ cachedMaterial.vertexTangents = true;
1484
+ if (useVertexColors)
1485
+ cachedMaterial.vertexColors = true;
1486
+ if (useFlatShading)
1487
+ cachedMaterial.flatShading = true;
1488
+ if (useMorphTargets)
1489
+ cachedMaterial.morphTargets = true;
1490
+ if (useMorphNormals)
1491
+ cachedMaterial.morphNormals = true;
1492
+ this.cache.add(cacheKey, cachedMaterial);
1493
+ this.associations.set(cachedMaterial, this.associations.get(material));
1494
+ }
1495
+ material = cachedMaterial;
1496
+ }
1497
+ if (material.aoMap && geometry.attributes.uv2 === void 0 && geometry.attributes.uv !== void 0) {
1498
+ geometry.setAttribute("uv2", geometry.attributes.uv);
1499
+ }
1500
+ if (material.normalScale && !useVertexTangents) {
1501
+ material.normalScale.y = -material.normalScale.y;
1502
+ }
1503
+ if (material.clearcoatNormalScale && !useVertexTangents) {
1504
+ material.clearcoatNormalScale.y = -material.clearcoatNormalScale.y;
1505
+ }
1506
+ mesh.material = material;
1507
+ };
1508
+ GLTFParser.prototype.loadMaterial = function(materialIndex) {
1509
+ var parser = this;
1510
+ var json = this.json;
1511
+ var extensions = this.extensions;
1512
+ var materialDef = json.materials[materialIndex];
1513
+ var materialType;
1514
+ var materialParams = {};
1515
+ var materialExtensions = materialDef.extensions || {};
1516
+ var pending = [];
1517
+ if (materialExtensions[EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]) {
1518
+ var sgExtension = extensions[EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];
1519
+ materialType = sgExtension.getMaterialType();
1520
+ pending.push(sgExtension.extendParams(materialParams, materialDef, parser));
1521
+ } else if (materialExtensions[EXTENSIONS.KHR_MATERIALS_UNLIT]) {
1522
+ var kmuExtension = extensions[EXTENSIONS.KHR_MATERIALS_UNLIT];
1523
+ materialType = kmuExtension.getMaterialType();
1524
+ pending.push(kmuExtension.extendParams(materialParams, materialDef, parser));
1525
+ } else {
1526
+ materialType = MeshStandardMaterial;
1527
+ var metallicRoughness = materialDef.pbrMetallicRoughness || {};
1528
+ materialParams.color = new Color(1, 1, 1);
1529
+ materialParams.opacity = 1;
1530
+ if (Array.isArray(metallicRoughness.baseColorFactor)) {
1531
+ var array = metallicRoughness.baseColorFactor;
1532
+ materialParams.color.fromArray(array);
1533
+ materialParams.opacity = array[3];
1534
+ }
1535
+ if (metallicRoughness.baseColorTexture !== void 0) {
1536
+ pending.push(parser.assignTexture(materialParams, "map", metallicRoughness.baseColorTexture));
1537
+ }
1538
+ materialParams.metalness = metallicRoughness.metallicFactor !== void 0 ? metallicRoughness.metallicFactor : 1;
1539
+ materialParams.roughness = metallicRoughness.roughnessFactor !== void 0 ? metallicRoughness.roughnessFactor : 1;
1540
+ if (metallicRoughness.metallicRoughnessTexture !== void 0) {
1541
+ pending.push(parser.assignTexture(materialParams, "metalnessMap", metallicRoughness.metallicRoughnessTexture));
1542
+ pending.push(parser.assignTexture(materialParams, "roughnessMap", metallicRoughness.metallicRoughnessTexture));
1543
+ }
1544
+ }
1545
+ if (materialDef.doubleSided === true) {
1546
+ materialParams.side = DoubleSide;
1547
+ }
1548
+ var alphaMode = materialDef.alphaMode || ALPHA_MODES.OPAQUE;
1549
+ if (alphaMode === ALPHA_MODES.BLEND) {
1550
+ materialParams.transparent = true;
1551
+ materialParams.depthWrite = false;
1552
+ } else {
1553
+ materialParams.transparent = false;
1554
+ if (alphaMode === ALPHA_MODES.MASK) {
1555
+ materialParams.alphaTest = materialDef.alphaCutoff !== void 0 ? materialDef.alphaCutoff : 0.5;
1556
+ }
1557
+ }
1558
+ if (materialDef.normalTexture !== void 0 && materialType !== MeshBasicMaterial) {
1559
+ pending.push(parser.assignTexture(materialParams, "normalMap", materialDef.normalTexture));
1560
+ materialParams.normalScale = new Vector2(1, 1);
1561
+ if (materialDef.normalTexture.scale !== void 0) {
1562
+ materialParams.normalScale.set(materialDef.normalTexture.scale, materialDef.normalTexture.scale);
1563
+ }
1564
+ }
1565
+ if (materialDef.occlusionTexture !== void 0 && materialType !== MeshBasicMaterial) {
1566
+ pending.push(parser.assignTexture(materialParams, "aoMap", materialDef.occlusionTexture));
1567
+ if (materialDef.occlusionTexture.strength !== void 0) {
1568
+ materialParams.aoMapIntensity = materialDef.occlusionTexture.strength;
1569
+ }
1570
+ }
1571
+ if (materialDef.emissiveFactor !== void 0 && materialType !== MeshBasicMaterial) {
1572
+ materialParams.emissive = new Color().fromArray(materialDef.emissiveFactor);
1573
+ }
1574
+ if (materialDef.emissiveTexture !== void 0 && materialType !== MeshBasicMaterial) {
1575
+ pending.push(parser.assignTexture(materialParams, "emissiveMap", materialDef.emissiveTexture));
1576
+ }
1577
+ if (materialExtensions[EXTENSIONS.KHR_MATERIALS_CLEARCOAT]) {
1578
+ var clearcoatExtension = extensions[EXTENSIONS.KHR_MATERIALS_CLEARCOAT];
1579
+ materialType = clearcoatExtension.getMaterialType();
1580
+ pending.push(clearcoatExtension.extendParams(materialParams, { extensions: materialExtensions }, parser));
1581
+ }
1582
+ if (materialExtensions[EXTENSIONS.KHR_MATERIALS_TRANSMISSION]) {
1583
+ var clearcoatExtension = extensions[EXTENSIONS.KHR_MATERIALS_TRANSMISSION];
1584
+ materialType = clearcoatExtension.getMaterialType();
1585
+ pending.push(clearcoatExtension.extendParams(materialParams, { extensions: materialExtensions }, parser));
1586
+ }
1587
+ return Promise.all(pending).then(function() {
1588
+ var material;
1589
+ if (materialType === GLTFMeshStandardSGMaterial) {
1590
+ material = extensions[EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(materialParams);
1591
+ } else {
1592
+ material = new materialType(materialParams);
1593
+ }
1594
+ if (materialDef.name)
1595
+ material.name = materialDef.name;
1596
+ if (material.map)
1597
+ material.map.encoding = sRGBEncoding;
1598
+ if (material.emissiveMap)
1599
+ material.emissiveMap.encoding = sRGBEncoding;
1600
+ assignExtrasToUserData(material, materialDef);
1601
+ parser.associations.set(material, { type: "materials", index: materialIndex });
1602
+ if (materialDef.extensions)
1603
+ addUnknownExtensionsToUserData(extensions, material, materialDef);
1604
+ return material;
1605
+ });
1606
+ };
1607
+ function computeBounds(geometry, primitiveDef, parser) {
1608
+ var attributes = primitiveDef.attributes;
1609
+ var box = new Box3();
1610
+ if (attributes.POSITION !== void 0) {
1611
+ var accessor = parser.json.accessors[attributes.POSITION];
1612
+ var min = accessor.min;
1613
+ var max = accessor.max;
1614
+ if (min !== void 0 && max !== void 0) {
1615
+ box.set(
1616
+ new Vector3(min[0], min[1], min[2]),
1617
+ new Vector3(max[0], max[1], max[2])
1618
+ );
1619
+ } else {
1620
+ console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
1621
+ return;
1622
+ }
1623
+ } else {
1624
+ return;
1625
+ }
1626
+ var targets = primitiveDef.targets;
1627
+ if (targets !== void 0) {
1628
+ var maxDisplacement = new Vector3();
1629
+ var vector = new Vector3();
1630
+ for (var i = 0, il = targets.length; i < il; i++) {
1631
+ var target = targets[i];
1632
+ if (target.POSITION !== void 0) {
1633
+ var accessor = parser.json.accessors[target.POSITION];
1634
+ var min = accessor.min;
1635
+ var max = accessor.max;
1636
+ if (min !== void 0 && max !== void 0) {
1637
+ vector.setX(Math.max(Math.abs(min[0]), Math.abs(max[0])));
1638
+ vector.setY(Math.max(Math.abs(min[1]), Math.abs(max[1])));
1639
+ vector.setZ(Math.max(Math.abs(min[2]), Math.abs(max[2])));
1640
+ maxDisplacement.max(vector);
1641
+ } else {
1642
+ console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
1643
+ }
1644
+ }
1645
+ }
1646
+ box.expandByVector(maxDisplacement);
1647
+ }
1648
+ geometry.boundingBox = box;
1649
+ var sphere = new Sphere();
1650
+ box.getCenter(sphere.center);
1651
+ sphere.radius = box.min.distanceTo(box.max) / 2;
1652
+ geometry.boundingSphere = sphere;
1653
+ }
1654
+ function addPrimitiveAttributes(geometry, primitiveDef, parser) {
1655
+ var attributes = primitiveDef.attributes;
1656
+ var pending = [];
1657
+ function assignAttributeAccessor(accessorIndex, attributeName) {
1658
+ return parser.getDependency("accessor", accessorIndex).then(function(accessor2) {
1659
+ geometry.setAttribute(attributeName, accessor2);
1660
+ });
1661
+ }
1662
+ for (var gltfAttributeName in attributes) {
1663
+ var threeAttributeName = ATTRIBUTES[gltfAttributeName] || gltfAttributeName.toLowerCase();
1664
+ if (threeAttributeName in geometry.attributes)
1665
+ continue;
1666
+ pending.push(assignAttributeAccessor(attributes[gltfAttributeName], threeAttributeName));
1667
+ }
1668
+ if (primitiveDef.indices !== void 0 && !geometry.index) {
1669
+ var accessor = parser.getDependency("accessor", primitiveDef.indices).then(function(accessor2) {
1670
+ geometry.setIndex(accessor2);
1671
+ });
1672
+ pending.push(accessor);
1673
+ }
1674
+ assignExtrasToUserData(geometry, primitiveDef);
1675
+ computeBounds(geometry, primitiveDef, parser);
1676
+ return Promise.all(pending).then(function() {
1677
+ return primitiveDef.targets !== void 0 ? addMorphTargets(geometry, primitiveDef.targets, parser) : geometry;
1678
+ });
1679
+ }
1680
+ function toTrianglesDrawMode(geometry, drawMode) {
1681
+ var index = geometry.getIndex();
1682
+ if (index === null) {
1683
+ var indices = [];
1684
+ var position = geometry.getAttribute("position");
1685
+ if (position !== void 0) {
1686
+ for (var i = 0; i < position.count; i++) {
1687
+ indices.push(i);
1688
+ }
1689
+ geometry.setIndex(indices);
1690
+ index = geometry.getIndex();
1691
+ } else {
1692
+ console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.");
1693
+ return geometry;
1694
+ }
1695
+ }
1696
+ var numberOfTriangles = index.count - 2;
1697
+ var newIndices = [];
1698
+ if (drawMode === TriangleFanDrawMode) {
1699
+ for (var i = 1; i <= numberOfTriangles; i++) {
1700
+ newIndices.push(index.getX(0));
1701
+ newIndices.push(index.getX(i));
1702
+ newIndices.push(index.getX(i + 1));
1703
+ }
1704
+ } else {
1705
+ for (var i = 0; i < numberOfTriangles; i++) {
1706
+ if (i % 2 === 0) {
1707
+ newIndices.push(index.getX(i));
1708
+ newIndices.push(index.getX(i + 1));
1709
+ newIndices.push(index.getX(i + 2));
1710
+ } else {
1711
+ newIndices.push(index.getX(i + 2));
1712
+ newIndices.push(index.getX(i + 1));
1713
+ newIndices.push(index.getX(i));
1714
+ }
1715
+ }
1716
+ }
1717
+ if (newIndices.length / 3 !== numberOfTriangles) {
1718
+ console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");
1719
+ }
1720
+ var newGeometry = geometry.clone();
1721
+ newGeometry.setIndex(newIndices);
1722
+ return newGeometry;
1723
+ }
1724
+ GLTFParser.prototype.loadGeometries = function(primitives) {
1725
+ var parser = this;
1726
+ var extensions = this.extensions;
1727
+ var cache = this.primitiveCache;
1728
+ function createDracoPrimitive(primitive2) {
1729
+ return extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(primitive2, parser).then(function(geometry) {
1730
+ return addPrimitiveAttributes(geometry, primitive2, parser);
1731
+ });
1732
+ }
1733
+ var pending = [];
1734
+ for (var i = 0, il = primitives.length; i < il; i++) {
1735
+ var primitive = primitives[i];
1736
+ var cacheKey = createPrimitiveKey(primitive);
1737
+ var cached = cache[cacheKey];
1738
+ if (cached) {
1739
+ pending.push(cached.promise);
1740
+ } else {
1741
+ var geometryPromise;
1742
+ if (primitive.extensions && primitive.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION]) {
1743
+ geometryPromise = createDracoPrimitive(primitive);
1744
+ } else {
1745
+ geometryPromise = addPrimitiveAttributes(new BufferGeometry(), primitive, parser);
1746
+ }
1747
+ cache[cacheKey] = { primitive, promise: geometryPromise };
1748
+ pending.push(geometryPromise);
1749
+ }
1750
+ }
1751
+ return Promise.all(pending);
1752
+ };
1753
+ GLTFParser.prototype.loadMesh = function(meshIndex) {
1754
+ var parser = this;
1755
+ var json = this.json;
1756
+ var meshDef = json.meshes[meshIndex];
1757
+ var primitives = meshDef.primitives;
1758
+ var pending = [];
1759
+ for (var i = 0, il = primitives.length; i < il; i++) {
1760
+ var material = primitives[i].material === void 0 ? createDefaultMaterial(this.cache) : this.getDependency("material", primitives[i].material);
1761
+ pending.push(material);
1762
+ }
1763
+ pending.push(parser.loadGeometries(primitives));
1764
+ return Promise.all(pending).then(function(results) {
1765
+ var materials = results.slice(0, results.length - 1);
1766
+ var geometries = results[results.length - 1];
1767
+ var meshes = [];
1768
+ for (var i2 = 0, il2 = geometries.length; i2 < il2; i2++) {
1769
+ var geometry = geometries[i2];
1770
+ var primitive = primitives[i2];
1771
+ var mesh;
1772
+ var material2 = materials[i2];
1773
+ if (primitive.mode === WEBGL_CONSTANTS.TRIANGLES || primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP || primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN || primitive.mode === void 0) {
1774
+ mesh = meshDef.isSkinnedMesh === true ? new SkinnedMesh(geometry, material2) : new Mesh(geometry, material2);
1775
+ if (mesh.isSkinnedMesh === true && !mesh.geometry.attributes.skinWeight.normalized) {
1776
+ mesh.normalizeSkinWeights();
1777
+ }
1778
+ if (primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP) {
1779
+ mesh.geometry = toTrianglesDrawMode(mesh.geometry, TriangleStripDrawMode);
1780
+ } else if (primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN) {
1781
+ mesh.geometry = toTrianglesDrawMode(mesh.geometry, TriangleFanDrawMode);
1782
+ }
1783
+ } else if (primitive.mode === WEBGL_CONSTANTS.LINES) {
1784
+ mesh = new LineSegments(geometry, material2);
1785
+ } else if (primitive.mode === WEBGL_CONSTANTS.LINE_STRIP) {
1786
+ mesh = new Line(geometry, material2);
1787
+ } else if (primitive.mode === WEBGL_CONSTANTS.LINE_LOOP) {
1788
+ mesh = new LineLoop(geometry, material2);
1789
+ } else if (primitive.mode === WEBGL_CONSTANTS.POINTS) {
1790
+ mesh = new Points(geometry, material2);
1791
+ } else {
1792
+ throw new Error("THREE.GLTFLoader: Primitive mode unsupported: " + primitive.mode);
1793
+ }
1794
+ if (Object.keys(mesh.geometry.morphAttributes).length > 0) {
1795
+ updateMorphTargets(mesh, meshDef);
1796
+ }
1797
+ mesh.name = meshDef.name || "mesh_" + meshIndex;
1798
+ if (geometries.length > 1)
1799
+ mesh.name += "_" + i2;
1800
+ assignExtrasToUserData(mesh, meshDef);
1801
+ parser.assignFinalMaterial(mesh);
1802
+ meshes.push(mesh);
1803
+ }
1804
+ if (meshes.length === 1) {
1805
+ return meshes[0];
1806
+ }
1807
+ var group = new Group();
1808
+ for (var i2 = 0, il2 = meshes.length; i2 < il2; i2++) {
1809
+ group.add(meshes[i2]);
1810
+ }
1811
+ return group;
1812
+ });
1813
+ };
1814
+ GLTFParser.prototype.loadCamera = function(cameraIndex) {
1815
+ var camera;
1816
+ var cameraDef = this.json.cameras[cameraIndex];
1817
+ var params = cameraDef[cameraDef.type];
1818
+ if (!params) {
1819
+ console.warn("THREE.GLTFLoader: Missing camera parameters.");
1820
+ return;
1821
+ }
1822
+ if (cameraDef.type === "perspective") {
1823
+ camera = new PerspectiveCamera(MathUtils.radToDeg(params.yfov), params.aspectRatio || 1, params.znear || 1, params.zfar || 2e6);
1824
+ } else if (cameraDef.type === "orthographic") {
1825
+ camera = new OrthographicCamera(-params.xmag, params.xmag, params.ymag, -params.ymag, params.znear, params.zfar);
1826
+ }
1827
+ if (cameraDef.name)
1828
+ camera.name = cameraDef.name;
1829
+ assignExtrasToUserData(camera, cameraDef);
1830
+ return Promise.resolve(camera);
1831
+ };
1832
+ GLTFParser.prototype.loadSkin = function(skinIndex) {
1833
+ var skinDef = this.json.skins[skinIndex];
1834
+ var skinEntry = { joints: skinDef.joints };
1835
+ if (skinDef.inverseBindMatrices === void 0) {
1836
+ return Promise.resolve(skinEntry);
1837
+ }
1838
+ return this.getDependency("accessor", skinDef.inverseBindMatrices).then(function(accessor) {
1839
+ skinEntry.inverseBindMatrices = accessor;
1840
+ return skinEntry;
1841
+ });
1842
+ };
1843
+ GLTFParser.prototype.loadAnimation = function(animationIndex) {
1844
+ var json = this.json;
1845
+ var animationDef = json.animations[animationIndex];
1846
+ var pendingNodes = [];
1847
+ var pendingInputAccessors = [];
1848
+ var pendingOutputAccessors = [];
1849
+ var pendingSamplers = [];
1850
+ var pendingTargets = [];
1851
+ for (var i = 0, il = animationDef.channels.length; i < il; i++) {
1852
+ var channel = animationDef.channels[i];
1853
+ var sampler = animationDef.samplers[channel.sampler];
1854
+ var target = channel.target;
1855
+ var name = target.node !== void 0 ? target.node : target.id;
1856
+ var input = animationDef.parameters !== void 0 ? animationDef.parameters[sampler.input] : sampler.input;
1857
+ var output = animationDef.parameters !== void 0 ? animationDef.parameters[sampler.output] : sampler.output;
1858
+ pendingNodes.push(this.getDependency("node", name));
1859
+ pendingInputAccessors.push(this.getDependency("accessor", input));
1860
+ pendingOutputAccessors.push(this.getDependency("accessor", output));
1861
+ pendingSamplers.push(sampler);
1862
+ pendingTargets.push(target);
1863
+ }
1864
+ return Promise.all([
1865
+ Promise.all(pendingNodes),
1866
+ Promise.all(pendingInputAccessors),
1867
+ Promise.all(pendingOutputAccessors),
1868
+ Promise.all(pendingSamplers),
1869
+ Promise.all(pendingTargets)
1870
+ ]).then(function(dependencies) {
1871
+ var nodes = dependencies[0];
1872
+ var inputAccessors = dependencies[1];
1873
+ var outputAccessors = dependencies[2];
1874
+ var samplers = dependencies[3];
1875
+ var targets = dependencies[4];
1876
+ var tracks = [];
1877
+ for (var i2 = 0, il2 = nodes.length; i2 < il2; i2++) {
1878
+ var node = nodes[i2];
1879
+ var inputAccessor = inputAccessors[i2];
1880
+ var outputAccessor = outputAccessors[i2];
1881
+ var sampler2 = samplers[i2];
1882
+ var target2 = targets[i2];
1883
+ if (node === void 0)
1884
+ continue;
1885
+ node.updateMatrix();
1886
+ node.matrixAutoUpdate = true;
1887
+ var TypedKeyframeTrack;
1888
+ switch (PATH_PROPERTIES[target2.path]) {
1889
+ case PATH_PROPERTIES.weights:
1890
+ TypedKeyframeTrack = NumberKeyframeTrack;
1891
+ break;
1892
+ case PATH_PROPERTIES.rotation:
1893
+ TypedKeyframeTrack = QuaternionKeyframeTrack;
1894
+ break;
1895
+ case PATH_PROPERTIES.position:
1896
+ case PATH_PROPERTIES.scale:
1897
+ default:
1898
+ TypedKeyframeTrack = VectorKeyframeTrack;
1899
+ break;
1900
+ }
1901
+ var targetName = node.name ? node.name : node.uuid;
1902
+ var interpolation = sampler2.interpolation !== void 0 ? INTERPOLATION[sampler2.interpolation] : InterpolateLinear;
1903
+ var targetNames = [];
1904
+ if (PATH_PROPERTIES[target2.path] === PATH_PROPERTIES.weights) {
1905
+ node.traverse(function(object) {
1906
+ if (object.isMesh === true && object.morphTargetInfluences) {
1907
+ targetNames.push(object.name ? object.name : object.uuid);
1908
+ }
1909
+ });
1910
+ } else {
1911
+ targetNames.push(targetName);
1912
+ }
1913
+ var outputArray = outputAccessor.array;
1914
+ if (outputAccessor.normalized) {
1915
+ var scale;
1916
+ if (outputArray.constructor === Int8Array) {
1917
+ scale = 1 / 127;
1918
+ } else if (outputArray.constructor === Uint8Array) {
1919
+ scale = 1 / 255;
1920
+ } else if (outputArray.constructor == Int16Array) {
1921
+ scale = 1 / 32767;
1922
+ } else if (outputArray.constructor === Uint16Array) {
1923
+ scale = 1 / 65535;
1924
+ } else {
1925
+ throw new Error("THREE.GLTFLoader: Unsupported output accessor component type.");
1926
+ }
1927
+ var scaled = new Float32Array(outputArray.length);
1928
+ for (var j = 0, jl = outputArray.length; j < jl; j++) {
1929
+ scaled[j] = outputArray[j] * scale;
1930
+ }
1931
+ outputArray = scaled;
1932
+ }
1933
+ for (var j = 0, jl = targetNames.length; j < jl; j++) {
1934
+ var track = new TypedKeyframeTrack(
1935
+ targetNames[j] + "." + PATH_PROPERTIES[target2.path],
1936
+ inputAccessor.array,
1937
+ outputArray,
1938
+ interpolation
1939
+ );
1940
+ if (sampler2.interpolation === "CUBICSPLINE") {
1941
+ track.createInterpolant = function InterpolantFactoryMethodGLTFCubicSpline(result) {
1942
+ return new GLTFCubicSplineInterpolant(this.times, this.values, this.getValueSize() / 3, result);
1943
+ };
1944
+ track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = true;
1945
+ }
1946
+ tracks.push(track);
1947
+ }
1948
+ }
1949
+ var name2 = animationDef.name ? animationDef.name : "animation_" + animationIndex;
1950
+ return new AnimationClip(name2, void 0, tracks);
1951
+ });
1952
+ };
1953
+ GLTFParser.prototype.loadNode = function(nodeIndex) {
1954
+ var json = this.json;
1955
+ var extensions = this.extensions;
1956
+ var parser = this;
1957
+ var meshReferences = json.meshReferences;
1958
+ var meshUses = json.meshUses;
1959
+ var nodeDef = json.nodes[nodeIndex];
1960
+ return function() {
1961
+ var pending = [];
1962
+ if (nodeDef.mesh !== void 0) {
1963
+ pending.push(parser.getDependency("mesh", nodeDef.mesh).then(function(mesh) {
1964
+ var node;
1965
+ if (meshReferences[nodeDef.mesh] > 1) {
1966
+ var instanceNum = meshUses[nodeDef.mesh]++;
1967
+ node = mesh.clone();
1968
+ node.name += "_instance_" + instanceNum;
1969
+ } else {
1970
+ node = mesh;
1971
+ }
1972
+ if (nodeDef.weights !== void 0) {
1973
+ node.traverse(function(o) {
1974
+ if (!o.isMesh)
1975
+ return;
1976
+ for (var i = 0, il = nodeDef.weights.length; i < il; i++) {
1977
+ o.morphTargetInfluences[i] = nodeDef.weights[i];
1978
+ }
1979
+ });
1980
+ }
1981
+ return node;
1982
+ }));
1983
+ }
1984
+ if (nodeDef.camera !== void 0) {
1985
+ pending.push(parser.getDependency("camera", nodeDef.camera));
1986
+ }
1987
+ if (nodeDef.extensions && nodeDef.extensions[EXTENSIONS.KHR_LIGHTS_PUNCTUAL] && nodeDef.extensions[EXTENSIONS.KHR_LIGHTS_PUNCTUAL].light !== void 0) {
1988
+ pending.push(parser.getDependency("light", nodeDef.extensions[EXTENSIONS.KHR_LIGHTS_PUNCTUAL].light));
1989
+ }
1990
+ return Promise.all(pending);
1991
+ }().then(function(objects) {
1992
+ var node;
1993
+ if (nodeDef.isBone === true) {
1994
+ node = new Bone();
1995
+ } else if (objects.length > 1) {
1996
+ node = new Group();
1997
+ } else if (objects.length === 1) {
1998
+ node = objects[0];
1999
+ } else {
2000
+ node = new Object3D();
2001
+ }
2002
+ if (node !== objects[0]) {
2003
+ for (var i = 0, il = objects.length; i < il; i++) {
2004
+ node.add(objects[i]);
2005
+ }
2006
+ }
2007
+ if (nodeDef.name) {
2008
+ node.userData.name = nodeDef.name;
2009
+ node.name = PropertyBinding.sanitizeNodeName(nodeDef.name);
2010
+ }
2011
+ assignExtrasToUserData(node, nodeDef);
2012
+ if (nodeDef.extensions)
2013
+ addUnknownExtensionsToUserData(extensions, node, nodeDef);
2014
+ if (nodeDef.matrix !== void 0) {
2015
+ var matrix = new Matrix4();
2016
+ matrix.fromArray(nodeDef.matrix);
2017
+ node.applyMatrix4(matrix);
2018
+ } else {
2019
+ if (nodeDef.translation !== void 0) {
2020
+ node.position.fromArray(nodeDef.translation);
2021
+ }
2022
+ if (nodeDef.rotation !== void 0) {
2023
+ node.quaternion.fromArray(nodeDef.rotation);
2024
+ }
2025
+ if (nodeDef.scale !== void 0) {
2026
+ node.scale.fromArray(nodeDef.scale);
2027
+ }
2028
+ }
2029
+ parser.associations.set(node, { type: "nodes", index: nodeIndex });
2030
+ return node;
2031
+ });
2032
+ };
2033
+ GLTFParser.prototype.loadScene = /* @__PURE__ */ function() {
2034
+ function buildNodeHierachy(nodeId, parentObject, json, parser) {
2035
+ var nodeDef = json.nodes[nodeId];
2036
+ return parser.getDependency("node", nodeId).then(function(node) {
2037
+ if (nodeDef.skin === void 0)
2038
+ return node;
2039
+ var skinEntry;
2040
+ return parser.getDependency("skin", nodeDef.skin).then(function(skin) {
2041
+ skinEntry = skin;
2042
+ var pendingJoints = [];
2043
+ for (var i = 0, il = skinEntry.joints.length; i < il; i++) {
2044
+ pendingJoints.push(parser.getDependency("node", skinEntry.joints[i]));
2045
+ }
2046
+ return Promise.all(pendingJoints);
2047
+ }).then(function(jointNodes) {
2048
+ node.traverse(function(mesh) {
2049
+ if (!mesh.isMesh)
2050
+ return;
2051
+ var bones = [];
2052
+ var boneInverses = [];
2053
+ for (var j = 0, jl = jointNodes.length; j < jl; j++) {
2054
+ var jointNode = jointNodes[j];
2055
+ if (jointNode) {
2056
+ bones.push(jointNode);
2057
+ var mat = new Matrix4();
2058
+ if (skinEntry.inverseBindMatrices !== void 0) {
2059
+ mat.fromArray(skinEntry.inverseBindMatrices.array, j * 16);
2060
+ }
2061
+ boneInverses.push(mat);
2062
+ } else {
2063
+ console.warn('THREE.GLTFLoader: Joint "%s" could not be found.', skinEntry.joints[j]);
2064
+ }
2065
+ }
2066
+ mesh.bind(new Skeleton(bones, boneInverses), mesh.matrixWorld);
2067
+ });
2068
+ return node;
2069
+ });
2070
+ }).then(function(node) {
2071
+ parentObject.add(node);
2072
+ var pending = [];
2073
+ if (nodeDef.children) {
2074
+ var children = nodeDef.children;
2075
+ for (var i = 0, il = children.length; i < il; i++) {
2076
+ var child = children[i];
2077
+ pending.push(buildNodeHierachy(child, node, json, parser));
2078
+ }
2079
+ }
2080
+ return Promise.all(pending);
2081
+ });
2082
+ }
2083
+ return function loadScene(sceneIndex) {
2084
+ var json = this.json;
2085
+ var extensions = this.extensions;
2086
+ var sceneDef = this.json.scenes[sceneIndex];
2087
+ var parser = this;
2088
+ var scene = new Group();
2089
+ if (sceneDef.name)
2090
+ scene.name = sceneDef.name;
2091
+ assignExtrasToUserData(scene, sceneDef);
2092
+ if (sceneDef.extensions)
2093
+ addUnknownExtensionsToUserData(extensions, scene, sceneDef);
2094
+ var nodeIds = sceneDef.nodes || [];
2095
+ var pending = [];
2096
+ for (var i = 0, il = nodeIds.length; i < il; i++) {
2097
+ pending.push(buildNodeHierachy(nodeIds[i], scene, json, parser));
2098
+ }
2099
+ return Promise.all(pending).then(function() {
2100
+ return scene;
2101
+ });
2102
+ };
2103
+ }();
2104
+ return GLTFLoader2;
2105
+ }();
2106
+ var DRACOLoader = function(manager) {
2107
+ Loader.call(this, manager);
2108
+ this.decoderPath = "";
2109
+ this.decoderConfig = {};
2110
+ this.decoderBinary = null;
2111
+ this.decoderPending = null;
2112
+ this.workerLimit = 4;
2113
+ this.workerPool = [];
2114
+ this.workerNextTaskID = 1;
2115
+ this.workerSourceURL = "";
2116
+ this.defaultAttributeIDs = {
2117
+ position: "POSITION",
2118
+ normal: "NORMAL",
2119
+ color: "COLOR",
2120
+ uv: "TEX_COORD"
2121
+ };
2122
+ this.defaultAttributeTypes = {
2123
+ position: "Float32Array",
2124
+ normal: "Float32Array",
2125
+ color: "Float32Array",
2126
+ uv: "Float32Array"
2127
+ };
2128
+ };
2129
+ DRACOLoader.prototype = Object.assign(Object.create(Loader.prototype), {
2130
+ constructor: DRACOLoader,
2131
+ setDecoderPath: function(path) {
2132
+ this.decoderPath = path;
2133
+ return this;
2134
+ },
2135
+ setDecoderConfig: function(config) {
2136
+ this.decoderConfig = config;
2137
+ return this;
2138
+ },
2139
+ setWorkerLimit: function(workerLimit) {
2140
+ this.workerLimit = workerLimit;
2141
+ return this;
2142
+ },
2143
+ /** @deprecated */
2144
+ setVerbosity: function() {
2145
+ console.warn("THREE.DRACOLoader: The .setVerbosity() method has been removed.");
2146
+ },
2147
+ /** @deprecated */
2148
+ setDrawMode: function() {
2149
+ console.warn("THREE.DRACOLoader: The .setDrawMode() method has been removed.");
2150
+ },
2151
+ /** @deprecated */
2152
+ setSkipDequantization: function() {
2153
+ console.warn("THREE.DRACOLoader: The .setSkipDequantization() method has been removed.");
2154
+ },
2155
+ load: function(url, onLoad, onProgress, onError) {
2156
+ var loader = new FileLoader(this.manager);
2157
+ loader.setPath(this.path);
2158
+ loader.setResponseType("arraybuffer");
2159
+ if (this.crossOrigin === "use-credentials") {
2160
+ loader.setWithCredentials(true);
2161
+ }
2162
+ loader.load(url, (buffer) => {
2163
+ var taskConfig = {
2164
+ attributeIDs: this.defaultAttributeIDs,
2165
+ attributeTypes: this.defaultAttributeTypes,
2166
+ useUniqueIDs: false
2167
+ };
2168
+ this.decodeGeometry(buffer, taskConfig).then(onLoad).catch(onError);
2169
+ }, onProgress, onError);
2170
+ },
2171
+ /** @deprecated Kept for backward-compatibility with previous DRACOLoader versions. */
2172
+ decodeDracoFile: function(buffer, callback, attributeIDs, attributeTypes) {
2173
+ var taskConfig = {
2174
+ attributeIDs: attributeIDs || this.defaultAttributeIDs,
2175
+ attributeTypes: attributeTypes || this.defaultAttributeTypes,
2176
+ useUniqueIDs: !!attributeIDs
2177
+ };
2178
+ this.decodeGeometry(buffer, taskConfig).then(callback);
2179
+ },
2180
+ decodeGeometry: function(buffer, taskConfig) {
2181
+ for (var attribute in taskConfig.attributeTypes) {
2182
+ var type = taskConfig.attributeTypes[attribute];
2183
+ if (type.BYTES_PER_ELEMENT !== void 0) {
2184
+ taskConfig.attributeTypes[attribute] = type.name;
2185
+ }
2186
+ }
2187
+ var taskKey = JSON.stringify(taskConfig);
2188
+ if (DRACOLoader.taskCache.has(buffer)) {
2189
+ var cachedTask = DRACOLoader.taskCache.get(buffer);
2190
+ if (cachedTask.key === taskKey) {
2191
+ return cachedTask.promise;
2192
+ } else if (buffer.byteLength === 0) {
2193
+ throw new Error(
2194
+ "THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred."
2195
+ );
2196
+ }
2197
+ }
2198
+ var worker;
2199
+ var taskID = this.workerNextTaskID++;
2200
+ var taskCost = buffer.byteLength;
2201
+ var geometryPending = this._getWorker(taskID, taskCost).then((_worker) => {
2202
+ worker = _worker;
2203
+ return new Promise((resolve, reject) => {
2204
+ worker._callbacks[taskID] = { resolve, reject };
2205
+ worker.postMessage({ type: "decode", id: taskID, taskConfig, buffer }, [buffer]);
2206
+ });
2207
+ }).then((message) => this._createGeometry(message.geometry));
2208
+ geometryPending.catch(() => true).then(() => {
2209
+ if (worker && taskID) {
2210
+ this._releaseTask(worker, taskID);
2211
+ }
2212
+ });
2213
+ DRACOLoader.taskCache.set(buffer, {
2214
+ key: taskKey,
2215
+ promise: geometryPending
2216
+ });
2217
+ return geometryPending;
2218
+ },
2219
+ _createGeometry: function(geometryData) {
2220
+ var geometry = new BufferGeometry();
2221
+ if (geometryData.index) {
2222
+ geometry.setIndex(new BufferAttribute(geometryData.index.array, 1));
2223
+ }
2224
+ for (var i = 0; i < geometryData.attributes.length; i++) {
2225
+ var attribute = geometryData.attributes[i];
2226
+ var name = attribute.name;
2227
+ var array = attribute.array;
2228
+ var itemSize = attribute.itemSize;
2229
+ geometry.setAttribute(name, new BufferAttribute(array, itemSize));
2230
+ }
2231
+ return geometry;
2232
+ },
2233
+ _loadLibrary: function(url, responseType) {
2234
+ var loader = new FileLoader(this.manager);
2235
+ loader.setPath(this.decoderPath);
2236
+ loader.setResponseType(responseType);
2237
+ return new Promise((resolve, reject) => {
2238
+ loader.load(url, resolve, void 0, reject);
2239
+ });
2240
+ },
2241
+ preload: function() {
2242
+ this._initDecoder();
2243
+ return this;
2244
+ },
2245
+ _initDecoder: function() {
2246
+ if (this.decoderPending)
2247
+ return this.decoderPending;
2248
+ var useJS = typeof WebAssembly !== "object" || this.decoderConfig.type === "js";
2249
+ var librariesPending = [];
2250
+ if (useJS) {
2251
+ librariesPending.push(this._loadLibrary("draco_decoder.js", "text"));
2252
+ } else {
2253
+ librariesPending.push(this._loadLibrary("draco_wasm_wrapper.js", "text"));
2254
+ librariesPending.push(this._loadLibrary("draco_decoder.wasm", "arraybuffer"));
2255
+ }
2256
+ this.decoderPending = Promise.all(librariesPending).then((libraries) => {
2257
+ var jsContent = libraries[0];
2258
+ if (!useJS) {
2259
+ this.decoderConfig.wasmBinary = libraries[1];
2260
+ }
2261
+ var fn = DRACOLoader.DRACOWorker.toString();
2262
+ var body = [
2263
+ "/* draco decoder */",
2264
+ jsContent,
2265
+ "",
2266
+ "/* worker */",
2267
+ fn.substring(fn.indexOf("{") + 1, fn.lastIndexOf("}"))
2268
+ ].join("\n");
2269
+ this.workerSourceURL = URL.createObjectURL(new Blob([body]));
2270
+ });
2271
+ return this.decoderPending;
2272
+ },
2273
+ _getWorker: function(taskID, taskCost) {
2274
+ return this._initDecoder().then(() => {
2275
+ if (this.workerPool.length < this.workerLimit) {
2276
+ var worker = new Worker(this.workerSourceURL);
2277
+ worker._callbacks = {};
2278
+ worker._taskCosts = {};
2279
+ worker._taskLoad = 0;
2280
+ worker.postMessage({ type: "init", decoderConfig: this.decoderConfig });
2281
+ worker.onmessage = function(e) {
2282
+ var message = e.data;
2283
+ switch (message.type) {
2284
+ case "decode":
2285
+ worker._callbacks[message.id].resolve(message);
2286
+ break;
2287
+ case "error":
2288
+ worker._callbacks[message.id].reject(message);
2289
+ break;
2290
+ default:
2291
+ console.error('THREE.DRACOLoader: Unexpected message, "' + message.type + '"');
2292
+ }
2293
+ };
2294
+ this.workerPool.push(worker);
2295
+ } else {
2296
+ this.workerPool.sort(function(a, b) {
2297
+ return a._taskLoad > b._taskLoad ? -1 : 1;
2298
+ });
2299
+ }
2300
+ var worker = this.workerPool[this.workerPool.length - 1];
2301
+ worker._taskCosts[taskID] = taskCost;
2302
+ worker._taskLoad += taskCost;
2303
+ return worker;
2304
+ });
2305
+ },
2306
+ _releaseTask: function(worker, taskID) {
2307
+ worker._taskLoad -= worker._taskCosts[taskID];
2308
+ delete worker._callbacks[taskID];
2309
+ delete worker._taskCosts[taskID];
2310
+ },
2311
+ debug: function() {
2312
+ console.log("Task load: ", this.workerPool.map((worker) => worker._taskLoad));
2313
+ },
2314
+ dispose: function() {
2315
+ for (var i = 0; i < this.workerPool.length; ++i) {
2316
+ this.workerPool[i].terminate();
2317
+ }
2318
+ this.workerPool.length = 0;
2319
+ return this;
2320
+ }
2321
+ });
2322
+ DRACOLoader.DRACOWorker = function() {
2323
+ var decoderConfig;
2324
+ var decoderPending;
2325
+ onmessage = function(e) {
2326
+ var message = e.data;
2327
+ switch (message.type) {
2328
+ case "init":
2329
+ decoderConfig = message.decoderConfig;
2330
+ decoderPending = new Promise(function(resolve) {
2331
+ decoderConfig.onModuleLoaded = function(draco) {
2332
+ resolve({ draco });
2333
+ };
2334
+ DracoDecoderModule(decoderConfig);
2335
+ });
2336
+ break;
2337
+ case "decode":
2338
+ var buffer = message.buffer;
2339
+ var taskConfig = message.taskConfig;
2340
+ decoderPending.then((module) => {
2341
+ var draco = module.draco;
2342
+ var decoder = new draco.Decoder();
2343
+ var decoderBuffer = new draco.DecoderBuffer();
2344
+ decoderBuffer.Init(new Int8Array(buffer), buffer.byteLength);
2345
+ try {
2346
+ var geometry = decodeGeometry(draco, decoder, decoderBuffer, taskConfig);
2347
+ var buffers = geometry.attributes.map((attr) => attr.array.buffer);
2348
+ if (geometry.index)
2349
+ buffers.push(geometry.index.array.buffer);
2350
+ self.postMessage({ type: "decode", id: message.id, geometry }, buffers);
2351
+ } catch (error) {
2352
+ console.error(error);
2353
+ self.postMessage({ type: "error", id: message.id, error: error.message });
2354
+ } finally {
2355
+ draco.destroy(decoderBuffer);
2356
+ draco.destroy(decoder);
2357
+ }
2358
+ });
2359
+ break;
2360
+ }
2361
+ };
2362
+ function decodeGeometry(draco, decoder, decoderBuffer, taskConfig) {
2363
+ var attributeIDs = taskConfig.attributeIDs;
2364
+ var attributeTypes = taskConfig.attributeTypes;
2365
+ var dracoGeometry;
2366
+ var decodingStatus;
2367
+ var geometryType = decoder.GetEncodedGeometryType(decoderBuffer);
2368
+ if (geometryType === draco.TRIANGULAR_MESH) {
2369
+ dracoGeometry = new draco.Mesh();
2370
+ decodingStatus = decoder.DecodeBufferToMesh(decoderBuffer, dracoGeometry);
2371
+ } else if (geometryType === draco.POINT_CLOUD) {
2372
+ dracoGeometry = new draco.PointCloud();
2373
+ decodingStatus = decoder.DecodeBufferToPointCloud(decoderBuffer, dracoGeometry);
2374
+ } else {
2375
+ throw new Error("THREE.DRACOLoader: Unexpected geometry type.");
2376
+ }
2377
+ if (!decodingStatus.ok() || dracoGeometry.ptr === 0) {
2378
+ throw new Error("THREE.DRACOLoader: Decoding failed: " + decodingStatus.error_msg());
2379
+ }
2380
+ var geometry = { index: null, attributes: [] };
2381
+ for (var attributeName in attributeIDs) {
2382
+ var attributeType = self[attributeTypes[attributeName]];
2383
+ var attribute;
2384
+ var attributeID;
2385
+ if (taskConfig.useUniqueIDs) {
2386
+ attributeID = attributeIDs[attributeName];
2387
+ attribute = decoder.GetAttributeByUniqueId(dracoGeometry, attributeID);
2388
+ } else {
2389
+ attributeID = decoder.GetAttributeId(dracoGeometry, draco[attributeIDs[attributeName]]);
2390
+ if (attributeID === -1)
2391
+ continue;
2392
+ attribute = decoder.GetAttribute(dracoGeometry, attributeID);
2393
+ }
2394
+ geometry.attributes.push(decodeAttribute(draco, decoder, dracoGeometry, attributeName, attributeType, attribute));
2395
+ }
2396
+ if (geometryType === draco.TRIANGULAR_MESH) {
2397
+ var numFaces = dracoGeometry.num_faces();
2398
+ var numIndices = numFaces * 3;
2399
+ var index = new Uint32Array(numIndices);
2400
+ var indexArray = new draco.DracoInt32Array();
2401
+ for (var i = 0; i < numFaces; ++i) {
2402
+ decoder.GetFaceFromMesh(dracoGeometry, i, indexArray);
2403
+ for (var j = 0; j < 3; ++j) {
2404
+ index[i * 3 + j] = indexArray.GetValue(j);
2405
+ }
2406
+ }
2407
+ geometry.index = { array: index, itemSize: 1 };
2408
+ draco.destroy(indexArray);
2409
+ }
2410
+ draco.destroy(dracoGeometry);
2411
+ return geometry;
2412
+ }
2413
+ function decodeAttribute(draco, decoder, dracoGeometry, attributeName, attributeType, attribute) {
2414
+ var numComponents = attribute.num_components();
2415
+ var numPoints = dracoGeometry.num_points();
2416
+ var numValues = numPoints * numComponents;
2417
+ var dracoArray;
2418
+ var array;
2419
+ switch (attributeType) {
2420
+ case Float32Array:
2421
+ dracoArray = new draco.DracoFloat32Array();
2422
+ decoder.GetAttributeFloatForAllPoints(dracoGeometry, attribute, dracoArray);
2423
+ array = new Float32Array(numValues);
2424
+ break;
2425
+ case Int8Array:
2426
+ dracoArray = new draco.DracoInt8Array();
2427
+ decoder.GetAttributeInt8ForAllPoints(dracoGeometry, attribute, dracoArray);
2428
+ array = new Int8Array(numValues);
2429
+ break;
2430
+ case Int16Array:
2431
+ dracoArray = new draco.DracoInt16Array();
2432
+ decoder.GetAttributeInt16ForAllPoints(dracoGeometry, attribute, dracoArray);
2433
+ array = new Int16Array(numValues);
2434
+ break;
2435
+ case Int32Array:
2436
+ dracoArray = new draco.DracoInt32Array();
2437
+ decoder.GetAttributeInt32ForAllPoints(dracoGeometry, attribute, dracoArray);
2438
+ array = new Int32Array(numValues);
2439
+ break;
2440
+ case Uint8Array:
2441
+ dracoArray = new draco.DracoUInt8Array();
2442
+ decoder.GetAttributeUInt8ForAllPoints(dracoGeometry, attribute, dracoArray);
2443
+ array = new Uint8Array(numValues);
2444
+ break;
2445
+ case Uint16Array:
2446
+ dracoArray = new draco.DracoUInt16Array();
2447
+ decoder.GetAttributeUInt16ForAllPoints(dracoGeometry, attribute, dracoArray);
2448
+ array = new Uint16Array(numValues);
2449
+ break;
2450
+ case Uint32Array:
2451
+ dracoArray = new draco.DracoUInt32Array();
2452
+ decoder.GetAttributeUInt32ForAllPoints(dracoGeometry, attribute, dracoArray);
2453
+ array = new Uint32Array(numValues);
2454
+ break;
2455
+ default:
2456
+ throw new Error("THREE.DRACOLoader: Unexpected attribute type.");
2457
+ }
2458
+ for (var i = 0; i < numValues; i++) {
2459
+ array[i] = dracoArray.GetValue(i);
2460
+ }
2461
+ draco.destroy(dracoArray);
2462
+ return {
2463
+ name: attributeName,
2464
+ array,
2465
+ itemSize: numComponents
2466
+ };
2467
+ }
2468
+ };
2469
+ DRACOLoader.taskCache = /* @__PURE__ */ new WeakMap();
2470
+ DRACOLoader.setDecoderPath = function() {
2471
+ console.warn("THREE.DRACOLoader: The .setDecoderPath() method has been removed. Use instance methods.");
2472
+ };
2473
+ DRACOLoader.setDecoderConfig = function() {
2474
+ console.warn("THREE.DRACOLoader: The .setDecoderConfig() method has been removed. Use instance methods.");
2475
+ };
2476
+ DRACOLoader.releaseDecoderModule = function() {
2477
+ console.warn("THREE.DRACOLoader: The .releaseDecoderModule() method has been removed. Use instance methods.");
2478
+ };
2479
+ DRACOLoader.getDecoderModule = function() {
2480
+ console.warn("THREE.DRACOLoader: The .getDecoderModule() method has been removed. Use instance methods.");
2481
+ };
2482
+ var DDSLoader = function(manager) {
2483
+ CompressedTextureLoader.call(this, manager);
2484
+ };
2485
+ DDSLoader.prototype = Object.assign(Object.create(CompressedTextureLoader.prototype), {
2486
+ constructor: DDSLoader,
2487
+ parse: function(buffer, loadMipmaps) {
2488
+ var dds = { mipmaps: [], width: 0, height: 0, format: null, mipmapCount: 1 };
2489
+ var DDS_MAGIC = 542327876;
2490
+ var DDSD_MIPMAPCOUNT = 131072;
2491
+ var DDSCAPS2_CUBEMAP = 512;
2492
+ var DDSCAPS2_CUBEMAP_POSITIVEX = 1024;
2493
+ var DDSCAPS2_CUBEMAP_NEGATIVEX = 2048;
2494
+ var DDSCAPS2_CUBEMAP_POSITIVEY = 4096;
2495
+ var DDSCAPS2_CUBEMAP_NEGATIVEY = 8192;
2496
+ var DDSCAPS2_CUBEMAP_POSITIVEZ = 16384;
2497
+ var DDSCAPS2_CUBEMAP_NEGATIVEZ = 32768;
2498
+ var DDPF_FOURCC = 4;
2499
+ function fourCCToInt32(value) {
2500
+ return value.charCodeAt(0) + (value.charCodeAt(1) << 8) + (value.charCodeAt(2) << 16) + (value.charCodeAt(3) << 24);
2501
+ }
2502
+ function int32ToFourCC(value) {
2503
+ return String.fromCharCode(
2504
+ value & 255,
2505
+ value >> 8 & 255,
2506
+ value >> 16 & 255,
2507
+ value >> 24 & 255
2508
+ );
2509
+ }
2510
+ function loadARGBMip(buffer2, dataOffset2, width2, height2) {
2511
+ var dataLength2 = width2 * height2 * 4;
2512
+ var srcBuffer = new Uint8Array(buffer2, dataOffset2, dataLength2);
2513
+ var byteArray2 = new Uint8Array(dataLength2);
2514
+ var dst = 0;
2515
+ var src = 0;
2516
+ for (var y = 0; y < height2; y++) {
2517
+ for (var x = 0; x < width2; x++) {
2518
+ var b = srcBuffer[src];
2519
+ src++;
2520
+ var g = srcBuffer[src];
2521
+ src++;
2522
+ var r = srcBuffer[src];
2523
+ src++;
2524
+ var a = srcBuffer[src];
2525
+ src++;
2526
+ byteArray2[dst] = r;
2527
+ dst++;
2528
+ byteArray2[dst] = g;
2529
+ dst++;
2530
+ byteArray2[dst] = b;
2531
+ dst++;
2532
+ byteArray2[dst] = a;
2533
+ dst++;
2534
+ }
2535
+ }
2536
+ return byteArray2;
2537
+ }
2538
+ var FOURCC_DXT1 = fourCCToInt32("DXT1");
2539
+ var FOURCC_DXT3 = fourCCToInt32("DXT3");
2540
+ var FOURCC_DXT5 = fourCCToInt32("DXT5");
2541
+ var FOURCC_ETC1 = fourCCToInt32("ETC1");
2542
+ var headerLengthInt = 31;
2543
+ var off_magic = 0;
2544
+ var off_size = 1;
2545
+ var off_flags = 2;
2546
+ var off_height = 3;
2547
+ var off_width = 4;
2548
+ var off_mipmapCount = 7;
2549
+ var off_pfFlags = 20;
2550
+ var off_pfFourCC = 21;
2551
+ var off_RGBBitCount = 22;
2552
+ var off_RBitMask = 23;
2553
+ var off_GBitMask = 24;
2554
+ var off_BBitMask = 25;
2555
+ var off_ABitMask = 26;
2556
+ var off_caps2 = 28;
2557
+ var header = new Int32Array(buffer, 0, headerLengthInt);
2558
+ if (header[off_magic] !== DDS_MAGIC) {
2559
+ console.error("THREE.DDSLoader.parse: Invalid magic number in DDS header.");
2560
+ return dds;
2561
+ }
2562
+ if (!header[off_pfFlags] & DDPF_FOURCC) {
2563
+ console.error("THREE.DDSLoader.parse: Unsupported format, must contain a FourCC code.");
2564
+ return dds;
2565
+ }
2566
+ var blockBytes;
2567
+ var fourCC = header[off_pfFourCC];
2568
+ var isRGBAUncompressed = false;
2569
+ switch (fourCC) {
2570
+ case FOURCC_DXT1:
2571
+ blockBytes = 8;
2572
+ dds.format = RGB_S3TC_DXT1_Format;
2573
+ break;
2574
+ case FOURCC_DXT3:
2575
+ blockBytes = 16;
2576
+ dds.format = RGBA_S3TC_DXT3_Format;
2577
+ break;
2578
+ case FOURCC_DXT5:
2579
+ blockBytes = 16;
2580
+ dds.format = RGBA_S3TC_DXT5_Format;
2581
+ break;
2582
+ case FOURCC_ETC1:
2583
+ blockBytes = 8;
2584
+ dds.format = RGB_ETC1_Format;
2585
+ break;
2586
+ default:
2587
+ if (header[off_RGBBitCount] === 32 && header[off_RBitMask] & 16711680 && header[off_GBitMask] & 65280 && header[off_BBitMask] & 255 && header[off_ABitMask] & 4278190080) {
2588
+ isRGBAUncompressed = true;
2589
+ blockBytes = 64;
2590
+ dds.format = RGBAFormat;
2591
+ } else {
2592
+ console.error("THREE.DDSLoader.parse: Unsupported FourCC code ", int32ToFourCC(fourCC));
2593
+ return dds;
2594
+ }
2595
+ }
2596
+ dds.mipmapCount = 1;
2597
+ if (header[off_flags] & DDSD_MIPMAPCOUNT && loadMipmaps !== false) {
2598
+ dds.mipmapCount = Math.max(1, header[off_mipmapCount]);
2599
+ }
2600
+ var caps2 = header[off_caps2];
2601
+ dds.isCubemap = caps2 & DDSCAPS2_CUBEMAP ? true : false;
2602
+ if (dds.isCubemap && (!(caps2 & DDSCAPS2_CUBEMAP_POSITIVEX) || !(caps2 & DDSCAPS2_CUBEMAP_NEGATIVEX) || !(caps2 & DDSCAPS2_CUBEMAP_POSITIVEY) || !(caps2 & DDSCAPS2_CUBEMAP_NEGATIVEY) || !(caps2 & DDSCAPS2_CUBEMAP_POSITIVEZ) || !(caps2 & DDSCAPS2_CUBEMAP_NEGATIVEZ))) {
2603
+ console.error("THREE.DDSLoader.parse: Incomplete cubemap faces");
2604
+ return dds;
2605
+ }
2606
+ dds.width = header[off_width];
2607
+ dds.height = header[off_height];
2608
+ var dataOffset = header[off_size] + 4;
2609
+ var faces = dds.isCubemap ? 6 : 1;
2610
+ for (var face = 0; face < faces; face++) {
2611
+ var width = dds.width;
2612
+ var height = dds.height;
2613
+ for (var i = 0; i < dds.mipmapCount; i++) {
2614
+ if (isRGBAUncompressed) {
2615
+ var byteArray = loadARGBMip(buffer, dataOffset, width, height);
2616
+ var dataLength = byteArray.length;
2617
+ } else {
2618
+ var dataLength = Math.max(4, width) / 4 * Math.max(4, height) / 4 * blockBytes;
2619
+ var byteArray = new Uint8Array(buffer, dataOffset, dataLength);
2620
+ }
2621
+ var mipmap = { "data": byteArray, "width": width, "height": height };
2622
+ dds.mipmaps.push(mipmap);
2623
+ dataOffset += dataLength;
2624
+ width = Math.max(width >> 1, 1);
2625
+ height = Math.max(height >> 1, 1);
2626
+ }
2627
+ }
2628
+ return dds;
2629
+ }
2630
+ });
2631
+ var GLTFObject = (
2632
+ /** @class */
2633
+ function(_super) {
2634
+ __extends(GLTFObject2, _super);
2635
+ function GLTFObject2(rootObject) {
2636
+ var _this = _super.call(this) || this;
2637
+ _this.needsRender = true;
2638
+ if (rootObject && rootObject.children.length) {
2639
+ _this.add.apply(_this, rootObject.children);
2640
+ }
2641
+ _this.mixer = new THREE.AnimationMixer(_this);
2642
+ return _this;
2643
+ }
2644
+ GLTFObject2.prototype.clone = function() {
2645
+ var cloned = _super.prototype.clone.call(this, true);
2646
+ var mixer = new THREE.AnimationMixer(cloned);
2647
+ cloned.mixer = mixer;
2648
+ cloned.needsRender = true;
2649
+ return cloned;
2650
+ };
2651
+ return GLTFObject2;
2652
+ }(THREE.Group)
2653
+ );
2654
+ var DRACO_PATH = "https://vr-public.realsee-cdn.cn/release/static/image/release/five/resource/draco/1.5.6/";
2655
+ var GLTFLoader = (
2656
+ /** @class */
2657
+ function(_super) {
2658
+ __extends(GLTFLoader2, _super);
2659
+ function GLTFLoader2(manager) {
2660
+ var _this = _super.call(this, manager) || this;
2661
+ _this.ddsLoader = new DDSLoader(manager);
2662
+ _this.dracoLoader = new DRACOLoader(manager);
2663
+ _this.dracoLoader.setDecoderPath(DRACO_PATH);
2664
+ return _this;
2665
+ }
2666
+ Object.defineProperty(GLTFLoader2, "version", {
2667
+ get: function() {
2668
+ return "6.0.0-alpha.71";
2669
+ },
2670
+ enumerable: false,
2671
+ configurable: true
2672
+ });
2673
+ GLTFLoader2.prototype.load = function(url, onLoad, onProgress, onError) {
2674
+ return _super.prototype.load.call(this, url, onLoad, onProgress, onError);
2675
+ };
2676
+ GLTFLoader2.prototype.parse = function(data, path, onLoad, onError) {
2677
+ return _super.prototype.parse.call(this, data, path, function(gltf) {
2678
+ var scene = new GLTFObject(gltf.scene);
2679
+ var scenes = gltf.scenes.map(function(scene_) {
2680
+ if (scene_ === gltf.scene)
2681
+ return scene;
2682
+ return new GLTFObject(scene_);
2683
+ });
2684
+ onLoad(Object.assign(gltf, { scene, scenes }));
2685
+ }, onError);
2686
+ };
2687
+ return GLTFLoader2;
2688
+ }(GLTFLoader$1)
2689
+ );
2690
+ export {
2691
+ DDSLoader,
2692
+ DRACOLoader,
2693
+ GLTFLoader,
2694
+ GLTFObject,
2695
+ GLTFLoader$1 as THREEGLTFLoader
2696
+ };