@vived/component-abb-6700 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.todo.md +13 -0
- package/README.md +122 -0
- package/dist/.gitkeep +0 -0
- package/dist/Adapters/aBB6700PMAdapter.d.ts +10 -0
- package/dist/Adapters/aBB6700PMAdapter.d.ts.map +1 -0
- package/dist/Controllers/createABB6700.d.ts +12 -0
- package/dist/Controllers/createABB6700.d.ts.map +1 -0
- package/dist/Controllers/getPose.d.ts +11 -0
- package/dist/Controllers/getPose.d.ts.map +1 -0
- package/dist/Controllers/setJointAngle.d.ts +12 -0
- package/dist/Controllers/setJointAngle.d.ts.map +1 -0
- package/dist/Controllers/setPose.d.ts +11 -0
- package/dist/Controllers/setPose.d.ts.map +1 -0
- package/dist/Entities/ABB6700Entity.d.ts +35 -0
- package/dist/Entities/ABB6700Entity.d.ts.map +1 -0
- package/dist/Entities/ABB6700Repo.d.ts +32 -0
- package/dist/Entities/ABB6700Repo.d.ts.map +1 -0
- package/dist/Factory/ABB6700FeatureFactory.d.ts +26 -0
- package/dist/Factory/ABB6700FeatureFactory.d.ts.map +1 -0
- package/dist/Mocks/MockABB6700PM.d.ts +11 -0
- package/dist/Mocks/MockABB6700PM.d.ts.map +1 -0
- package/dist/Mocks/MockSetJointAngleUC.d.ts +7 -0
- package/dist/Mocks/MockSetJointAngleUC.d.ts.map +1 -0
- package/dist/Mocks/MockSetPoseUC.d.ts +7 -0
- package/dist/Mocks/MockSetPoseUC.d.ts.map +1 -0
- package/dist/PMs/ABB6700PM.d.ts +32 -0
- package/dist/PMs/ABB6700PM.d.ts.map +1 -0
- package/dist/UCs/CalcStabilizerUC.d.ts +7 -0
- package/dist/UCs/CalcStabilizerUC.d.ts.map +1 -0
- package/dist/UCs/SetJointAngleUC.d.ts +15 -0
- package/dist/UCs/SetJointAngleUC.d.ts.map +1 -0
- package/dist/UCs/SetPoseUC.d.ts +22 -0
- package/dist/UCs/SetPoseUC.d.ts.map +1 -0
- package/dist/Views/ABB6700BabylonView.d.ts +27 -0
- package/dist/Views/ABB6700BabylonView.d.ts.map +1 -0
- package/dist/abb_6700.glb +0 -0
- package/dist/abstractAudioBus-CyBWsmuN.js +14 -0
- package/dist/animationGroup-BhNThqQe.js +1454 -0
- package/dist/basisTextureLoader-BT391BsV.js +310 -0
- package/dist/brdfTextureTools-DUyKBAXf.js +79 -0
- package/dist/bumpFragment-Dd-ojPA1.js +134 -0
- package/dist/bumpFragment-KE1_PuMl.js +287 -0
- package/dist/bumpVertex-BcdvVFVx.js +8 -0
- package/dist/bumpVertexDeclaration-B5Uvs-RS.js +8 -0
- package/dist/bumpVertexDeclaration-ixSg-yGI.js +8 -0
- package/dist/clipPlaneFragment-DJwQynjA.js +136 -0
- package/dist/clipPlaneVertex-D4Wk50XG.js +376 -0
- package/dist/clipPlaneVertex-eQ147Tn2.js +350 -0
- package/dist/component.config.d.ts +17 -0
- package/dist/component.config.d.ts.map +1 -0
- package/dist/ddsTextureLoader-DeoF3iGO.js +331 -0
- package/dist/default.fragment-DKnTR9nY.js +548 -0
- package/dist/default.fragment-rIGWrUS5.js +486 -0
- package/dist/default.vertex-Bt5y1VyA.js +212 -0
- package/dist/default.vertex-Dext1liJ.js +224 -0
- package/dist/defaultUboDeclaration-BwslQZX8.js +11 -0
- package/dist/defaultUboDeclaration-DSXACgip.js +9 -0
- package/dist/easing-BAt0SO-B.js +163 -0
- package/dist/envTextureLoader-CBiW_Q-U.js +40 -0
- package/dist/exrTextureLoader-5SC6PKIA.js +740 -0
- package/dist/flowGraphApplyForceBlock-6e8-wcaw.js +32 -0
- package/dist/flowGraphApplyImpulseBlock-B27EZQow.js +32 -0
- package/dist/flowGraphArrayIndexBlock-DIUn5e4i.js +31 -0
- package/dist/flowGraphBezierCurveEasingBlock-BJmiHk40.js +25 -0
- package/dist/flowGraphBinaryOperationBlock-Bj7TANCc.js +25 -0
- package/dist/flowGraphBranchBlock-7CRvIKWc.js +19 -0
- package/dist/flowGraphCachedOperationBlock-CP1ZiuIB.js +26 -0
- package/dist/flowGraphCancelDelayBlock-DqtgzBGm.js +20 -0
- package/dist/flowGraphCodeExecutionBlock-CaYXCGqo.js +23 -0
- package/dist/flowGraphConditionalDataBlock-DJ7evX8_.js +28 -0
- package/dist/flowGraphConsoleLogBlock-cMkpqLzO.js +68 -0
- package/dist/flowGraphConstantBlock-JWybwT0A.js +28 -0
- package/dist/flowGraphContextBlock-CFDXHcbn.js +19 -0
- package/dist/flowGraphCounterBlock-B0uPkgw9.js +24 -0
- package/dist/flowGraphDataSwitchBlock-B0GSifvJ.js +27 -0
- package/dist/flowGraphDebounceBlock-CSw8zKym.js +24 -0
- package/dist/flowGraphDebugBlock-DiSR6Ahn.js +65 -0
- package/dist/flowGraphDoNBlock-C-48oQ2H.js +24 -0
- package/dist/flowGraphEasingBlock-DKUaE7Rp.js +50 -0
- package/dist/flowGraphFlipFlopBlock-DX5BGhMV.js +20 -0
- package/dist/flowGraphForLoopBlock-Di-Qwg23.js +27 -0
- package/dist/flowGraphFunctionReferenceBlock-D8X5TFsO.js +20 -0
- package/dist/flowGraphGLTFDataProvider-C4j7nPQv.js +16 -0
- package/dist/flowGraphGetAngularVelocityBlock-Cq-yTQ4D.js +31 -0
- package/dist/flowGraphGetAssetBlock-B36eioor.js +21 -0
- package/dist/flowGraphGetLinearVelocityBlock-MdrV0eUD.js +31 -0
- package/dist/flowGraphGetPhysicsMassPropertiesBlock-wXDZP1wM.js +30 -0
- package/dist/flowGraphGetPropertyBlock-eP0badwf.js +46 -0
- package/dist/flowGraphGetSoundVolumeBlock-D3gXGHXa.js +29 -0
- package/dist/flowGraphGetVariableBlock-C7-qZAec.js +31 -0
- package/dist/flowGraphIndexOfBlock-CC5l9n9P.js +31 -0
- package/dist/flowGraphInterpolationBlock-B6922jzt.js +50 -0
- package/dist/flowGraphIsKeyPressedBlock-X_iuiUOX.js +31 -0
- package/dist/flowGraphIsSoundPlayingBlock-DONQX8N8.js +29 -0
- package/dist/flowGraphJsonPointerParserBlock-DBH_gN8I.js +95 -0
- package/dist/flowGraphKeyDownEventBlock-D5T1Uyfv.js +26 -0
- package/dist/flowGraphKeyUpEventBlock-BPY_Kgkm.js +21 -0
- package/dist/flowGraphKeyboardEventBlock-C49fx3TC.js +20 -0
- package/dist/flowGraphMathBlocks-CkvrN3VJ.js +864 -0
- package/dist/flowGraphMathCombineExtractBlocks-QSjGlnoz.js +248 -0
- package/dist/flowGraphMatrixMathBlocks-B3D7Cz9p.js +117 -0
- package/dist/flowGraphMeshPickEventBlock-BBTz-taa.js +35 -0
- package/dist/flowGraphMultiGateBlock-BhY1y5BG.js +50 -0
- package/dist/flowGraphPauseAnimationBlock-CHZZXMbg.js +19 -0
- package/dist/flowGraphPauseSoundBlock-B7hMmJ0c.js +31 -0
- package/dist/flowGraphPhysicsCollisionEventBlock-CxoPpT-q.js +56 -0
- package/dist/flowGraphPlayAnimationBlock-DVAvIFux.js +99 -0
- package/dist/flowGraphPlaySoundBlock-DjHGrqbC.js +32 -0
- package/dist/flowGraphPointerDownEventBlock-qI-H0JST.js +31 -0
- package/dist/flowGraphPointerMoveEventBlock-DAi4VUyy.js +31 -0
- package/dist/flowGraphPointerOutEventBlock-CFtj68aC.js +21 -0
- package/dist/flowGraphPointerOverEventBlock-VxdHhFuu.js +23 -0
- package/dist/flowGraphPointerUpEventBlock-DRR1f07q.js +31 -0
- package/dist/flowGraphReceiveCustomEventBlock-B3bwdB66.js +52 -0
- package/dist/flowGraphSceneReadyEventBlock-Dy6lDT3j.js +23 -0
- package/dist/flowGraphSceneTickEventBlock-Bl9BF_Xw.js +32 -0
- package/dist/flowGraphSendCustomEventBlock-BAR4PGFq.js +35 -0
- package/dist/flowGraphSequenceBlock-veqU32ZZ.js +32 -0
- package/dist/flowGraphSetAngularVelocityBlock-Dj9b-zu6.js +31 -0
- package/dist/flowGraphSetDelayBlock-CMjudtvk.js +131 -0
- package/dist/flowGraphSetLinearVelocityBlock-DVDhhJBd.js +31 -0
- package/dist/flowGraphSetPhysicsMotionTypeBlock-CL3cxNCO.js +36 -0
- package/dist/flowGraphSetPropertyBlock-D3sWL3Ss.js +47 -0
- package/dist/flowGraphSetSoundVolumeBlock-CxVk45yR.js +32 -0
- package/dist/flowGraphSetVariableBlock-D1oJiwLj.js +47 -0
- package/dist/flowGraphSoundEndedEventBlock-CubEwii0.js +47 -0
- package/dist/flowGraphStopAnimationBlock-B9inwIQx.js +48 -0
- package/dist/flowGraphStopSoundBlock-BijIX2jC.js +31 -0
- package/dist/flowGraphSwitchBlock-BMhPb4OX.js +54 -0
- package/dist/flowGraphThrottleBlock-C7vrnkb1.js +37 -0
- package/dist/flowGraphTransformCoordinatesSystemBlock-DoISqaUG.js +29 -0
- package/dist/flowGraphTypeToTypeBlocks-CSML6QWx.js +57 -0
- package/dist/flowGraphUnaryOperationBlock-B0Shf-lJ.js +24 -0
- package/dist/flowGraphVectorMathBlocks-DoTRR_E0.js +178 -0
- package/dist/flowGraphWaitAllBlock-BvmDMc24.js +54 -0
- package/dist/flowGraphWhileLoopBlock-BaIq4-K2.js +27 -0
- package/dist/geometry.fragment-Bsis3UG2.js +275 -0
- package/dist/geometry.vertex-DskQ5b8j.js +222 -0
- package/dist/harmonicsFunctions-CtNrRfir.js +193 -0
- package/dist/harmonicsFunctions-PEz6APC7.js +18 -0
- package/dist/hdrTextureLoader-D9rYxJ9q.js +112 -0
- package/dist/helperFunctions-Bt7Zfkrp.js +89 -0
- package/dist/helperFunctions-CPmRxd37.js +121 -0
- package/dist/iesTextureLoader-BGUFjVhI.js +93 -0
- package/dist/index-CS3Icp_r.js +67657 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/ktxTextureLoader-cUaGg9_L.js +459 -0
- package/dist/lightFragment-BRDibDKG.js +404 -0
- package/dist/lightFragment-DCqtGMp_.js +402 -0
- package/dist/logDepthDeclaration-Bwm-3KyB.js +16 -0
- package/dist/logDepthDeclaration-gUfeSnXX.js +20 -0
- package/dist/logDepthVertex-CKeuJ6ae.js +213 -0
- package/dist/logDepthVertex-CXkmZels.js +459 -0
- package/dist/mesh.vertexData.functions-Bc9lJlrU.js +74 -0
- package/dist/oitFragment-B8zuQigp.js +792 -0
- package/dist/oitFragment-DH3h3T6x.js +657 -0
- package/dist/openpbr.fragment-BglYS6LA.js +1405 -0
- package/dist/openpbr.fragment-DrOTZs4m.js +1553 -0
- package/dist/openpbr.vertex-B-PaLFOR.js +384 -0
- package/dist/openpbr.vertex-DMdFRTnX.js +268 -0
- package/dist/openpbrMaterial-HCU0aOca.js +2880 -0
- package/dist/openpbrMaterialLoadingAdapter-CWRAa-7S.js +1122 -0
- package/dist/openpbrTransmissionLayerData-CfDVObj5.js +352 -0
- package/dist/openpbrUboDeclaration-CA2pvSbt.js +9 -0
- package/dist/openpbrUboDeclaration-xU8VOaib.js +10 -0
- package/dist/pass.fragment-1mMP54bb.js +10 -0
- package/dist/pass.fragment-DzaUp_jk.js +10 -0
- package/dist/passCube.fragment-CQaXS7g3.js +29 -0
- package/dist/passCube.fragment-QJGPwAXI.js +29 -0
- package/dist/pbr.fragment-BnaAAGxb.js +2775 -0
- package/dist/pbr.fragment-CYZk_EGU.js +2619 -0
- package/dist/pbr.vertex-CyvdCw91.js +372 -0
- package/dist/pbr.vertex-DJMAkDxs.js +270 -0
- package/dist/pbrBRDFFunctions-EugoWm6O.js +175 -0
- package/dist/pbrDebug-Bk3sPoEG.js +719 -0
- package/dist/pbrDebug-Cdalzb1I.js +614 -0
- package/dist/pbrIBLFunctions-B0bVAXCF.js +47 -0
- package/dist/pbrIBLFunctions-C06z-ouZ.js +51 -0
- package/dist/pbrMaterial-C4FCKBZQ.js +1660 -0
- package/dist/pbrMaterialLoadingAdapter-BGHlS_ZN.js +1032 -0
- package/dist/pbrUboDeclaration-1lN5_-Bw.js +9 -0
- package/dist/pbrUboDeclaration-BJOUUOZ2.js +10 -0
- package/dist/procedural.vertex-CFPKczKj.js +14 -0
- package/dist/procedural.vertex-DUW7bYZt.js +13 -0
- package/dist/rgbdDecode.fragment-CEGgE4tL.js +8 -0
- package/dist/rgbdDecode.fragment-FT0wkgah.js +8 -0
- package/dist/rgbdEncode.fragment-CLnJJf6E.js +8 -0
- package/dist/rgbdEncode.fragment-CaAcMsY9.js +8 -0
- package/dist/sceneUboDeclaration-B6oxsfcj.js +8 -0
- package/dist/sceneUboDeclaration-JByfVKik.js +13 -0
- package/dist/setupABB6700InstanceFactory.d.ts +7 -0
- package/dist/setupABB6700InstanceFactory.d.ts.map +1 -0
- package/dist/studio.env +0 -0
- package/dist/textureProcessor.fragment-BYPw6SMQ.js +152 -0
- package/dist/textureProcessor.fragment-Ciw9-F3w.js +157 -0
- package/dist/textureTools-Cct_bGgp.js +40 -0
- package/dist/tgaTextureLoader-BJOIdnFr.js +198 -0
- package/dist/thinEngine-Bt9FW4dD.js +2425 -0
- package/dist/webAudioBus-BUzRHSxr.js +88 -0
- package/dist/webAudioMainBus-Dds1TgJG.js +49 -0
- package/package.json +49 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ABB 6700 — VIVED Smart Component
|
|
3
|
+
*
|
|
4
|
+
* Public API: re-exports all component layers for consumer use.
|
|
5
|
+
*/
|
|
6
|
+
export { ABB6700Entity, makeABB6700Entity } from "./Entities/ABB6700Entity";
|
|
7
|
+
export { ABB6700Repo, makeABB6700Repo, type ABB6700EntityFactory, } from "./Entities/ABB6700Repo";
|
|
8
|
+
export { ABB6700PM, makeABB6700PM, type ABB6700VM } from "./PMs/ABB6700PM";
|
|
9
|
+
export { aBB6700PMAdapter } from "./Adapters/aBB6700PMAdapter";
|
|
10
|
+
export { ABB6700BabylonView, makeABB6700BabylonView, } from "./Views/ABB6700BabylonView";
|
|
11
|
+
export { ABB6700FeatureFactory, makeABB6700FeatureFactory, } from "./Factory/ABB6700FeatureFactory";
|
|
12
|
+
export { setupABB6700InstanceFactory } from "./setupABB6700InstanceFactory";
|
|
13
|
+
export { SetJointAngleUC, makeSetJointAngleUC, type ABB6700Joint, } from "./UCs/SetJointAngleUC";
|
|
14
|
+
export { SetPoseUC, makeSetPoseUC, type ABB6700Pose } from "./UCs/SetPoseUC";
|
|
15
|
+
export { createABB6700 } from "./Controllers/createABB6700";
|
|
16
|
+
export { setJointAngle } from "./Controllers/setJointAngle";
|
|
17
|
+
export { setPose } from "./Controllers/setPose";
|
|
18
|
+
export { getPose } from "./Controllers/getPose";
|
|
19
|
+
export { MockABB6700PM } from "./Mocks/MockABB6700PM";
|
|
20
|
+
export { MockSetJointAngleUC } from "./Mocks/MockSetJointAngleUC";
|
|
21
|
+
export { MockSetPoseUC } from "./Mocks/MockSetPoseUC";
|
|
22
|
+
export { default as componentConfig } from "./component.config";
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EACL,WAAW,EACX,eAAe,EACf,KAAK,oBAAoB,GAC1B,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAG/D,OAAO,EACL,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACL,qBAAqB,EACrB,yBAAyB,GAC1B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAG5E,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,KAAK,YAAY,GAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG7E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAGhD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGtD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { A as s, a as B, b as t, c as o, d as c, ae as A, af as n, ag as b, a_ as k, a$ as i, bJ as m, bL as r, bM as P, bU as M, b_ as g, b$ as y, c0 as C, c1 as U, c2 as l, c3 as p, c4 as S, ca as F, cb as J, cc as f } from "./index-CS3Icp_r.js";
|
|
2
|
+
export {
|
|
3
|
+
s as ABB6700BabylonView,
|
|
4
|
+
B as ABB6700Entity,
|
|
5
|
+
t as ABB6700FeatureFactory,
|
|
6
|
+
o as ABB6700PM,
|
|
7
|
+
c as ABB6700Repo,
|
|
8
|
+
A as MockABB6700PM,
|
|
9
|
+
n as MockSetJointAngleUC,
|
|
10
|
+
b as MockSetPoseUC,
|
|
11
|
+
k as SetJointAngleUC,
|
|
12
|
+
i as SetPoseUC,
|
|
13
|
+
m as aBB6700PMAdapter,
|
|
14
|
+
r as componentConfig,
|
|
15
|
+
P as createABB6700,
|
|
16
|
+
M as getPose,
|
|
17
|
+
g as makeABB6700BabylonView,
|
|
18
|
+
y as makeABB6700Entity,
|
|
19
|
+
C as makeABB6700FeatureFactory,
|
|
20
|
+
U as makeABB6700PM,
|
|
21
|
+
l as makeABB6700Repo,
|
|
22
|
+
p as makeSetJointAngleUC,
|
|
23
|
+
S as makeSetPoseUC,
|
|
24
|
+
F as setJointAngle,
|
|
25
|
+
J as setPose,
|
|
26
|
+
f as setupABB6700InstanceFactory
|
|
27
|
+
};
|
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
import { a7 as l, b9 as n, k as u } from "./index-CS3Icp_r.js";
|
|
2
|
+
class d {
|
|
3
|
+
/**
|
|
4
|
+
* Creates a new KhronosTextureContainer
|
|
5
|
+
* @param data contents of the KTX container file
|
|
6
|
+
* @param facesExpected should be either 1 or 6, based whether a cube texture or or
|
|
7
|
+
*/
|
|
8
|
+
constructor(s, e) {
|
|
9
|
+
if (this.data = s, this.isInvalid = !1, !d.IsValid(s)) {
|
|
10
|
+
this.isInvalid = !0, l.Error("texture missing KTX identifier");
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const i = Uint32Array.BYTES_PER_ELEMENT, r = new DataView(this.data.buffer, this.data.byteOffset + 12, 13 * i), a = r.getUint32(0, !0) === 67305985;
|
|
14
|
+
if (this.glType = r.getUint32(1 * i, a), this.glTypeSize = r.getUint32(2 * i, a), this.glFormat = r.getUint32(3 * i, a), this.glInternalFormat = r.getUint32(4 * i, a), this.glBaseInternalFormat = r.getUint32(5 * i, a), this.pixelWidth = r.getUint32(6 * i, a), this.pixelHeight = r.getUint32(7 * i, a), this.pixelDepth = r.getUint32(8 * i, a), this.numberOfArrayElements = r.getUint32(9 * i, a), this.numberOfFaces = r.getUint32(10 * i, a), this.numberOfMipmapLevels = r.getUint32(11 * i, a), this.bytesOfKeyValueData = r.getUint32(12 * i, a), this.glType !== 0) {
|
|
15
|
+
l.Error("only compressed formats currently supported"), this.isInvalid = !0;
|
|
16
|
+
return;
|
|
17
|
+
} else
|
|
18
|
+
this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
|
|
19
|
+
if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
|
|
20
|
+
l.Error("only 2D textures currently supported"), this.isInvalid = !0;
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (this.numberOfArrayElements !== 0) {
|
|
24
|
+
l.Error("texture arrays not currently supported"), this.isInvalid = !0;
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (this.numberOfFaces !== e) {
|
|
28
|
+
l.Error("number of faces expected" + e + ", but found " + this.numberOfFaces), this.isInvalid = !0;
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
this.loadType = d.COMPRESSED_2D;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Uploads KTX content to a Babylon Texture.
|
|
35
|
+
* It is assumed that the texture has already been created & is currently bound
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
uploadLevels(s, e) {
|
|
39
|
+
this.loadType === d.COMPRESSED_2D && this._upload2DCompressedLevels(s, e);
|
|
40
|
+
}
|
|
41
|
+
_upload2DCompressedLevels(s, e) {
|
|
42
|
+
let i = d.HEADER_LEN + this.bytesOfKeyValueData, r = this.pixelWidth, c = this.pixelHeight;
|
|
43
|
+
const a = e ? this.numberOfMipmapLevels : 1;
|
|
44
|
+
for (let f = 0; f < a; f++) {
|
|
45
|
+
const _ = new Int32Array(this.data.buffer, this.data.byteOffset + i, 1)[0];
|
|
46
|
+
i += 4;
|
|
47
|
+
for (let R = 0; R < this.numberOfFaces; R++) {
|
|
48
|
+
const T = new Uint8Array(this.data.buffer, this.data.byteOffset + i, _);
|
|
49
|
+
s.getEngine()._uploadCompressedDataToTextureDirectly(s, s.format, r, c, T, R, f), i += _, i += 3 - (_ + 3) % 4;
|
|
50
|
+
}
|
|
51
|
+
r = Math.max(1, r * 0.5), c = Math.max(1, c * 0.5);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Checks if the given data starts with a KTX file identifier.
|
|
56
|
+
* @param data the data to check
|
|
57
|
+
* @returns true if the data is a KTX file or false otherwise
|
|
58
|
+
*/
|
|
59
|
+
static IsValid(s) {
|
|
60
|
+
if (s.byteLength >= 12) {
|
|
61
|
+
const e = new Uint8Array(s.buffer, s.byteOffset, 12);
|
|
62
|
+
if (e[0] === 171 && e[1] === 75 && e[2] === 84 && e[3] === 88 && e[4] === 32 && e[5] === 49 && e[6] === 49 && e[7] === 187 && e[8] === 13 && e[9] === 10 && e[10] === 26 && e[11] === 10)
|
|
63
|
+
return !0;
|
|
64
|
+
}
|
|
65
|
+
return !1;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
d.HEADER_LEN = 64;
|
|
69
|
+
d.COMPRESSED_2D = 0;
|
|
70
|
+
d.COMPRESSED_3D = 1;
|
|
71
|
+
d.TEX_2D = 2;
|
|
72
|
+
d.TEX_3D = 3;
|
|
73
|
+
var h;
|
|
74
|
+
(function(t) {
|
|
75
|
+
t[t.ETC1S = 0] = "ETC1S", t[t.UASTC4x4 = 1] = "UASTC4x4";
|
|
76
|
+
})(h || (h = {}));
|
|
77
|
+
var m;
|
|
78
|
+
(function(t) {
|
|
79
|
+
t[t.ASTC_4X4_RGBA = 0] = "ASTC_4X4_RGBA", t[t.ASTC_4x4_RGBA = 0] = "ASTC_4x4_RGBA", t[t.BC7_RGBA = 1] = "BC7_RGBA", t[t.BC3_RGBA = 2] = "BC3_RGBA", t[t.BC1_RGB = 3] = "BC1_RGB", t[t.PVRTC1_4_RGBA = 4] = "PVRTC1_4_RGBA", t[t.PVRTC1_4_RGB = 5] = "PVRTC1_4_RGB", t[t.ETC2_RGBA = 6] = "ETC2_RGBA", t[t.ETC1_RGB = 7] = "ETC1_RGB", t[t.RGBA32 = 8] = "RGBA32", t[t.R8 = 9] = "R8", t[t.RG8 = 10] = "RG8";
|
|
80
|
+
})(m || (m = {}));
|
|
81
|
+
var U;
|
|
82
|
+
(function(t) {
|
|
83
|
+
t[t.COMPRESSED_RGBA_BPTC_UNORM_EXT = 36492] = "COMPRESSED_RGBA_BPTC_UNORM_EXT", t[t.COMPRESSED_RGBA_ASTC_4X4_KHR = 37808] = "COMPRESSED_RGBA_ASTC_4X4_KHR", t[t.COMPRESSED_RGB_S3TC_DXT1_EXT = 33776] = "COMPRESSED_RGB_S3TC_DXT1_EXT", t[t.COMPRESSED_RGBA_S3TC_DXT5_EXT = 33779] = "COMPRESSED_RGBA_S3TC_DXT5_EXT", t[t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 35842] = "COMPRESSED_RGBA_PVRTC_4BPPV1_IMG", t[t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 35840] = "COMPRESSED_RGB_PVRTC_4BPPV1_IMG", t[t.COMPRESSED_RGBA8_ETC2_EAC = 37496] = "COMPRESSED_RGBA8_ETC2_EAC", t[t.COMPRESSED_RGB8_ETC2 = 37492] = "COMPRESSED_RGB8_ETC2", t[t.COMPRESSED_RGB_ETC1_WEBGL = 36196] = "COMPRESSED_RGB_ETC1_WEBGL", t[t.RGBA8Format = 32856] = "RGBA8Format", t[t.R8Format = 33321] = "R8Format", t[t.RG8Format = 33323] = "RG8Format";
|
|
84
|
+
})(U || (U = {}));
|
|
85
|
+
function A(t, s) {
|
|
86
|
+
const e = s?.jsDecoderModule || KTX2DECODER;
|
|
87
|
+
t && (t.wasmBaseUrl && (e.Transcoder.WasmBaseUrl = t.wasmBaseUrl), t.wasmUASTCToASTC && (e.LiteTranscoder_UASTC_ASTC.WasmModuleURL = t.wasmUASTCToASTC), t.wasmUASTCToBC7 && (e.LiteTranscoder_UASTC_BC7.WasmModuleURL = t.wasmUASTCToBC7), t.wasmUASTCToRGBA_UNORM && (e.LiteTranscoder_UASTC_RGBA_UNORM.WasmModuleURL = t.wasmUASTCToRGBA_UNORM), t.wasmUASTCToRGBA_SRGB && (e.LiteTranscoder_UASTC_RGBA_SRGB.WasmModuleURL = t.wasmUASTCToRGBA_SRGB), t.wasmUASTCToR8_UNORM && (e.LiteTranscoder_UASTC_R8_UNORM.WasmModuleURL = t.wasmUASTCToR8_UNORM), t.wasmUASTCToRG8_UNORM && (e.LiteTranscoder_UASTC_RG8_UNORM.WasmModuleURL = t.wasmUASTCToRG8_UNORM), t.jsMSCTranscoder && (e.MSCTranscoder.JSModuleURL = t.jsMSCTranscoder), t.wasmMSCTranscoder && (e.MSCTranscoder.WasmModuleURL = t.wasmMSCTranscoder), t.wasmZSTDDecoder && (e.ZSTDDecoder.WasmModuleURL = t.wasmZSTDDecoder)), s && (s.wasmUASTCToASTC && (e.LiteTranscoder_UASTC_ASTC.WasmBinary = s.wasmUASTCToASTC), s.wasmUASTCToBC7 && (e.LiteTranscoder_UASTC_BC7.WasmBinary = s.wasmUASTCToBC7), s.wasmUASTCToRGBA_UNORM && (e.LiteTranscoder_UASTC_RGBA_UNORM.WasmBinary = s.wasmUASTCToRGBA_UNORM), s.wasmUASTCToRGBA_SRGB && (e.LiteTranscoder_UASTC_RGBA_SRGB.WasmBinary = s.wasmUASTCToRGBA_SRGB), s.wasmUASTCToR8_UNORM && (e.LiteTranscoder_UASTC_R8_UNORM.WasmBinary = s.wasmUASTCToR8_UNORM), s.wasmUASTCToRG8_UNORM && (e.LiteTranscoder_UASTC_RG8_UNORM.WasmBinary = s.wasmUASTCToRG8_UNORM), s.jsMSCTranscoder && (e.MSCTranscoder.JSModule = s.jsMSCTranscoder), s.wasmMSCTranscoder && (e.MSCTranscoder.WasmBinary = s.wasmMSCTranscoder), s.wasmZSTDDecoder && (e.ZSTDDecoder.WasmBinary = s.wasmZSTDDecoder));
|
|
88
|
+
}
|
|
89
|
+
function G(t) {
|
|
90
|
+
typeof t > "u" && typeof KTX2DECODER < "u" && (t = KTX2DECODER);
|
|
91
|
+
let s;
|
|
92
|
+
onmessage = (e) => {
|
|
93
|
+
if (e.data)
|
|
94
|
+
switch (e.data.action) {
|
|
95
|
+
case "init": {
|
|
96
|
+
const i = e.data.urls;
|
|
97
|
+
i && (i.jsDecoderModule && typeof t > "u" && (importScripts(i.jsDecoderModule), t = KTX2DECODER), A(i)), e.data.wasmBinaries && A(void 0, { ...e.data.wasmBinaries, jsDecoderModule: t }), s = new t.KTX2Decoder(), postMessage({ action: "init" });
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
case "setDefaultDecoderOptions": {
|
|
101
|
+
t.KTX2Decoder.DefaultDecoderOptions = e.data.options;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
case "decode":
|
|
105
|
+
s.decode(e.data.data, e.data.caps, e.data.options).then((i) => {
|
|
106
|
+
const r = [];
|
|
107
|
+
for (let c = 0; c < i.mipmaps.length; ++c) {
|
|
108
|
+
const a = i.mipmaps[c];
|
|
109
|
+
a && a.data && r.push(a.data.buffer);
|
|
110
|
+
}
|
|
111
|
+
postMessage({ action: "decoded", success: !0, decodedData: i }, r);
|
|
112
|
+
}).catch((i) => {
|
|
113
|
+
postMessage({ action: "decoded", success: !1, msg: i });
|
|
114
|
+
});
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
async function M(t, s, e) {
|
|
120
|
+
return await new Promise((i, r) => {
|
|
121
|
+
const c = (f) => {
|
|
122
|
+
t.removeEventListener("error", c), t.removeEventListener("message", a), r(f);
|
|
123
|
+
}, a = (f) => {
|
|
124
|
+
f.data.action === "init" && (t.removeEventListener("error", c), t.removeEventListener("message", a), i(t));
|
|
125
|
+
};
|
|
126
|
+
t.addEventListener("error", c), t.addEventListener("message", a), t.postMessage({
|
|
127
|
+
action: "init",
|
|
128
|
+
urls: e,
|
|
129
|
+
wasmBinaries: s
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
class y {
|
|
134
|
+
constructor() {
|
|
135
|
+
this._isDirty = !0, this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC = !0, this._ktx2DecoderOptions = {};
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Gets the dirty flag
|
|
139
|
+
*/
|
|
140
|
+
get isDirty() {
|
|
141
|
+
return this._isDirty;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* force a (uncompressed) RGBA transcoded format if transcoding a UASTC source format and ASTC + BC7 are not available as a compressed transcoded format
|
|
145
|
+
*/
|
|
146
|
+
get useRGBAIfASTCBC7NotAvailableWhenUASTC() {
|
|
147
|
+
return this._useRGBAIfASTCBC7NotAvailableWhenUASTC;
|
|
148
|
+
}
|
|
149
|
+
set useRGBAIfASTCBC7NotAvailableWhenUASTC(s) {
|
|
150
|
+
this._useRGBAIfASTCBC7NotAvailableWhenUASTC !== s && (this._useRGBAIfASTCBC7NotAvailableWhenUASTC = s, this._isDirty = !0);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* force a (uncompressed) RGBA transcoded format if transcoding a UASTC source format and only BC1 or BC3 are available as a compressed transcoded format.
|
|
154
|
+
* This property is true by default to favor speed over memory, because currently transcoding from UASTC to BC1/3 is slow because the transcoder transcodes
|
|
155
|
+
* to uncompressed and then recompresses the texture
|
|
156
|
+
*/
|
|
157
|
+
get useRGBAIfOnlyBC1BC3AvailableWhenUASTC() {
|
|
158
|
+
return this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC;
|
|
159
|
+
}
|
|
160
|
+
set useRGBAIfOnlyBC1BC3AvailableWhenUASTC(s) {
|
|
161
|
+
this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC !== s && (this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC = s, this._isDirty = !0);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* force to always use (uncompressed) RGBA for transcoded format
|
|
165
|
+
*/
|
|
166
|
+
get forceRGBA() {
|
|
167
|
+
return this._forceRGBA;
|
|
168
|
+
}
|
|
169
|
+
set forceRGBA(s) {
|
|
170
|
+
this._forceRGBA !== s && (this._forceRGBA = s, this._isDirty = !0);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* force to always use (uncompressed) R8 for transcoded format
|
|
174
|
+
*/
|
|
175
|
+
get forceR8() {
|
|
176
|
+
return this._forceR8;
|
|
177
|
+
}
|
|
178
|
+
set forceR8(s) {
|
|
179
|
+
this._forceR8 !== s && (this._forceR8 = s, this._isDirty = !0);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* force to always use (uncompressed) RG8 for transcoded format
|
|
183
|
+
*/
|
|
184
|
+
get forceRG8() {
|
|
185
|
+
return this._forceRG8;
|
|
186
|
+
}
|
|
187
|
+
set forceRG8(s) {
|
|
188
|
+
this._forceRG8 !== s && (this._forceRG8 = s, this._isDirty = !0);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* list of transcoders to bypass when looking for a suitable transcoder. The available transcoders are:
|
|
192
|
+
* UniversalTranscoder_UASTC_ASTC
|
|
193
|
+
* UniversalTranscoder_UASTC_BC7
|
|
194
|
+
* UniversalTranscoder_UASTC_RGBA_UNORM
|
|
195
|
+
* UniversalTranscoder_UASTC_RGBA_SRGB
|
|
196
|
+
* UniversalTranscoder_UASTC_R8_UNORM
|
|
197
|
+
* UniversalTranscoder_UASTC_RG8_UNORM
|
|
198
|
+
* MSCTranscoder
|
|
199
|
+
*/
|
|
200
|
+
get bypassTranscoders() {
|
|
201
|
+
return this._bypassTranscoders;
|
|
202
|
+
}
|
|
203
|
+
set bypassTranscoders(s) {
|
|
204
|
+
this._bypassTranscoders !== s && (this._bypassTranscoders = s, this._isDirty = !0);
|
|
205
|
+
}
|
|
206
|
+
/** @internal */
|
|
207
|
+
_getKTX2DecoderOptions() {
|
|
208
|
+
if (!this._isDirty)
|
|
209
|
+
return this._ktx2DecoderOptions;
|
|
210
|
+
this._isDirty = !1;
|
|
211
|
+
const s = {};
|
|
212
|
+
return this._useRGBAIfASTCBC7NotAvailableWhenUASTC !== void 0 && (s.useRGBAIfASTCBC7NotAvailableWhenUASTC = this._useRGBAIfASTCBC7NotAvailableWhenUASTC), this._forceRGBA !== void 0 && (s.forceRGBA = this._forceRGBA), this._forceR8 !== void 0 && (s.forceR8 = this._forceR8), this._forceRG8 !== void 0 && (s.forceRG8 = this._forceRG8), this._bypassTranscoders !== void 0 && (s.bypassTranscoders = this._bypassTranscoders), this.useRGBAIfOnlyBC1BC3AvailableWhenUASTC && (s.transcodeFormatDecisionTree = {
|
|
213
|
+
UASTC: {
|
|
214
|
+
transcodeFormat: [m.BC1_RGB, m.BC3_RGBA],
|
|
215
|
+
yes: {
|
|
216
|
+
transcodeFormat: m.RGBA32,
|
|
217
|
+
engineFormat: 32856,
|
|
218
|
+
roundToMultiple4: !1
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}), this._ktx2DecoderOptions = s, s;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
class o {
|
|
225
|
+
static GetDefaultNumWorkers() {
|
|
226
|
+
return typeof navigator != "object" || !navigator.hardwareConcurrency ? 1 : Math.min(Math.floor(navigator.hardwareConcurrency * 0.5), 4);
|
|
227
|
+
}
|
|
228
|
+
static _Initialize(s) {
|
|
229
|
+
if (o._WorkerPoolPromise || o._DecoderModulePromise)
|
|
230
|
+
return;
|
|
231
|
+
const e = {
|
|
232
|
+
wasmBaseUrl: n.ScriptBaseUrl,
|
|
233
|
+
jsDecoderModule: n.GetBabylonScriptURL(this.URLConfig.jsDecoderModule, !0),
|
|
234
|
+
wasmUASTCToASTC: n.GetBabylonScriptURL(this.URLConfig.wasmUASTCToASTC, !0),
|
|
235
|
+
wasmUASTCToBC7: n.GetBabylonScriptURL(this.URLConfig.wasmUASTCToBC7, !0),
|
|
236
|
+
wasmUASTCToRGBA_UNORM: n.GetBabylonScriptURL(this.URLConfig.wasmUASTCToRGBA_UNORM, !0),
|
|
237
|
+
wasmUASTCToRGBA_SRGB: n.GetBabylonScriptURL(this.URLConfig.wasmUASTCToRGBA_SRGB, !0),
|
|
238
|
+
wasmUASTCToR8_UNORM: n.GetBabylonScriptURL(this.URLConfig.wasmUASTCToR8_UNORM, !0),
|
|
239
|
+
wasmUASTCToRG8_UNORM: n.GetBabylonScriptURL(this.URLConfig.wasmUASTCToRG8_UNORM, !0),
|
|
240
|
+
jsMSCTranscoder: n.GetBabylonScriptURL(this.URLConfig.jsMSCTranscoder, !0),
|
|
241
|
+
wasmMSCTranscoder: n.GetBabylonScriptURL(this.URLConfig.wasmMSCTranscoder, !0),
|
|
242
|
+
wasmZSTDDecoder: n.GetBabylonScriptURL(this.URLConfig.wasmZSTDDecoder, !0)
|
|
243
|
+
};
|
|
244
|
+
s && typeof Worker == "function" && typeof URL < "u" ? o._WorkerPoolPromise = new Promise((i) => {
|
|
245
|
+
const r = `${A}(${G})()`, c = URL.createObjectURL(new Blob([r], { type: "application/javascript" }));
|
|
246
|
+
i(new u(s, async () => await M(new Worker(c), void 0, e)));
|
|
247
|
+
}) : typeof o._KTX2DecoderModule > "u" ? o._DecoderModulePromise = n.LoadBabylonScriptAsync(e.jsDecoderModule).then(() => (o._KTX2DecoderModule = KTX2DECODER, o._KTX2DecoderModule.MSCTranscoder.UseFromWorkerThread = !1, o._KTX2DecoderModule.WASMMemoryManager.LoadBinariesFromCurrentThread = !0, A(e, o._KTX2DecoderModule), new o._KTX2DecoderModule.KTX2Decoder())) : (o._KTX2DecoderModule.MSCTranscoder.UseFromWorkerThread = !1, o._KTX2DecoderModule.WASMMemoryManager.LoadBinariesFromCurrentThread = !0, o._DecoderModulePromise = Promise.resolve(new o._KTX2DecoderModule.KTX2Decoder()));
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Constructor
|
|
251
|
+
* @param engine The engine to use
|
|
252
|
+
* @param numWorkersOrOptions The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
|
|
253
|
+
*/
|
|
254
|
+
constructor(s, e = o.DefaultNumWorkers) {
|
|
255
|
+
this._engine = s;
|
|
256
|
+
const i = typeof e == "object" && e.workerPool || o.WorkerPool;
|
|
257
|
+
if (i)
|
|
258
|
+
o._WorkerPoolPromise = Promise.resolve(i);
|
|
259
|
+
else {
|
|
260
|
+
typeof e == "object" ? o._KTX2DecoderModule = e?.binariesAndModulesContainer?.jsDecoderModule : typeof KTX2DECODER < "u" && (o._KTX2DecoderModule = KTX2DECODER);
|
|
261
|
+
const r = typeof e == "number" ? e : e.numWorkers ?? o.DefaultNumWorkers;
|
|
262
|
+
o._Initialize(r);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* @internal
|
|
267
|
+
*/
|
|
268
|
+
async _uploadAsync(s, e, i) {
|
|
269
|
+
const r = this._engine.getCaps(), c = {
|
|
270
|
+
astc: !!r.astc,
|
|
271
|
+
bptc: !!r.bptc,
|
|
272
|
+
s3tc: !!r.s3tc,
|
|
273
|
+
pvrtc: !!r.pvrtc,
|
|
274
|
+
etc2: !!r.etc2,
|
|
275
|
+
etc1: !!r.etc1
|
|
276
|
+
};
|
|
277
|
+
if (o._WorkerPoolPromise) {
|
|
278
|
+
const a = await o._WorkerPoolPromise;
|
|
279
|
+
return await new Promise((f, _) => {
|
|
280
|
+
a.push((R, T) => {
|
|
281
|
+
const C = (S) => {
|
|
282
|
+
R.removeEventListener("error", C), R.removeEventListener("message", p), _(S), T();
|
|
283
|
+
}, p = (S) => {
|
|
284
|
+
if (S.data.action === "decoded") {
|
|
285
|
+
if (R.removeEventListener("error", C), R.removeEventListener("message", p), !S.data.success)
|
|
286
|
+
_({ message: S.data.msg });
|
|
287
|
+
else
|
|
288
|
+
try {
|
|
289
|
+
this._createTexture(S.data.decodedData, e, i), f();
|
|
290
|
+
} catch (D) {
|
|
291
|
+
_({ message: D });
|
|
292
|
+
}
|
|
293
|
+
T();
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
R.addEventListener("error", C), R.addEventListener("message", p), R.postMessage({ action: "setDefaultDecoderOptions", options: o.DefaultDecoderOptions._getKTX2DecoderOptions() });
|
|
297
|
+
const B = new Uint8Array(s.byteLength);
|
|
298
|
+
B.set(new Uint8Array(s.buffer, s.byteOffset, s.byteLength)), R.postMessage({ action: "decode", data: B, caps: c, options: i }, [B.buffer]);
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
} else if (o._DecoderModulePromise) {
|
|
302
|
+
const a = await o._DecoderModulePromise;
|
|
303
|
+
return o.DefaultDecoderOptions.isDirty && (o._KTX2DecoderModule.KTX2Decoder.DefaultDecoderOptions = o.DefaultDecoderOptions._getKTX2DecoderOptions()), await new Promise((f, _) => {
|
|
304
|
+
a.decode(s, r).then((R) => {
|
|
305
|
+
this._createTexture(R, e), f();
|
|
306
|
+
}).catch((R) => {
|
|
307
|
+
_({ message: R });
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
throw new Error("KTX2 decoder module is not available");
|
|
312
|
+
}
|
|
313
|
+
_createTexture(s, e, i) {
|
|
314
|
+
this._engine._bindTextureDirectly(3553, e), i && (i.transcodedFormat = s.transcodedFormat, i.isInGammaSpace = s.isInGammaSpace, i.hasAlpha = s.hasAlpha, i.transcoderName = s.transcoderName);
|
|
315
|
+
let c = !0;
|
|
316
|
+
switch (s.transcodedFormat) {
|
|
317
|
+
case 32856:
|
|
318
|
+
e.type = 0, e.format = 5;
|
|
319
|
+
break;
|
|
320
|
+
case 33321:
|
|
321
|
+
e.type = 0, e.format = 6;
|
|
322
|
+
break;
|
|
323
|
+
case 33323:
|
|
324
|
+
e.type = 0, e.format = 7;
|
|
325
|
+
break;
|
|
326
|
+
default:
|
|
327
|
+
e.format = s.transcodedFormat, c = !1;
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
if (e._gammaSpace = s.isInGammaSpace, e.generateMipMaps = s.mipmaps.length > 1, e.width = s.mipmaps[0].width, e.height = s.mipmaps[0].height, s.errors)
|
|
331
|
+
throw new Error("KTX2 container - could not transcode the data. " + s.errors);
|
|
332
|
+
for (let a = 0; a < s.mipmaps.length; ++a) {
|
|
333
|
+
const f = s.mipmaps[a];
|
|
334
|
+
if (!f || !f.data)
|
|
335
|
+
throw new Error("KTX2 container - could not transcode one of the image");
|
|
336
|
+
c ? (e.width = f.width, e.height = f.height, this._engine._uploadDataToTextureDirectly(e, f.data, 0, a, void 0, !0)) : this._engine._uploadCompressedDataToTextureDirectly(e, s.transcodedFormat, f.width, f.height, f.data, 0, a);
|
|
337
|
+
}
|
|
338
|
+
e._extension = ".ktx2", e.isReady = !0, this._engine._bindTextureDirectly(3553, null);
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Checks if the given data starts with a KTX2 file identifier.
|
|
342
|
+
* @param data the data to check
|
|
343
|
+
* @returns true if the data is a KTX2 file or false otherwise
|
|
344
|
+
*/
|
|
345
|
+
static IsValid(s) {
|
|
346
|
+
if (s.byteLength >= 12) {
|
|
347
|
+
const e = new Uint8Array(s.buffer, s.byteOffset, 12);
|
|
348
|
+
if (e[0] === 171 && e[1] === 75 && e[2] === 84 && e[3] === 88 && e[4] === 32 && e[5] === 50 && e[6] === 48 && e[7] === 187 && e[8] === 13 && e[9] === 10 && e[10] === 26 && e[11] === 10)
|
|
349
|
+
return !0;
|
|
350
|
+
}
|
|
351
|
+
return !1;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
o.URLConfig = {
|
|
355
|
+
jsDecoderModule: "https://cdn.babylonjs.com/babylon.ktx2Decoder.js",
|
|
356
|
+
wasmUASTCToASTC: null,
|
|
357
|
+
wasmUASTCToBC7: null,
|
|
358
|
+
wasmUASTCToRGBA_UNORM: null,
|
|
359
|
+
wasmUASTCToRGBA_SRGB: null,
|
|
360
|
+
wasmUASTCToR8_UNORM: null,
|
|
361
|
+
wasmUASTCToRG8_UNORM: null,
|
|
362
|
+
jsMSCTranscoder: null,
|
|
363
|
+
wasmMSCTranscoder: null,
|
|
364
|
+
wasmZSTDDecoder: null
|
|
365
|
+
};
|
|
366
|
+
o.DefaultNumWorkers = o.GetDefaultNumWorkers();
|
|
367
|
+
o.DefaultDecoderOptions = new y();
|
|
368
|
+
function w(t) {
|
|
369
|
+
switch (t) {
|
|
370
|
+
case 35916:
|
|
371
|
+
return 33776;
|
|
372
|
+
case 35918:
|
|
373
|
+
return 33778;
|
|
374
|
+
case 35919:
|
|
375
|
+
return 33779;
|
|
376
|
+
case 37493:
|
|
377
|
+
return 37492;
|
|
378
|
+
case 37497:
|
|
379
|
+
return 37496;
|
|
380
|
+
case 37495:
|
|
381
|
+
return 37494;
|
|
382
|
+
case 37840:
|
|
383
|
+
return 37808;
|
|
384
|
+
case 37841:
|
|
385
|
+
return 37809;
|
|
386
|
+
case 37842:
|
|
387
|
+
return 37810;
|
|
388
|
+
case 37843:
|
|
389
|
+
return 37811;
|
|
390
|
+
case 37844:
|
|
391
|
+
return 37812;
|
|
392
|
+
case 37845:
|
|
393
|
+
return 37813;
|
|
394
|
+
case 37846:
|
|
395
|
+
return 37814;
|
|
396
|
+
case 37847:
|
|
397
|
+
return 37815;
|
|
398
|
+
case 37848:
|
|
399
|
+
return 37816;
|
|
400
|
+
case 37849:
|
|
401
|
+
return 37817;
|
|
402
|
+
case 37850:
|
|
403
|
+
return 37818;
|
|
404
|
+
case 37851:
|
|
405
|
+
return 37819;
|
|
406
|
+
case 37852:
|
|
407
|
+
return 37820;
|
|
408
|
+
case 37853:
|
|
409
|
+
return 37821;
|
|
410
|
+
case 36493:
|
|
411
|
+
return 36492;
|
|
412
|
+
}
|
|
413
|
+
return null;
|
|
414
|
+
}
|
|
415
|
+
class O {
|
|
416
|
+
constructor() {
|
|
417
|
+
this.supportCascades = !1;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Uploads the cube texture data to the WebGL texture. It has already been bound.
|
|
421
|
+
* @param data contains the texture data
|
|
422
|
+
* @param texture defines the BabylonJS internal texture
|
|
423
|
+
* @param createPolynomials will be true if polynomials have been requested
|
|
424
|
+
* @param onLoad defines the callback to trigger once the texture is ready
|
|
425
|
+
*/
|
|
426
|
+
loadCubeData(s, e, i, r) {
|
|
427
|
+
if (Array.isArray(s))
|
|
428
|
+
return;
|
|
429
|
+
e._invertVScale = !e.invertY;
|
|
430
|
+
const c = e.getEngine(), a = new d(s, 6), f = a.numberOfMipmapLevels > 1 && e.generateMipMaps;
|
|
431
|
+
c._unpackFlipY(!0), a.uploadLevels(e, e.generateMipMaps), e.width = a.pixelWidth, e.height = a.pixelHeight, c._setCubeMapTextureParams(e, f, a.numberOfMipmapLevels - 1), e.isReady = !0, e.onLoadedObservable.notifyObservers(e), e.onLoadedObservable.clear(), r && r();
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
|
|
435
|
+
* @param data contains the texture data
|
|
436
|
+
* @param texture defines the BabylonJS internal texture
|
|
437
|
+
* @param callback defines the method to call once ready to upload
|
|
438
|
+
* @param options
|
|
439
|
+
*/
|
|
440
|
+
loadData(s, e, i, r) {
|
|
441
|
+
if (d.IsValid(s)) {
|
|
442
|
+
e._invertVScale = !e.invertY;
|
|
443
|
+
const c = new d(s, 1), a = w(c.glInternalFormat);
|
|
444
|
+
a ? (e.format = a, e._useSRGBBuffer = e.getEngine()._getUseSRGBBuffer(!0, e.generateMipMaps), e._gammaSpace = !0) : e.format = c.glInternalFormat, i(c.pixelWidth, c.pixelHeight, e.generateMipMaps, !0, () => {
|
|
445
|
+
c.uploadLevels(e, e.generateMipMaps);
|
|
446
|
+
}, c.isInvalid);
|
|
447
|
+
} else o.IsValid(s) ? new o(e.getEngine())._uploadAsync(s, e, r).then(() => {
|
|
448
|
+
i(e.width, e.height, e.generateMipMaps, !0, () => {
|
|
449
|
+
}, !1);
|
|
450
|
+
}, (a) => {
|
|
451
|
+
l.Warn(`Failed to load KTX2 texture data: ${a.message}`), i(0, 0, !1, !1, () => {
|
|
452
|
+
}, !0);
|
|
453
|
+
}) : (l.Error("texture missing KTX identifier"), i(0, 0, !1, !1, () => {
|
|
454
|
+
}, !0));
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
export {
|
|
458
|
+
O as _KTXTextureLoader
|
|
459
|
+
};
|