@cueframe/kernel 0.0.1 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/dist/_members/account-model/testing/conversationStoreContract.d.ts +1 -1
- package/dist/_members/authoring/providers/resourceApi.d.ts +1 -1
- package/dist/_members/authoring/transpileComponent.d.ts +1 -1
- package/dist/_members/cloud-import/CloudImportService.d.ts +35 -0
- package/dist/_members/cloud-import/ImportProvider.d.ts +73 -0
- package/dist/_members/cloud-import/MediaItemPreprocessor.d.ts +27 -0
- package/dist/_members/cloud-import/cloudConfig.d.ts +23 -0
- package/dist/_members/cloud-import/index.d.ts +9 -0
- package/dist/_members/cloud-import/multipartUpload.d.ts +12 -0
- package/dist/_members/composition/ops/compositionOps.d.ts +2 -1
- package/dist/_members/composition/ops/types.d.ts +1 -1
- package/dist/_members/composition/projection/behind-readiness.d.ts +127 -0
- package/dist/_members/composition/projection/index.d.ts +2 -0
- package/dist/_members/composition/projection/reframe-readiness.d.ts +156 -0
- package/dist/_members/composition/timeline/placement.d.ts +1 -1
- package/dist/_members/composition/validators/composition.d.ts +43 -26
- package/dist/_members/composition/validators/render.d.ts +32 -0
- package/dist/_members/composition-ops/index.d.ts +1 -1
- package/dist/_members/composition-ops/opRecorder.d.ts +1 -1
- package/dist/_members/convex-api/api.d.ts +5 -0
- package/dist/_members/convex-api/dataModel.d.ts +6 -0
- package/dist/_members/core/render/compositionRender.d.ts +17 -1
- package/dist/_members/core/render/exportSettings.d.ts +1 -1
- package/dist/_members/core/render/types.d.ts +31 -0
- package/dist/_members/mcp/curation.d.ts +1 -1
- package/dist/_members/plane/conformance.d.ts +1 -1
- package/dist/_members/render-harness/localRender.d.ts +1 -1
- package/dist/animate.js +828 -79187
- package/dist/authoring/build-tools.js +8 -11
- package/dist/authoring/context.js +5 -5
- package/dist/authoring/models.js +1 -2
- package/dist/authoring/prompts.js +1 -1
- package/dist/authoring/tools.js +7 -7
- package/dist/authoring/transpileComponent.js +3 -2220
- package/dist/authoring.js +30 -30
- package/dist/brand-derivation.js +1 -1
- package/dist/chunk-6IU2UQI5.js +107 -0
- package/dist/{chunk-5I7VDCAC.js → chunk-7FO3ZJ43.js} +4 -1
- package/dist/{chunk-N67PDTKQ.js → chunk-ABL557OT.js} +1 -1
- package/dist/{chunk-MC5DLSEV.js → chunk-AP6ZIVAV.js} +15 -15
- package/dist/{chunk-QLAQHR3L.js → chunk-AQBREB5O.js} +1 -1
- package/dist/{chunk-DSNG6WLU.js → chunk-AYVJXDLB.js} +1 -4
- package/dist/{chunk-6CMVBTTP.js → chunk-DK2ODBNT.js} +19 -9
- package/dist/chunk-DSMLHYJ4.js +82 -0
- package/dist/{chunk-BRKJKB33.js → chunk-FYZVH3MC.js} +1 -1
- package/dist/{chunk-MVEE6HEC.js → chunk-GA23TRNR.js} +5 -7
- package/dist/chunk-HCCBDJLW.js +68 -0
- package/dist/{chunk-JRQVPFLF.js → chunk-HY3RIEZW.js} +1 -1
- package/dist/{chunk-OIRUO5P7.js → chunk-JJ6XD7NG.js} +152 -2
- package/dist/{_members/primitives/chunk-IDAL6G3Y.js → chunk-JQMPHKLU.js} +19 -27
- package/dist/{chunk-G3PBH53P.js → chunk-MBCXCJOE.js} +1 -1
- package/dist/{chunk-UEI3NLNK.js → chunk-MHOQTPOB.js} +1 -4
- package/dist/{chunk-37NJ27UU.js → chunk-OCFDUCF4.js} +3 -0
- package/dist/{chunk-WZTTZHNR.js → chunk-OLFOPQCA.js} +12 -9
- package/dist/{chunk-P43IE4WB.js → chunk-P727GZVO.js} +2 -4
- package/dist/{chunk-52AHXNKM.js → chunk-PDYO3DOJ.js} +5 -5
- package/dist/{chunk-S3P5BFFL.js → chunk-PMY24FUD.js} +2 -4
- package/dist/{chunk-ATAF24QG.js → chunk-PODIYN2K.js} +10 -3
- package/dist/chunk-RF7U3SCL.js +606 -0
- package/dist/{chunk-JD77Y2WM.js → chunk-SW336CJP.js} +1 -4
- package/dist/{chunk-TULRCY6U.js → chunk-TOJEXFXL.js} +1 -1
- package/dist/{chunk-ELLSET2N.js → chunk-UHGSZZDI.js} +3 -6
- package/dist/{chunk-M3I5LMAB.js → chunk-UY4SWJVE.js} +1 -1
- package/dist/{chunk-6QJ3V3VS.js → chunk-YX2GSJK7.js} +1 -1
- package/dist/chunk-ZT7MHRQU.js +104 -0
- package/dist/{chunk-NV4I6GJV.js → chunk-ZWMV6DD2.js} +27 -4
- package/dist/cloud-import/multipart.d.ts +1 -0
- package/dist/cloud-import/multipart.js +8 -0
- package/dist/cloud-import.d.ts +1 -0
- package/dist/cloud-import.js +234 -0
- package/dist/compose/renderer.js +19 -22
- package/dist/compose.js +19 -22
- package/dist/composition/graphics-plan.js +3 -3
- package/dist/composition/ops.js +4 -4
- package/dist/composition/primitive-catalog.js +1 -1
- package/dist/composition/projection.js +21 -5
- package/dist/composition/validators.js +6 -4
- package/dist/composition-ops.js +15 -13
- package/dist/composition.js +26 -8
- package/dist/{context-CEAKQ5T7.js → context-YWUZDG5X.js} +5 -5
- package/dist/convex-api/dataModel.d.ts +1 -0
- package/dist/convex-api/dataModel.js +0 -0
- package/dist/convex-api.d.ts +1 -0
- package/dist/convex-api.js +8 -0
- package/dist/core/render.js +3 -3
- package/dist/core/select.js +2 -2
- package/dist/core.js +3 -3
- package/dist/errors.js +1 -1
- package/dist/mcp/adapter.js +2 -5
- package/dist/mcp/server.js +1 -2
- package/dist/mcp.js +2 -95
- package/dist/media-model/media-kind.js +9 -98
- package/dist/media-model/testing.js +1071 -718
- package/dist/nle-export/server.js +328 -130
- package/dist/nle-export/xml.js +5 -22799
- package/dist/nle-export.js +20 -22
- package/dist/primitives/backgrounds.js +2 -3
- package/dist/primitives/captions.js +4 -243
- package/dist/primitives/effects.js +2 -3
- package/dist/primitives/hero-text.js +2 -3
- package/dist/primitives/layouts.js +2 -3
- package/dist/primitives/lib/index.js +8 -10
- package/dist/primitives/lib/preview.js +1 -2
- package/dist/primitives/lib/schema.js +1 -2
- package/dist/primitives/lib/text/fitText.js +1 -2
- package/dist/primitives/lib.js +8 -10
- package/dist/primitives/scenes.js +1 -2
- package/dist/primitives/text.js +2 -3
- package/dist/primitives/ui-blocks.js +4 -5
- package/dist/primitives.js +19 -21
- package/package.json +125 -16
- package/dist/TextureLoader-UQOFUSAP.js +0 -422
- package/dist/VideoTexture-AQWSPIJG.js +0 -62
- package/dist/_members/account-model/index.js +0 -4
- package/dist/_members/account-model/testing/conversationStoreContract.js +0 -168
- package/dist/_members/account-model/testing/index.js +0 -7
- package/dist/_members/account-model/testing/restorePointStoreContract.js +0 -69
- package/dist/_members/account-model/types/index.js +0 -1
- package/dist/_members/account-model/validators/contextFile.js +0 -18
- package/dist/_members/account-model/validators/conversation.js +0 -95
- package/dist/_members/account-model/validators/dashboardInsight.js +0 -16
- package/dist/_members/account-model/validators/index.js +0 -7
- package/dist/_members/account-model/validators/sessionToken.js +0 -49
- package/dist/_members/account-model/validators/uploadToken.js +0 -16
- package/dist/_members/account-model/validators/userSettings.js +0 -12
- package/dist/_members/account-model/validators/workingComposition.js +0 -20
- package/dist/_members/brand-derivation/constants.js +0 -20
- package/dist/_members/brand-derivation/contrastSafe.js +0 -114
- package/dist/_members/brand-derivation/index.js +0 -1
- package/dist/_members/composition/audio/audioMix.js +0 -61
- package/dist/_members/composition/audio/index.js +0 -5
- package/dist/_members/composition/audio/mixStaging.js +0 -195
- package/dist/_members/composition/audio/musicPack.generated.js +0 -136
- package/dist/_members/composition/audio/musicPack.js +0 -36
- package/dist/_members/composition/audio/pack.generated.js +0 -603
- package/dist/_members/composition/audio/pack.js +0 -48
- package/dist/_members/composition/audio/palette.js +0 -134
- package/dist/_members/composition/autozoom/index.js +0 -83
- package/dist/_members/composition/brand-kit.js +0 -45
- package/dist/_members/composition/brief/contract.js +0 -209
- package/dist/_members/composition/color-grade.js +0 -80
- package/dist/_members/composition/depth.js +0 -8
- package/dist/_members/composition/fixtures/index.js +0 -143
- package/dist/_members/composition/fixtures/vaayaErrored.d.ts +0 -25
- package/dist/_members/composition/fixtures/vaayaErrored.js +0 -203
- package/dist/_members/composition/fonts.js +0 -162
- package/dist/_members/composition/graphics-plan/compile.js +0 -221
- package/dist/_members/composition/graphics-plan/index.js +0 -10
- package/dist/_members/composition/graphics-plan/instantiateMotif.js +0 -44
- package/dist/_members/composition/graphics-plan/motion.js +0 -66
- package/dist/_members/composition/graphics-plan/schemas.js +0 -261
- package/dist/_members/composition/graphics-plan/solve.js +0 -145
- package/dist/_members/composition/index.js +0 -5
- package/dist/_members/composition/invariants/clipPlacement.js +0 -69
- package/dist/_members/composition/invariants/composition.js +0 -28
- package/dist/_members/composition/invariants/errors.js +0 -10
- package/dist/_members/composition/invariants/etag.js +0 -38
- package/dist/_members/composition/invariants/ids.js +0 -33
- package/dist/_members/composition/invariants/index.js +0 -9
- package/dist/_members/composition/invariants/keyframes.js +0 -45
- package/dist/_members/composition/invariants/markers.js +0 -29
- package/dist/_members/composition/invariants/time.js +0 -20
- package/dist/_members/composition/invariants/tracks.js +0 -304
- package/dist/_members/composition/ops/compositionOps.js +0 -1056
- package/dist/_members/composition/ops/headlessStore.js +0 -94
- package/dist/_members/composition/ops/index.js +0 -4
- package/dist/_members/composition/ops/selectors.js +0 -118
- package/dist/_members/composition/ops/timeline-word.js +0 -1
- package/dist/_members/composition/ops/transcript.js +0 -77
- package/dist/_members/composition/ops/types.js +0 -16
- package/dist/_members/composition/primitive-catalog/catalogQuery.js +0 -150
- package/dist/_members/composition/primitive-catalog/disabled.js +0 -32
- package/dist/_members/composition/primitive-catalog/generated/meta.js +0 -15161
- package/dist/_members/composition/primitive-catalog/index.js +0 -46
- package/dist/_members/composition/primitive-catalog/paramValidation.js +0 -231
- package/dist/_members/composition/primitive-catalog/projection.js +0 -164
- package/dist/_members/composition/primitive-catalog/types.js +0 -14
- package/dist/_members/composition/projection/behind-placement.js +0 -62
- package/dist/_members/composition/projection/brandKit.js +0 -482
- package/dist/_members/composition/projection/cardTokens.js +0 -209
- package/dist/_members/composition/projection/composition-floor.js +0 -582
- package/dist/_members/composition/projection/cropProjection.js +0 -257
- package/dist/_members/composition/projection/index.js +0 -7
- package/dist/_members/composition/projection/occlusion-budget.js +0 -104
- package/dist/_members/composition/projection/safe-zones.js +0 -99
- package/dist/_members/composition/reframe/aspectLoss.js +0 -115
- package/dist/_members/composition/reframe/coverage.js +0 -62
- package/dist/_members/composition/reframe/derive.js +0 -73
- package/dist/_members/composition/reframe/index.js +0 -109
- package/dist/_members/composition/reframe/kenBurns.js +0 -64
- package/dist/_members/composition/reframe/shotScale.js +0 -176
- package/dist/_members/composition/reframe/trajectory.js +0 -124
- package/dist/_members/composition/timeline/compound.js +0 -134
- package/dist/_members/composition/timeline/index.js +0 -9
- package/dist/_members/composition/timeline/intent.js +0 -228
- package/dist/_members/composition/timeline/keyframes.js +0 -121
- package/dist/_members/composition/timeline/link.js +0 -59
- package/dist/_members/composition/timeline/occupancy.js +0 -36
- package/dist/_members/composition/timeline/placement.js +0 -74
- package/dist/_members/composition/timeline/plan.js +0 -31
- package/dist/_members/composition/timeline/resolve.js +0 -170
- package/dist/_members/composition/timeline/trims.js +0 -278
- package/dist/_members/composition/types/index.js +0 -1
- package/dist/_members/composition/validators/brandKit.js +0 -295
- package/dist/_members/composition/validators/composePlan.js +0 -113
- package/dist/_members/composition/validators/composition.js +0 -703
- package/dist/_members/composition/validators/font.js +0 -34
- package/dist/_members/composition/validators/graphicKinds.js +0 -30
- package/dist/_members/composition/validators/index.js +0 -9
- package/dist/_members/composition/validators/project.js +0 -29
- package/dist/_members/composition/validators/registry.js +0 -41
- package/dist/_members/composition/validators/render.js +0 -139
- package/dist/_members/composition/validators/session.js +0 -37
- package/dist/_members/composition/validators/webhook.js +0 -72
- package/dist/_members/composition-ops/alphaLayers.js +0 -141
- package/dist/_members/composition-ops/index.js +0 -637
- package/dist/_members/composition-ops/materializeGrid.js +0 -99
- package/dist/_members/composition-ops/opRecorder.js +0 -196
- package/dist/_members/composition-ops/recordingStore.js +0 -14
- package/dist/_members/composition-ops/replaceRegion.js +0 -102
- package/dist/_members/composition-ops/testFixtures.js +0 -19
- package/dist/_members/core/index.js +0 -5
- package/dist/_members/core/render/bookends.js +0 -53
- package/dist/_members/core/render/captions.js +0 -127
- package/dist/_members/core/render/compositionRender.js +0 -1249
- package/dist/_members/core/render/deriveTrajectory.js +0 -889
- package/dist/_members/core/render/emphasis.js +0 -16
- package/dist/_members/core/render/eval/cropBox.js +0 -139
- package/dist/_members/core/render/eval/inclusion.js +0 -96
- package/dist/_members/core/render/eval/index.js +0 -146
- package/dist/_members/core/render/eval/metrics.js +0 -94
- package/dist/_members/core/render/exportSettings.js +0 -65
- package/dist/_members/core/render/index.js +0 -20
- package/dist/_members/core/render/mapFaceToPerson.js +0 -73
- package/dist/_members/core/render/types.js +0 -8
- package/dist/_members/core/render/vcam/cameraPath.js +0 -248
- package/dist/_members/core/render/vcam/constants.js +0 -115
- package/dist/_members/core/render/vcam/errorCodes.js +0 -39
- package/dist/_members/core/render/vcam/framing.js +0 -136
- package/dist/_members/core/render/vcam/requiredRegion.js +0 -137
- package/dist/_members/core/render/vcam/shots.js +0 -53
- package/dist/_members/core/render/vcam/subjectSet.js +0 -388
- package/dist/_members/core/select/errorCodes.js +0 -38
- package/dist/_members/core/select/index.js +0 -26
- package/dist/_members/core/select/model.js +0 -18
- package/dist/_members/core/select/select.js +0 -244
- package/dist/_members/core/select/stabilize.js +0 -242
- package/dist/_members/core/types.js +0 -7
- package/dist/_members/errors/index.js +0 -1
- package/dist/_members/errors/registry.js +0 -560
- package/dist/_members/foundation/codes/index.js +0 -31
- package/dist/_members/foundation/index.js +0 -2
- package/dist/_members/foundation/primitives/index.js +0 -5
- package/dist/_members/mcp/adapter.js +0 -771
- package/dist/_members/mcp/burnedNames.js +0 -73
- package/dist/_members/mcp/core.js +0 -390
- package/dist/_members/mcp/curation.js +0 -792
- package/dist/_members/mcp/executor.js +0 -142
- package/dist/_members/mcp/format.js +0 -9
- package/dist/_members/mcp/generated/catalogPreviews.js +0 -95
- package/dist/_members/mcp/generated/harness.js +0 -81
- package/dist/_members/mcp/generated/operations.js +0 -131
- package/dist/_members/mcp/index.js +0 -50
- package/dist/_members/mcp/internalLoopTools.js +0 -109
- package/dist/_members/mcp/prompts.js +0 -45
- package/dist/_members/mcp/resources.js +0 -166
- package/dist/_members/mcp/server.js +0 -340
- package/dist/_members/mcp/wait.js +0 -378
- package/dist/_members/mcp/x402Meta.js +0 -66
- package/dist/_members/media-model/api.js +0 -175
- package/dist/_members/media-model/index.js +0 -1
- package/dist/_members/media-model/media-kind.js +0 -116
- package/dist/_members/media-model/testing/index.js +0 -1
- package/dist/_members/media-model/testing/mediaStoreContract.js +0 -82
- package/dist/_members/media-model/transcriptSearch.js +0 -70
- package/dist/_members/media-model/transcriptSearchCases.json +0 -79
- package/dist/_members/nle-export/compact-timeline.js +0 -73
- package/dist/_members/nle-export/compact-timeline.js.map +0 -1
- package/dist/_members/nle-export/composition-to-input.js +0 -147
- package/dist/_members/nle-export/composition-to-input.js.map +0 -1
- package/dist/_members/nle-export/fcpxml.js +0 -159
- package/dist/_members/nle-export/fcpxml.js.map +0 -1
- package/dist/_members/nle-export/index.js +0 -12
- package/dist/_members/nle-export/index.js.map +0 -1
- package/dist/_members/nle-export/premiere.js +0 -161
- package/dist/_members/nle-export/premiere.js.map +0 -1
- package/dist/_members/nle-export/server/index.js +0 -2
- package/dist/_members/nle-export/server/index.js.map +0 -1
- package/dist/_members/nle-export/server/pack-zip.js +0 -38
- package/dist/_members/nle-export/server/pack-zip.js.map +0 -1
- package/dist/_members/nle-export/srt.js +0 -50
- package/dist/_members/nle-export/srt.js.map +0 -1
- package/dist/_members/nle-export/types.js +0 -9
- package/dist/_members/nle-export/types.js.map +0 -1
- package/dist/_members/nle-export/xml/index.js +0 -11
- package/dist/_members/nle-export/xml/index.js.map +0 -1
- package/dist/_members/nle-export/xml-utils.js +0 -48
- package/dist/_members/nle-export/xml-utils.js.map +0 -1
- package/dist/_members/perception/activeSpeaker.js +0 -103
- package/dist/_members/perception/audioQuality.js +0 -76
- package/dist/_members/perception/energyBeat.js +0 -99
- package/dist/_members/perception/identityMatch.js +0 -91
- package/dist/_members/perception/index.js +0 -48
- package/dist/_members/perception/visualQuality.js +0 -95
- package/dist/_members/plane/conformance.js +0 -90
- package/dist/_members/plane/contract.js +0 -49
- package/dist/_members/plane/index.js +0 -16
- package/dist/_members/primitives/backgrounds/index.js +0 -32
- package/dist/_members/primitives/backgrounds/index.js.map +0 -1
- package/dist/_members/primitives/captions/index.js +0 -398
- package/dist/_members/primitives/captions/index.js.map +0 -1
- package/dist/_members/primitives/chunk-2LVE4UIT.js +0 -139
- package/dist/_members/primitives/chunk-2LVE4UIT.js.map +0 -1
- package/dist/_members/primitives/chunk-3IQUH6KK.js +0 -20
- package/dist/_members/primitives/chunk-3IQUH6KK.js.map +0 -1
- package/dist/_members/primitives/chunk-3OMURV6Q.js +0 -112
- package/dist/_members/primitives/chunk-3OMURV6Q.js.map +0 -1
- package/dist/_members/primitives/chunk-4IS6TMEG.js +0 -21
- package/dist/_members/primitives/chunk-4IS6TMEG.js.map +0 -1
- package/dist/_members/primitives/chunk-5MWGAEGQ.js +0 -1644
- package/dist/_members/primitives/chunk-5MWGAEGQ.js.map +0 -1
- package/dist/_members/primitives/chunk-7RRPFPQK.js +0 -15
- package/dist/_members/primitives/chunk-7RRPFPQK.js.map +0 -1
- package/dist/_members/primitives/chunk-DH5TRZK2.js +0 -125
- package/dist/_members/primitives/chunk-DH5TRZK2.js.map +0 -1
- package/dist/_members/primitives/chunk-E3KNUSFG.js +0 -2337
- package/dist/_members/primitives/chunk-E3KNUSFG.js.map +0 -1
- package/dist/_members/primitives/chunk-G2B3G4HK.js +0 -47
- package/dist/_members/primitives/chunk-G2B3G4HK.js.map +0 -1
- package/dist/_members/primitives/chunk-HFPFGZXT.js +0 -1494
- package/dist/_members/primitives/chunk-HFPFGZXT.js.map +0 -1
- package/dist/_members/primitives/chunk-HIWVFZVH.js +0 -19
- package/dist/_members/primitives/chunk-HIWVFZVH.js.map +0 -1
- package/dist/_members/primitives/chunk-IDAL6G3Y.js.map +0 -1
- package/dist/_members/primitives/chunk-KNC6JP5F.js +0 -34
- package/dist/_members/primitives/chunk-KNC6JP5F.js.map +0 -1
- package/dist/_members/primitives/chunk-KYRDVZST.js +0 -459
- package/dist/_members/primitives/chunk-KYRDVZST.js.map +0 -1
- package/dist/_members/primitives/chunk-LWLHS2NS.js +0 -3410
- package/dist/_members/primitives/chunk-LWLHS2NS.js.map +0 -1
- package/dist/_members/primitives/chunk-QAQ3P7DR.js +0 -8855
- package/dist/_members/primitives/chunk-QAQ3P7DR.js.map +0 -1
- package/dist/_members/primitives/chunk-ROV2ODWC.js +0 -81
- package/dist/_members/primitives/chunk-ROV2ODWC.js.map +0 -1
- package/dist/_members/primitives/chunk-TCRC2FH3.js +0 -183
- package/dist/_members/primitives/chunk-TCRC2FH3.js.map +0 -1
- package/dist/_members/primitives/chunk-US4YEDAA.js +0 -96
- package/dist/_members/primitives/chunk-US4YEDAA.js.map +0 -1
- package/dist/_members/primitives/chunk-UVKRO5ER.js +0 -13
- package/dist/_members/primitives/chunk-UVKRO5ER.js.map +0 -1
- package/dist/_members/primitives/chunk-W4EIIF2I.js +0 -10
- package/dist/_members/primitives/chunk-W4EIIF2I.js.map +0 -1
- package/dist/_members/primitives/chunk-WPGKIPCO.js +0 -3563
- package/dist/_members/primitives/chunk-WPGKIPCO.js.map +0 -1
- package/dist/_members/primitives/chunk-WZFLEGMD.js +0 -1435
- package/dist/_members/primitives/chunk-WZFLEGMD.js.map +0 -1
- package/dist/_members/primitives/chunk-XHU3WBEI.js +0 -33
- package/dist/_members/primitives/chunk-XHU3WBEI.js.map +0 -1
- package/dist/_members/primitives/chunk-YN7WTZZ7.js +0 -46
- package/dist/_members/primitives/chunk-YN7WTZZ7.js.map +0 -1
- package/dist/_members/primitives/effects/index.js +0 -30
- package/dist/_members/primitives/effects/index.js.map +0 -1
- package/dist/_members/primitives/hero-text/index.js +0 -14
- package/dist/_members/primitives/hero-text/index.js.map +0 -1
- package/dist/_members/primitives/index.js +0 -64
- package/dist/_members/primitives/index.js.map +0 -1
- package/dist/_members/primitives/layouts/index.js +0 -24
- package/dist/_members/primitives/layouts/index.js.map +0 -1
- package/dist/_members/primitives/lib/easings.js +0 -26
- package/dist/_members/primitives/lib/easings.js.map +0 -1
- package/dist/_members/primitives/lib/index.js +0 -74
- package/dist/_members/primitives/lib/index.js.map +0 -1
- package/dist/_members/primitives/lib/palette.js +0 -72
- package/dist/_members/primitives/lib/palette.js.map +0 -1
- package/dist/_members/primitives/lib/preview.js +0 -8
- package/dist/_members/primitives/lib/preview.js.map +0 -1
- package/dist/_members/primitives/lib/schema.js +0 -12
- package/dist/_members/primitives/lib/schema.js.map +0 -1
- package/dist/_members/primitives/lib/seeded-random.js +0 -14
- package/dist/_members/primitives/lib/seeded-random.js.map +0 -1
- package/dist/_members/primitives/lib/text/contrast.js +0 -12
- package/dist/_members/primitives/lib/text/contrast.js.map +0 -1
- package/dist/_members/primitives/lib/text/fill.js +0 -8
- package/dist/_members/primitives/lib/text/fill.js.map +0 -1
- package/dist/_members/primitives/lib/text/fitText.js +0 -10
- package/dist/_members/primitives/lib/text/fitText.js.map +0 -1
- package/dist/_members/primitives/lib/text/marker.js +0 -8
- package/dist/_members/primitives/lib/text/marker.js.map +0 -1
- package/dist/_members/primitives/lib/text/motion.js +0 -16
- package/dist/_members/primitives/lib/text/motion.js.map +0 -1
- package/dist/_members/primitives/lib/text/recolor.js +0 -8
- package/dist/_members/primitives/lib/text/recolor.js.map +0 -1
- package/dist/_members/primitives/lib/text/spec.js +0 -1
- package/dist/_members/primitives/lib/text/spec.js.map +0 -1
- package/dist/_members/primitives/lib/text/stage.js +0 -8
- package/dist/_members/primitives/lib/text/stage.js.map +0 -1
- package/dist/_members/primitives/lib/text/typeface.js +0 -8
- package/dist/_members/primitives/lib/text/typeface.js.map +0 -1
- package/dist/_members/primitives/lib/tokens.js +0 -24
- package/dist/_members/primitives/lib/tokens.js.map +0 -1
- package/dist/_members/primitives/lib/types.js +0 -1
- package/dist/_members/primitives/lib/types.js.map +0 -1
- package/dist/_members/primitives/params-required.json +0 -153
- package/dist/_members/primitives/scenes/index.js +0 -25
- package/dist/_members/primitives/scenes/index.js.map +0 -1
- package/dist/_members/primitives/subject-foreground/index.js +0 -30
- package/dist/_members/primitives/subject-foreground/index.js.map +0 -1
- package/dist/_members/primitives/text/index.js +0 -57
- package/dist/_members/primitives/text/index.js.map +0 -1
- package/dist/_members/primitives/transitions/index.js +0 -67
- package/dist/_members/primitives/transitions/index.js.map +0 -1
- package/dist/_members/primitives/ui-blocks/index.js +0 -76
- package/dist/_members/primitives/ui-blocks/index.js.map +0 -1
- package/dist/_members/primitives/version-map.json +0 -105
- package/dist/_members/primitives/workspace.js +0 -60
- package/dist/_members/primitives/workspace.js.map +0 -1
- package/dist/chunk-7GISRVON.js +0 -14176
- package/dist/chunk-DIBOJJMU.js +0 -16838
- package/dist/chunk-EAUSEGB7.js +0 -420
- package/dist/chunk-FUWJOVVK.js +0 -3633
- package/dist/chunk-G75E7YA4.js +0 -11883
- package/dist/chunk-JCZQT7K3.js +0 -3266
- package/dist/chunk-KF5ETMKB.js +0 -544
- package/dist/chunk-NDKERSXY.js +0 -1296
- package/dist/chunk-V43Y7IE4.js +0 -3621
- package/dist/chunk-VIVQHIGZ.js +0 -4319
- package/dist/chunk-YA3OR2KK.js +0 -249
- package/dist/hls-HD4C5G6W.js +0 -33000
- package/dist/token-RGFIT24D.js +0 -69
- package/dist/token-util-GPLSGYVO.js +0 -5
- package/dist/vision_bundle-5Y376MAR.js +0 -4084
package/dist/chunk-JCZQT7K3.js
DELETED
|
@@ -1,3266 +0,0 @@
|
|
|
1
|
-
// ../../node_modules/.pnpm/three@0.183.2/node_modules/three/src/constants.js
|
|
2
|
-
var NeverDepth = 0;
|
|
3
|
-
var AlwaysDepth = 1;
|
|
4
|
-
var LessDepth = 2;
|
|
5
|
-
var LessEqualDepth = 3;
|
|
6
|
-
var EqualDepth = 4;
|
|
7
|
-
var GreaterEqualDepth = 5;
|
|
8
|
-
var GreaterDepth = 6;
|
|
9
|
-
var NotEqualDepth = 7;
|
|
10
|
-
var UVMapping = 300;
|
|
11
|
-
var RepeatWrapping = 1e3;
|
|
12
|
-
var ClampToEdgeWrapping = 1001;
|
|
13
|
-
var MirroredRepeatWrapping = 1002;
|
|
14
|
-
var LinearFilter = 1006;
|
|
15
|
-
var LinearMipmapLinearFilter = 1008;
|
|
16
|
-
var UnsignedByteType = 1009;
|
|
17
|
-
var RGBAFormat = 1023;
|
|
18
|
-
var NoColorSpace = "";
|
|
19
|
-
|
|
20
|
-
// ../../node_modules/.pnpm/three@0.183.2/node_modules/three/src/core/EventDispatcher.js
|
|
21
|
-
var EventDispatcher = class {
|
|
22
|
-
/**
|
|
23
|
-
* Adds the given event listener to the given event type.
|
|
24
|
-
*
|
|
25
|
-
* @param {string} type - The type of event to listen to.
|
|
26
|
-
* @param {Function} listener - The function that gets called when the event is fired.
|
|
27
|
-
*/
|
|
28
|
-
addEventListener(type, listener) {
|
|
29
|
-
if (this._listeners === void 0) this._listeners = {};
|
|
30
|
-
const listeners = this._listeners;
|
|
31
|
-
if (listeners[type] === void 0) {
|
|
32
|
-
listeners[type] = [];
|
|
33
|
-
}
|
|
34
|
-
if (listeners[type].indexOf(listener) === -1) {
|
|
35
|
-
listeners[type].push(listener);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Returns `true` if the given event listener has been added to the given event type.
|
|
40
|
-
*
|
|
41
|
-
* @param {string} type - The type of event.
|
|
42
|
-
* @param {Function} listener - The listener to check.
|
|
43
|
-
* @return {boolean} Whether the given event listener has been added to the given event type.
|
|
44
|
-
*/
|
|
45
|
-
hasEventListener(type, listener) {
|
|
46
|
-
const listeners = this._listeners;
|
|
47
|
-
if (listeners === void 0) return false;
|
|
48
|
-
return listeners[type] !== void 0 && listeners[type].indexOf(listener) !== -1;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Removes the given event listener from the given event type.
|
|
52
|
-
*
|
|
53
|
-
* @param {string} type - The type of event.
|
|
54
|
-
* @param {Function} listener - The listener to remove.
|
|
55
|
-
*/
|
|
56
|
-
removeEventListener(type, listener) {
|
|
57
|
-
const listeners = this._listeners;
|
|
58
|
-
if (listeners === void 0) return;
|
|
59
|
-
const listenerArray = listeners[type];
|
|
60
|
-
if (listenerArray !== void 0) {
|
|
61
|
-
const index = listenerArray.indexOf(listener);
|
|
62
|
-
if (index !== -1) {
|
|
63
|
-
listenerArray.splice(index, 1);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Dispatches an event object.
|
|
69
|
-
*
|
|
70
|
-
* @param {Object} event - The event that gets fired.
|
|
71
|
-
*/
|
|
72
|
-
dispatchEvent(event) {
|
|
73
|
-
const listeners = this._listeners;
|
|
74
|
-
if (listeners === void 0) return;
|
|
75
|
-
const listenerArray = listeners[event.type];
|
|
76
|
-
if (listenerArray !== void 0) {
|
|
77
|
-
event.target = this;
|
|
78
|
-
const array = listenerArray.slice(0);
|
|
79
|
-
for (let i = 0, l = array.length; i < l; i++) {
|
|
80
|
-
array[i].call(this, event);
|
|
81
|
-
}
|
|
82
|
-
event.target = null;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
// ../../node_modules/.pnpm/three@0.183.2/node_modules/three/src/utils.js
|
|
88
|
-
function createElementNS(name) {
|
|
89
|
-
return document.createElementNS("http://www.w3.org/1999/xhtml", name);
|
|
90
|
-
}
|
|
91
|
-
var _setConsoleFunction = null;
|
|
92
|
-
function enhanceLogMessage(params) {
|
|
93
|
-
const message = params[0];
|
|
94
|
-
if (typeof message === "string" && message.startsWith("TSL:")) {
|
|
95
|
-
const stackTrace = params[1];
|
|
96
|
-
if (stackTrace && stackTrace.isStackTrace) {
|
|
97
|
-
params[0] += " " + stackTrace.getLocation();
|
|
98
|
-
} else {
|
|
99
|
-
params[1] = 'Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.';
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return params;
|
|
103
|
-
}
|
|
104
|
-
function warn(...params) {
|
|
105
|
-
params = enhanceLogMessage(params);
|
|
106
|
-
const message = "THREE." + params.shift();
|
|
107
|
-
if (_setConsoleFunction) {
|
|
108
|
-
_setConsoleFunction("warn", message, ...params);
|
|
109
|
-
} else {
|
|
110
|
-
const stackTrace = params[0];
|
|
111
|
-
if (stackTrace && stackTrace.isStackTrace) {
|
|
112
|
-
console.warn(stackTrace.getError(message));
|
|
113
|
-
} else {
|
|
114
|
-
console.warn(message, ...params);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
var ReversedDepthFuncs = {
|
|
119
|
-
[NeverDepth]: AlwaysDepth,
|
|
120
|
-
[LessDepth]: GreaterDepth,
|
|
121
|
-
[EqualDepth]: NotEqualDepth,
|
|
122
|
-
[LessEqualDepth]: GreaterEqualDepth,
|
|
123
|
-
[AlwaysDepth]: NeverDepth,
|
|
124
|
-
[GreaterDepth]: LessDepth,
|
|
125
|
-
[NotEqualDepth]: EqualDepth,
|
|
126
|
-
[GreaterEqualDepth]: LessEqualDepth
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
// ../../node_modules/.pnpm/three@0.183.2/node_modules/three/src/math/MathUtils.js
|
|
130
|
-
var _lut = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0a", "0b", "0c", "0d", "0e", "0f", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "1a", "1b", "1c", "1d", "1e", "1f", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "2a", "2b", "2c", "2d", "2e", "2f", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "3a", "3b", "3c", "3d", "3e", "3f", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "4a", "4b", "4c", "4d", "4e", "4f", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "5a", "5b", "5c", "5d", "5e", "5f", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "6a", "6b", "6c", "6d", "6e", "6f", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "7a", "7b", "7c", "7d", "7e", "7f", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "8a", "8b", "8c", "8d", "8e", "8f", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "9a", "9b", "9c", "9d", "9e", "9f", "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "aa", "ab", "ac", "ad", "ae", "af", "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "ba", "bb", "bc", "bd", "be", "bf", "c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "ca", "cb", "cc", "cd", "ce", "cf", "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "da", "db", "dc", "dd", "de", "df", "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9", "ea", "eb", "ec", "ed", "ee", "ef", "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "fa", "fb", "fc", "fd", "fe", "ff"];
|
|
131
|
-
var DEG2RAD = Math.PI / 180;
|
|
132
|
-
var RAD2DEG = 180 / Math.PI;
|
|
133
|
-
function generateUUID() {
|
|
134
|
-
const d0 = Math.random() * 4294967295 | 0;
|
|
135
|
-
const d1 = Math.random() * 4294967295 | 0;
|
|
136
|
-
const d2 = Math.random() * 4294967295 | 0;
|
|
137
|
-
const d3 = Math.random() * 4294967295 | 0;
|
|
138
|
-
const uuid = _lut[d0 & 255] + _lut[d0 >> 8 & 255] + _lut[d0 >> 16 & 255] + _lut[d0 >> 24 & 255] + "-" + _lut[d1 & 255] + _lut[d1 >> 8 & 255] + "-" + _lut[d1 >> 16 & 15 | 64] + _lut[d1 >> 24 & 255] + "-" + _lut[d2 & 63 | 128] + _lut[d2 >> 8 & 255] + "-" + _lut[d2 >> 16 & 255] + _lut[d2 >> 24 & 255] + _lut[d3 & 255] + _lut[d3 >> 8 & 255] + _lut[d3 >> 16 & 255] + _lut[d3 >> 24 & 255];
|
|
139
|
-
return uuid.toLowerCase();
|
|
140
|
-
}
|
|
141
|
-
function clamp(value, min, max) {
|
|
142
|
-
return Math.max(min, Math.min(max, value));
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// ../../node_modules/.pnpm/three@0.183.2/node_modules/three/src/math/Vector2.js
|
|
146
|
-
var Vector2 = class _Vector2 {
|
|
147
|
-
/**
|
|
148
|
-
* Constructs a new 2D vector.
|
|
149
|
-
*
|
|
150
|
-
* @param {number} [x=0] - The x value of this vector.
|
|
151
|
-
* @param {number} [y=0] - The y value of this vector.
|
|
152
|
-
*/
|
|
153
|
-
constructor(x = 0, y = 0) {
|
|
154
|
-
_Vector2.prototype.isVector2 = true;
|
|
155
|
-
this.x = x;
|
|
156
|
-
this.y = y;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Alias for {@link Vector2#x}.
|
|
160
|
-
*
|
|
161
|
-
* @type {number}
|
|
162
|
-
*/
|
|
163
|
-
get width() {
|
|
164
|
-
return this.x;
|
|
165
|
-
}
|
|
166
|
-
set width(value) {
|
|
167
|
-
this.x = value;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Alias for {@link Vector2#y}.
|
|
171
|
-
*
|
|
172
|
-
* @type {number}
|
|
173
|
-
*/
|
|
174
|
-
get height() {
|
|
175
|
-
return this.y;
|
|
176
|
-
}
|
|
177
|
-
set height(value) {
|
|
178
|
-
this.y = value;
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Sets the vector components.
|
|
182
|
-
*
|
|
183
|
-
* @param {number} x - The value of the x component.
|
|
184
|
-
* @param {number} y - The value of the y component.
|
|
185
|
-
* @return {Vector2} A reference to this vector.
|
|
186
|
-
*/
|
|
187
|
-
set(x, y) {
|
|
188
|
-
this.x = x;
|
|
189
|
-
this.y = y;
|
|
190
|
-
return this;
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Sets the vector components to the same value.
|
|
194
|
-
*
|
|
195
|
-
* @param {number} scalar - The value to set for all vector components.
|
|
196
|
-
* @return {Vector2} A reference to this vector.
|
|
197
|
-
*/
|
|
198
|
-
setScalar(scalar) {
|
|
199
|
-
this.x = scalar;
|
|
200
|
-
this.y = scalar;
|
|
201
|
-
return this;
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Sets the vector's x component to the given value
|
|
205
|
-
*
|
|
206
|
-
* @param {number} x - The value to set.
|
|
207
|
-
* @return {Vector2} A reference to this vector.
|
|
208
|
-
*/
|
|
209
|
-
setX(x) {
|
|
210
|
-
this.x = x;
|
|
211
|
-
return this;
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Sets the vector's y component to the given value
|
|
215
|
-
*
|
|
216
|
-
* @param {number} y - The value to set.
|
|
217
|
-
* @return {Vector2} A reference to this vector.
|
|
218
|
-
*/
|
|
219
|
-
setY(y) {
|
|
220
|
-
this.y = y;
|
|
221
|
-
return this;
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Allows to set a vector component with an index.
|
|
225
|
-
*
|
|
226
|
-
* @param {number} index - The component index. `0` equals to x, `1` equals to y.
|
|
227
|
-
* @param {number} value - The value to set.
|
|
228
|
-
* @return {Vector2} A reference to this vector.
|
|
229
|
-
*/
|
|
230
|
-
setComponent(index, value) {
|
|
231
|
-
switch (index) {
|
|
232
|
-
case 0:
|
|
233
|
-
this.x = value;
|
|
234
|
-
break;
|
|
235
|
-
case 1:
|
|
236
|
-
this.y = value;
|
|
237
|
-
break;
|
|
238
|
-
default:
|
|
239
|
-
throw new Error("index is out of range: " + index);
|
|
240
|
-
}
|
|
241
|
-
return this;
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Returns the value of the vector component which matches the given index.
|
|
245
|
-
*
|
|
246
|
-
* @param {number} index - The component index. `0` equals to x, `1` equals to y.
|
|
247
|
-
* @return {number} A vector component value.
|
|
248
|
-
*/
|
|
249
|
-
getComponent(index) {
|
|
250
|
-
switch (index) {
|
|
251
|
-
case 0:
|
|
252
|
-
return this.x;
|
|
253
|
-
case 1:
|
|
254
|
-
return this.y;
|
|
255
|
-
default:
|
|
256
|
-
throw new Error("index is out of range: " + index);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Returns a new vector with copied values from this instance.
|
|
261
|
-
*
|
|
262
|
-
* @return {Vector2} A clone of this instance.
|
|
263
|
-
*/
|
|
264
|
-
clone() {
|
|
265
|
-
return new this.constructor(this.x, this.y);
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Copies the values of the given vector to this instance.
|
|
269
|
-
*
|
|
270
|
-
* @param {Vector2} v - The vector to copy.
|
|
271
|
-
* @return {Vector2} A reference to this vector.
|
|
272
|
-
*/
|
|
273
|
-
copy(v) {
|
|
274
|
-
this.x = v.x;
|
|
275
|
-
this.y = v.y;
|
|
276
|
-
return this;
|
|
277
|
-
}
|
|
278
|
-
/**
|
|
279
|
-
* Adds the given vector to this instance.
|
|
280
|
-
*
|
|
281
|
-
* @param {Vector2} v - The vector to add.
|
|
282
|
-
* @return {Vector2} A reference to this vector.
|
|
283
|
-
*/
|
|
284
|
-
add(v) {
|
|
285
|
-
this.x += v.x;
|
|
286
|
-
this.y += v.y;
|
|
287
|
-
return this;
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* Adds the given scalar value to all components of this instance.
|
|
291
|
-
*
|
|
292
|
-
* @param {number} s - The scalar to add.
|
|
293
|
-
* @return {Vector2} A reference to this vector.
|
|
294
|
-
*/
|
|
295
|
-
addScalar(s) {
|
|
296
|
-
this.x += s;
|
|
297
|
-
this.y += s;
|
|
298
|
-
return this;
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* Adds the given vectors and stores the result in this instance.
|
|
302
|
-
*
|
|
303
|
-
* @param {Vector2} a - The first vector.
|
|
304
|
-
* @param {Vector2} b - The second vector.
|
|
305
|
-
* @return {Vector2} A reference to this vector.
|
|
306
|
-
*/
|
|
307
|
-
addVectors(a, b) {
|
|
308
|
-
this.x = a.x + b.x;
|
|
309
|
-
this.y = a.y + b.y;
|
|
310
|
-
return this;
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* Adds the given vector scaled by the given factor to this instance.
|
|
314
|
-
*
|
|
315
|
-
* @param {Vector2} v - The vector.
|
|
316
|
-
* @param {number} s - The factor that scales `v`.
|
|
317
|
-
* @return {Vector2} A reference to this vector.
|
|
318
|
-
*/
|
|
319
|
-
addScaledVector(v, s) {
|
|
320
|
-
this.x += v.x * s;
|
|
321
|
-
this.y += v.y * s;
|
|
322
|
-
return this;
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Subtracts the given vector from this instance.
|
|
326
|
-
*
|
|
327
|
-
* @param {Vector2} v - The vector to subtract.
|
|
328
|
-
* @return {Vector2} A reference to this vector.
|
|
329
|
-
*/
|
|
330
|
-
sub(v) {
|
|
331
|
-
this.x -= v.x;
|
|
332
|
-
this.y -= v.y;
|
|
333
|
-
return this;
|
|
334
|
-
}
|
|
335
|
-
/**
|
|
336
|
-
* Subtracts the given scalar value from all components of this instance.
|
|
337
|
-
*
|
|
338
|
-
* @param {number} s - The scalar to subtract.
|
|
339
|
-
* @return {Vector2} A reference to this vector.
|
|
340
|
-
*/
|
|
341
|
-
subScalar(s) {
|
|
342
|
-
this.x -= s;
|
|
343
|
-
this.y -= s;
|
|
344
|
-
return this;
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* Subtracts the given vectors and stores the result in this instance.
|
|
348
|
-
*
|
|
349
|
-
* @param {Vector2} a - The first vector.
|
|
350
|
-
* @param {Vector2} b - The second vector.
|
|
351
|
-
* @return {Vector2} A reference to this vector.
|
|
352
|
-
*/
|
|
353
|
-
subVectors(a, b) {
|
|
354
|
-
this.x = a.x - b.x;
|
|
355
|
-
this.y = a.y - b.y;
|
|
356
|
-
return this;
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
* Multiplies the given vector with this instance.
|
|
360
|
-
*
|
|
361
|
-
* @param {Vector2} v - The vector to multiply.
|
|
362
|
-
* @return {Vector2} A reference to this vector.
|
|
363
|
-
*/
|
|
364
|
-
multiply(v) {
|
|
365
|
-
this.x *= v.x;
|
|
366
|
-
this.y *= v.y;
|
|
367
|
-
return this;
|
|
368
|
-
}
|
|
369
|
-
/**
|
|
370
|
-
* Multiplies the given scalar value with all components of this instance.
|
|
371
|
-
*
|
|
372
|
-
* @param {number} scalar - The scalar to multiply.
|
|
373
|
-
* @return {Vector2} A reference to this vector.
|
|
374
|
-
*/
|
|
375
|
-
multiplyScalar(scalar) {
|
|
376
|
-
this.x *= scalar;
|
|
377
|
-
this.y *= scalar;
|
|
378
|
-
return this;
|
|
379
|
-
}
|
|
380
|
-
/**
|
|
381
|
-
* Divides this instance by the given vector.
|
|
382
|
-
*
|
|
383
|
-
* @param {Vector2} v - The vector to divide.
|
|
384
|
-
* @return {Vector2} A reference to this vector.
|
|
385
|
-
*/
|
|
386
|
-
divide(v) {
|
|
387
|
-
this.x /= v.x;
|
|
388
|
-
this.y /= v.y;
|
|
389
|
-
return this;
|
|
390
|
-
}
|
|
391
|
-
/**
|
|
392
|
-
* Divides this vector by the given scalar.
|
|
393
|
-
*
|
|
394
|
-
* @param {number} scalar - The scalar to divide.
|
|
395
|
-
* @return {Vector2} A reference to this vector.
|
|
396
|
-
*/
|
|
397
|
-
divideScalar(scalar) {
|
|
398
|
-
return this.multiplyScalar(1 / scalar);
|
|
399
|
-
}
|
|
400
|
-
/**
|
|
401
|
-
* Multiplies this vector (with an implicit 1 as the 3rd component) by
|
|
402
|
-
* the given 3x3 matrix.
|
|
403
|
-
*
|
|
404
|
-
* @param {Matrix3} m - The matrix to apply.
|
|
405
|
-
* @return {Vector2} A reference to this vector.
|
|
406
|
-
*/
|
|
407
|
-
applyMatrix3(m) {
|
|
408
|
-
const x = this.x, y = this.y;
|
|
409
|
-
const e = m.elements;
|
|
410
|
-
this.x = e[0] * x + e[3] * y + e[6];
|
|
411
|
-
this.y = e[1] * x + e[4] * y + e[7];
|
|
412
|
-
return this;
|
|
413
|
-
}
|
|
414
|
-
/**
|
|
415
|
-
* If this vector's x or y value is greater than the given vector's x or y
|
|
416
|
-
* value, replace that value with the corresponding min value.
|
|
417
|
-
*
|
|
418
|
-
* @param {Vector2} v - The vector.
|
|
419
|
-
* @return {Vector2} A reference to this vector.
|
|
420
|
-
*/
|
|
421
|
-
min(v) {
|
|
422
|
-
this.x = Math.min(this.x, v.x);
|
|
423
|
-
this.y = Math.min(this.y, v.y);
|
|
424
|
-
return this;
|
|
425
|
-
}
|
|
426
|
-
/**
|
|
427
|
-
* If this vector's x or y value is less than the given vector's x or y
|
|
428
|
-
* value, replace that value with the corresponding max value.
|
|
429
|
-
*
|
|
430
|
-
* @param {Vector2} v - The vector.
|
|
431
|
-
* @return {Vector2} A reference to this vector.
|
|
432
|
-
*/
|
|
433
|
-
max(v) {
|
|
434
|
-
this.x = Math.max(this.x, v.x);
|
|
435
|
-
this.y = Math.max(this.y, v.y);
|
|
436
|
-
return this;
|
|
437
|
-
}
|
|
438
|
-
/**
|
|
439
|
-
* If this vector's x or y value is greater than the max vector's x or y
|
|
440
|
-
* value, it is replaced by the corresponding value.
|
|
441
|
-
* If this vector's x or y value is less than the min vector's x or y value,
|
|
442
|
-
* it is replaced by the corresponding value.
|
|
443
|
-
*
|
|
444
|
-
* @param {Vector2} min - The minimum x and y values.
|
|
445
|
-
* @param {Vector2} max - The maximum x and y values in the desired range.
|
|
446
|
-
* @return {Vector2} A reference to this vector.
|
|
447
|
-
*/
|
|
448
|
-
clamp(min, max) {
|
|
449
|
-
this.x = clamp(this.x, min.x, max.x);
|
|
450
|
-
this.y = clamp(this.y, min.y, max.y);
|
|
451
|
-
return this;
|
|
452
|
-
}
|
|
453
|
-
/**
|
|
454
|
-
* If this vector's x or y values are greater than the max value, they are
|
|
455
|
-
* replaced by the max value.
|
|
456
|
-
* If this vector's x or y values are less than the min value, they are
|
|
457
|
-
* replaced by the min value.
|
|
458
|
-
*
|
|
459
|
-
* @param {number} minVal - The minimum value the components will be clamped to.
|
|
460
|
-
* @param {number} maxVal - The maximum value the components will be clamped to.
|
|
461
|
-
* @return {Vector2} A reference to this vector.
|
|
462
|
-
*/
|
|
463
|
-
clampScalar(minVal, maxVal) {
|
|
464
|
-
this.x = clamp(this.x, minVal, maxVal);
|
|
465
|
-
this.y = clamp(this.y, minVal, maxVal);
|
|
466
|
-
return this;
|
|
467
|
-
}
|
|
468
|
-
/**
|
|
469
|
-
* If this vector's length is greater than the max value, it is replaced by
|
|
470
|
-
* the max value.
|
|
471
|
-
* If this vector's length is less than the min value, it is replaced by the
|
|
472
|
-
* min value.
|
|
473
|
-
*
|
|
474
|
-
* @param {number} min - The minimum value the vector length will be clamped to.
|
|
475
|
-
* @param {number} max - The maximum value the vector length will be clamped to.
|
|
476
|
-
* @return {Vector2} A reference to this vector.
|
|
477
|
-
*/
|
|
478
|
-
clampLength(min, max) {
|
|
479
|
-
const length = this.length();
|
|
480
|
-
return this.divideScalar(length || 1).multiplyScalar(clamp(length, min, max));
|
|
481
|
-
}
|
|
482
|
-
/**
|
|
483
|
-
* The components of this vector are rounded down to the nearest integer value.
|
|
484
|
-
*
|
|
485
|
-
* @return {Vector2} A reference to this vector.
|
|
486
|
-
*/
|
|
487
|
-
floor() {
|
|
488
|
-
this.x = Math.floor(this.x);
|
|
489
|
-
this.y = Math.floor(this.y);
|
|
490
|
-
return this;
|
|
491
|
-
}
|
|
492
|
-
/**
|
|
493
|
-
* The components of this vector are rounded up to the nearest integer value.
|
|
494
|
-
*
|
|
495
|
-
* @return {Vector2} A reference to this vector.
|
|
496
|
-
*/
|
|
497
|
-
ceil() {
|
|
498
|
-
this.x = Math.ceil(this.x);
|
|
499
|
-
this.y = Math.ceil(this.y);
|
|
500
|
-
return this;
|
|
501
|
-
}
|
|
502
|
-
/**
|
|
503
|
-
* The components of this vector are rounded to the nearest integer value
|
|
504
|
-
*
|
|
505
|
-
* @return {Vector2} A reference to this vector.
|
|
506
|
-
*/
|
|
507
|
-
round() {
|
|
508
|
-
this.x = Math.round(this.x);
|
|
509
|
-
this.y = Math.round(this.y);
|
|
510
|
-
return this;
|
|
511
|
-
}
|
|
512
|
-
/**
|
|
513
|
-
* The components of this vector are rounded towards zero (up if negative,
|
|
514
|
-
* down if positive) to an integer value.
|
|
515
|
-
*
|
|
516
|
-
* @return {Vector2} A reference to this vector.
|
|
517
|
-
*/
|
|
518
|
-
roundToZero() {
|
|
519
|
-
this.x = Math.trunc(this.x);
|
|
520
|
-
this.y = Math.trunc(this.y);
|
|
521
|
-
return this;
|
|
522
|
-
}
|
|
523
|
-
/**
|
|
524
|
-
* Inverts this vector - i.e. sets x = -x and y = -y.
|
|
525
|
-
*
|
|
526
|
-
* @return {Vector2} A reference to this vector.
|
|
527
|
-
*/
|
|
528
|
-
negate() {
|
|
529
|
-
this.x = -this.x;
|
|
530
|
-
this.y = -this.y;
|
|
531
|
-
return this;
|
|
532
|
-
}
|
|
533
|
-
/**
|
|
534
|
-
* Calculates the dot product of the given vector with this instance.
|
|
535
|
-
*
|
|
536
|
-
* @param {Vector2} v - The vector to compute the dot product with.
|
|
537
|
-
* @return {number} The result of the dot product.
|
|
538
|
-
*/
|
|
539
|
-
dot(v) {
|
|
540
|
-
return this.x * v.x + this.y * v.y;
|
|
541
|
-
}
|
|
542
|
-
/**
|
|
543
|
-
* Calculates the cross product of the given vector with this instance.
|
|
544
|
-
*
|
|
545
|
-
* @param {Vector2} v - The vector to compute the cross product with.
|
|
546
|
-
* @return {number} The result of the cross product.
|
|
547
|
-
*/
|
|
548
|
-
cross(v) {
|
|
549
|
-
return this.x * v.y - this.y * v.x;
|
|
550
|
-
}
|
|
551
|
-
/**
|
|
552
|
-
* Computes the square of the Euclidean length (straight-line length) from
|
|
553
|
-
* (0, 0) to (x, y). If you are comparing the lengths of vectors, you should
|
|
554
|
-
* compare the length squared instead as it is slightly more efficient to calculate.
|
|
555
|
-
*
|
|
556
|
-
* @return {number} The square length of this vector.
|
|
557
|
-
*/
|
|
558
|
-
lengthSq() {
|
|
559
|
-
return this.x * this.x + this.y * this.y;
|
|
560
|
-
}
|
|
561
|
-
/**
|
|
562
|
-
* Computes the Euclidean length (straight-line length) from (0, 0) to (x, y).
|
|
563
|
-
*
|
|
564
|
-
* @return {number} The length of this vector.
|
|
565
|
-
*/
|
|
566
|
-
length() {
|
|
567
|
-
return Math.sqrt(this.x * this.x + this.y * this.y);
|
|
568
|
-
}
|
|
569
|
-
/**
|
|
570
|
-
* Computes the Manhattan length of this vector.
|
|
571
|
-
*
|
|
572
|
-
* @return {number} The length of this vector.
|
|
573
|
-
*/
|
|
574
|
-
manhattanLength() {
|
|
575
|
-
return Math.abs(this.x) + Math.abs(this.y);
|
|
576
|
-
}
|
|
577
|
-
/**
|
|
578
|
-
* Converts this vector to a unit vector - that is, sets it equal to a vector
|
|
579
|
-
* with the same direction as this one, but with a vector length of `1`.
|
|
580
|
-
*
|
|
581
|
-
* @return {Vector2} A reference to this vector.
|
|
582
|
-
*/
|
|
583
|
-
normalize() {
|
|
584
|
-
return this.divideScalar(this.length() || 1);
|
|
585
|
-
}
|
|
586
|
-
/**
|
|
587
|
-
* Computes the angle in radians of this vector with respect to the positive x-axis.
|
|
588
|
-
*
|
|
589
|
-
* @return {number} The angle in radians.
|
|
590
|
-
*/
|
|
591
|
-
angle() {
|
|
592
|
-
const angle = Math.atan2(-this.y, -this.x) + Math.PI;
|
|
593
|
-
return angle;
|
|
594
|
-
}
|
|
595
|
-
/**
|
|
596
|
-
* Returns the angle between the given vector and this instance in radians.
|
|
597
|
-
*
|
|
598
|
-
* @param {Vector2} v - The vector to compute the angle with.
|
|
599
|
-
* @return {number} The angle in radians.
|
|
600
|
-
*/
|
|
601
|
-
angleTo(v) {
|
|
602
|
-
const denominator = Math.sqrt(this.lengthSq() * v.lengthSq());
|
|
603
|
-
if (denominator === 0) return Math.PI / 2;
|
|
604
|
-
const theta = this.dot(v) / denominator;
|
|
605
|
-
return Math.acos(clamp(theta, -1, 1));
|
|
606
|
-
}
|
|
607
|
-
/**
|
|
608
|
-
* Computes the distance from the given vector to this instance.
|
|
609
|
-
*
|
|
610
|
-
* @param {Vector2} v - The vector to compute the distance to.
|
|
611
|
-
* @return {number} The distance.
|
|
612
|
-
*/
|
|
613
|
-
distanceTo(v) {
|
|
614
|
-
return Math.sqrt(this.distanceToSquared(v));
|
|
615
|
-
}
|
|
616
|
-
/**
|
|
617
|
-
* Computes the squared distance from the given vector to this instance.
|
|
618
|
-
* If you are just comparing the distance with another distance, you should compare
|
|
619
|
-
* the distance squared instead as it is slightly more efficient to calculate.
|
|
620
|
-
*
|
|
621
|
-
* @param {Vector2} v - The vector to compute the squared distance to.
|
|
622
|
-
* @return {number} The squared distance.
|
|
623
|
-
*/
|
|
624
|
-
distanceToSquared(v) {
|
|
625
|
-
const dx = this.x - v.x, dy = this.y - v.y;
|
|
626
|
-
return dx * dx + dy * dy;
|
|
627
|
-
}
|
|
628
|
-
/**
|
|
629
|
-
* Computes the Manhattan distance from the given vector to this instance.
|
|
630
|
-
*
|
|
631
|
-
* @param {Vector2} v - The vector to compute the Manhattan distance to.
|
|
632
|
-
* @return {number} The Manhattan distance.
|
|
633
|
-
*/
|
|
634
|
-
manhattanDistanceTo(v) {
|
|
635
|
-
return Math.abs(this.x - v.x) + Math.abs(this.y - v.y);
|
|
636
|
-
}
|
|
637
|
-
/**
|
|
638
|
-
* Sets this vector to a vector with the same direction as this one, but
|
|
639
|
-
* with the specified length.
|
|
640
|
-
*
|
|
641
|
-
* @param {number} length - The new length of this vector.
|
|
642
|
-
* @return {Vector2} A reference to this vector.
|
|
643
|
-
*/
|
|
644
|
-
setLength(length) {
|
|
645
|
-
return this.normalize().multiplyScalar(length);
|
|
646
|
-
}
|
|
647
|
-
/**
|
|
648
|
-
* Linearly interpolates between the given vector and this instance, where
|
|
649
|
-
* alpha is the percent distance along the line - alpha = 0 will be this
|
|
650
|
-
* vector, and alpha = 1 will be the given one.
|
|
651
|
-
*
|
|
652
|
-
* @param {Vector2} v - The vector to interpolate towards.
|
|
653
|
-
* @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.
|
|
654
|
-
* @return {Vector2} A reference to this vector.
|
|
655
|
-
*/
|
|
656
|
-
lerp(v, alpha) {
|
|
657
|
-
this.x += (v.x - this.x) * alpha;
|
|
658
|
-
this.y += (v.y - this.y) * alpha;
|
|
659
|
-
return this;
|
|
660
|
-
}
|
|
661
|
-
/**
|
|
662
|
-
* Linearly interpolates between the given vectors, where alpha is the percent
|
|
663
|
-
* distance along the line - alpha = 0 will be first vector, and alpha = 1 will
|
|
664
|
-
* be the second one. The result is stored in this instance.
|
|
665
|
-
*
|
|
666
|
-
* @param {Vector2} v1 - The first vector.
|
|
667
|
-
* @param {Vector2} v2 - The second vector.
|
|
668
|
-
* @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.
|
|
669
|
-
* @return {Vector2} A reference to this vector.
|
|
670
|
-
*/
|
|
671
|
-
lerpVectors(v1, v2, alpha) {
|
|
672
|
-
this.x = v1.x + (v2.x - v1.x) * alpha;
|
|
673
|
-
this.y = v1.y + (v2.y - v1.y) * alpha;
|
|
674
|
-
return this;
|
|
675
|
-
}
|
|
676
|
-
/**
|
|
677
|
-
* Returns `true` if this vector is equal with the given one.
|
|
678
|
-
*
|
|
679
|
-
* @param {Vector2} v - The vector to test for equality.
|
|
680
|
-
* @return {boolean} Whether this vector is equal with the given one.
|
|
681
|
-
*/
|
|
682
|
-
equals(v) {
|
|
683
|
-
return v.x === this.x && v.y === this.y;
|
|
684
|
-
}
|
|
685
|
-
/**
|
|
686
|
-
* Sets this vector's x value to be `array[ offset ]` and y
|
|
687
|
-
* value to be `array[ offset + 1 ]`.
|
|
688
|
-
*
|
|
689
|
-
* @param {Array<number>} array - An array holding the vector component values.
|
|
690
|
-
* @param {number} [offset=0] - The offset into the array.
|
|
691
|
-
* @return {Vector2} A reference to this vector.
|
|
692
|
-
*/
|
|
693
|
-
fromArray(array, offset = 0) {
|
|
694
|
-
this.x = array[offset];
|
|
695
|
-
this.y = array[offset + 1];
|
|
696
|
-
return this;
|
|
697
|
-
}
|
|
698
|
-
/**
|
|
699
|
-
* Writes the components of this vector to the given array. If no array is provided,
|
|
700
|
-
* the method returns a new instance.
|
|
701
|
-
*
|
|
702
|
-
* @param {Array<number>} [array=[]] - The target array holding the vector components.
|
|
703
|
-
* @param {number} [offset=0] - Index of the first element in the array.
|
|
704
|
-
* @return {Array<number>} The vector components.
|
|
705
|
-
*/
|
|
706
|
-
toArray(array = [], offset = 0) {
|
|
707
|
-
array[offset] = this.x;
|
|
708
|
-
array[offset + 1] = this.y;
|
|
709
|
-
return array;
|
|
710
|
-
}
|
|
711
|
-
/**
|
|
712
|
-
* Sets the components of this vector from the given buffer attribute.
|
|
713
|
-
*
|
|
714
|
-
* @param {BufferAttribute} attribute - The buffer attribute holding vector data.
|
|
715
|
-
* @param {number} index - The index into the attribute.
|
|
716
|
-
* @return {Vector2} A reference to this vector.
|
|
717
|
-
*/
|
|
718
|
-
fromBufferAttribute(attribute, index) {
|
|
719
|
-
this.x = attribute.getX(index);
|
|
720
|
-
this.y = attribute.getY(index);
|
|
721
|
-
return this;
|
|
722
|
-
}
|
|
723
|
-
/**
|
|
724
|
-
* Rotates this vector around the given center by the given angle.
|
|
725
|
-
*
|
|
726
|
-
* @param {Vector2} center - The point around which to rotate.
|
|
727
|
-
* @param {number} angle - The angle to rotate, in radians.
|
|
728
|
-
* @return {Vector2} A reference to this vector.
|
|
729
|
-
*/
|
|
730
|
-
rotateAround(center, angle) {
|
|
731
|
-
const c = Math.cos(angle), s = Math.sin(angle);
|
|
732
|
-
const x = this.x - center.x;
|
|
733
|
-
const y = this.y - center.y;
|
|
734
|
-
this.x = x * c - y * s + center.x;
|
|
735
|
-
this.y = x * s + y * c + center.y;
|
|
736
|
-
return this;
|
|
737
|
-
}
|
|
738
|
-
/**
|
|
739
|
-
* Sets each component of this vector to a pseudo-random value between `0` and
|
|
740
|
-
* `1`, excluding `1`.
|
|
741
|
-
*
|
|
742
|
-
* @return {Vector2} A reference to this vector.
|
|
743
|
-
*/
|
|
744
|
-
random() {
|
|
745
|
-
this.x = Math.random();
|
|
746
|
-
this.y = Math.random();
|
|
747
|
-
return this;
|
|
748
|
-
}
|
|
749
|
-
*[Symbol.iterator]() {
|
|
750
|
-
yield this.x;
|
|
751
|
-
yield this.y;
|
|
752
|
-
}
|
|
753
|
-
};
|
|
754
|
-
|
|
755
|
-
// ../../node_modules/.pnpm/three@0.183.2/node_modules/three/src/math/Quaternion.js
|
|
756
|
-
var Quaternion = class {
|
|
757
|
-
/**
|
|
758
|
-
* Constructs a new quaternion.
|
|
759
|
-
*
|
|
760
|
-
* @param {number} [x=0] - The x value of this quaternion.
|
|
761
|
-
* @param {number} [y=0] - The y value of this quaternion.
|
|
762
|
-
* @param {number} [z=0] - The z value of this quaternion.
|
|
763
|
-
* @param {number} [w=1] - The w value of this quaternion.
|
|
764
|
-
*/
|
|
765
|
-
constructor(x = 0, y = 0, z = 0, w = 1) {
|
|
766
|
-
this.isQuaternion = true;
|
|
767
|
-
this._x = x;
|
|
768
|
-
this._y = y;
|
|
769
|
-
this._z = z;
|
|
770
|
-
this._w = w;
|
|
771
|
-
}
|
|
772
|
-
/**
|
|
773
|
-
* Interpolates between two quaternions via SLERP. This implementation assumes the
|
|
774
|
-
* quaternion data are managed in flat arrays.
|
|
775
|
-
*
|
|
776
|
-
* @param {Array<number>} dst - The destination array.
|
|
777
|
-
* @param {number} dstOffset - An offset into the destination array.
|
|
778
|
-
* @param {Array<number>} src0 - The source array of the first quaternion.
|
|
779
|
-
* @param {number} srcOffset0 - An offset into the first source array.
|
|
780
|
-
* @param {Array<number>} src1 - The source array of the second quaternion.
|
|
781
|
-
* @param {number} srcOffset1 - An offset into the second source array.
|
|
782
|
-
* @param {number} t - The interpolation factor. A value in the range `[0,1]` will interpolate. A value outside the range `[0,1]` will extrapolate.
|
|
783
|
-
* @see {@link Quaternion#slerp}
|
|
784
|
-
*/
|
|
785
|
-
static slerpFlat(dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t) {
|
|
786
|
-
let x0 = src0[srcOffset0 + 0], y0 = src0[srcOffset0 + 1], z0 = src0[srcOffset0 + 2], w0 = src0[srcOffset0 + 3];
|
|
787
|
-
let x1 = src1[srcOffset1 + 0], y1 = src1[srcOffset1 + 1], z1 = src1[srcOffset1 + 2], w1 = src1[srcOffset1 + 3];
|
|
788
|
-
if (w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1) {
|
|
789
|
-
let dot = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1;
|
|
790
|
-
if (dot < 0) {
|
|
791
|
-
x1 = -x1;
|
|
792
|
-
y1 = -y1;
|
|
793
|
-
z1 = -z1;
|
|
794
|
-
w1 = -w1;
|
|
795
|
-
dot = -dot;
|
|
796
|
-
}
|
|
797
|
-
let s = 1 - t;
|
|
798
|
-
if (dot < 0.9995) {
|
|
799
|
-
const theta = Math.acos(dot);
|
|
800
|
-
const sin = Math.sin(theta);
|
|
801
|
-
s = Math.sin(s * theta) / sin;
|
|
802
|
-
t = Math.sin(t * theta) / sin;
|
|
803
|
-
x0 = x0 * s + x1 * t;
|
|
804
|
-
y0 = y0 * s + y1 * t;
|
|
805
|
-
z0 = z0 * s + z1 * t;
|
|
806
|
-
w0 = w0 * s + w1 * t;
|
|
807
|
-
} else {
|
|
808
|
-
x0 = x0 * s + x1 * t;
|
|
809
|
-
y0 = y0 * s + y1 * t;
|
|
810
|
-
z0 = z0 * s + z1 * t;
|
|
811
|
-
w0 = w0 * s + w1 * t;
|
|
812
|
-
const f = 1 / Math.sqrt(x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0);
|
|
813
|
-
x0 *= f;
|
|
814
|
-
y0 *= f;
|
|
815
|
-
z0 *= f;
|
|
816
|
-
w0 *= f;
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
dst[dstOffset] = x0;
|
|
820
|
-
dst[dstOffset + 1] = y0;
|
|
821
|
-
dst[dstOffset + 2] = z0;
|
|
822
|
-
dst[dstOffset + 3] = w0;
|
|
823
|
-
}
|
|
824
|
-
/**
|
|
825
|
-
* Multiplies two quaternions. This implementation assumes the quaternion data are managed
|
|
826
|
-
* in flat arrays.
|
|
827
|
-
*
|
|
828
|
-
* @param {Array<number>} dst - The destination array.
|
|
829
|
-
* @param {number} dstOffset - An offset into the destination array.
|
|
830
|
-
* @param {Array<number>} src0 - The source array of the first quaternion.
|
|
831
|
-
* @param {number} srcOffset0 - An offset into the first source array.
|
|
832
|
-
* @param {Array<number>} src1 - The source array of the second quaternion.
|
|
833
|
-
* @param {number} srcOffset1 - An offset into the second source array.
|
|
834
|
-
* @return {Array<number>} The destination array.
|
|
835
|
-
* @see {@link Quaternion#multiplyQuaternions}.
|
|
836
|
-
*/
|
|
837
|
-
static multiplyQuaternionsFlat(dst, dstOffset, src0, srcOffset0, src1, srcOffset1) {
|
|
838
|
-
const x0 = src0[srcOffset0];
|
|
839
|
-
const y0 = src0[srcOffset0 + 1];
|
|
840
|
-
const z0 = src0[srcOffset0 + 2];
|
|
841
|
-
const w0 = src0[srcOffset0 + 3];
|
|
842
|
-
const x1 = src1[srcOffset1];
|
|
843
|
-
const y1 = src1[srcOffset1 + 1];
|
|
844
|
-
const z1 = src1[srcOffset1 + 2];
|
|
845
|
-
const w1 = src1[srcOffset1 + 3];
|
|
846
|
-
dst[dstOffset] = x0 * w1 + w0 * x1 + y0 * z1 - z0 * y1;
|
|
847
|
-
dst[dstOffset + 1] = y0 * w1 + w0 * y1 + z0 * x1 - x0 * z1;
|
|
848
|
-
dst[dstOffset + 2] = z0 * w1 + w0 * z1 + x0 * y1 - y0 * x1;
|
|
849
|
-
dst[dstOffset + 3] = w0 * w1 - x0 * x1 - y0 * y1 - z0 * z1;
|
|
850
|
-
return dst;
|
|
851
|
-
}
|
|
852
|
-
/**
|
|
853
|
-
* The x value of this quaternion.
|
|
854
|
-
*
|
|
855
|
-
* @type {number}
|
|
856
|
-
* @default 0
|
|
857
|
-
*/
|
|
858
|
-
get x() {
|
|
859
|
-
return this._x;
|
|
860
|
-
}
|
|
861
|
-
set x(value) {
|
|
862
|
-
this._x = value;
|
|
863
|
-
this._onChangeCallback();
|
|
864
|
-
}
|
|
865
|
-
/**
|
|
866
|
-
* The y value of this quaternion.
|
|
867
|
-
*
|
|
868
|
-
* @type {number}
|
|
869
|
-
* @default 0
|
|
870
|
-
*/
|
|
871
|
-
get y() {
|
|
872
|
-
return this._y;
|
|
873
|
-
}
|
|
874
|
-
set y(value) {
|
|
875
|
-
this._y = value;
|
|
876
|
-
this._onChangeCallback();
|
|
877
|
-
}
|
|
878
|
-
/**
|
|
879
|
-
* The z value of this quaternion.
|
|
880
|
-
*
|
|
881
|
-
* @type {number}
|
|
882
|
-
* @default 0
|
|
883
|
-
*/
|
|
884
|
-
get z() {
|
|
885
|
-
return this._z;
|
|
886
|
-
}
|
|
887
|
-
set z(value) {
|
|
888
|
-
this._z = value;
|
|
889
|
-
this._onChangeCallback();
|
|
890
|
-
}
|
|
891
|
-
/**
|
|
892
|
-
* The w value of this quaternion.
|
|
893
|
-
*
|
|
894
|
-
* @type {number}
|
|
895
|
-
* @default 1
|
|
896
|
-
*/
|
|
897
|
-
get w() {
|
|
898
|
-
return this._w;
|
|
899
|
-
}
|
|
900
|
-
set w(value) {
|
|
901
|
-
this._w = value;
|
|
902
|
-
this._onChangeCallback();
|
|
903
|
-
}
|
|
904
|
-
/**
|
|
905
|
-
* Sets the quaternion components.
|
|
906
|
-
*
|
|
907
|
-
* @param {number} x - The x value of this quaternion.
|
|
908
|
-
* @param {number} y - The y value of this quaternion.
|
|
909
|
-
* @param {number} z - The z value of this quaternion.
|
|
910
|
-
* @param {number} w - The w value of this quaternion.
|
|
911
|
-
* @return {Quaternion} A reference to this quaternion.
|
|
912
|
-
*/
|
|
913
|
-
set(x, y, z, w) {
|
|
914
|
-
this._x = x;
|
|
915
|
-
this._y = y;
|
|
916
|
-
this._z = z;
|
|
917
|
-
this._w = w;
|
|
918
|
-
this._onChangeCallback();
|
|
919
|
-
return this;
|
|
920
|
-
}
|
|
921
|
-
/**
|
|
922
|
-
* Returns a new quaternion with copied values from this instance.
|
|
923
|
-
*
|
|
924
|
-
* @return {Quaternion} A clone of this instance.
|
|
925
|
-
*/
|
|
926
|
-
clone() {
|
|
927
|
-
return new this.constructor(this._x, this._y, this._z, this._w);
|
|
928
|
-
}
|
|
929
|
-
/**
|
|
930
|
-
* Copies the values of the given quaternion to this instance.
|
|
931
|
-
*
|
|
932
|
-
* @param {Quaternion} quaternion - The quaternion to copy.
|
|
933
|
-
* @return {Quaternion} A reference to this quaternion.
|
|
934
|
-
*/
|
|
935
|
-
copy(quaternion) {
|
|
936
|
-
this._x = quaternion.x;
|
|
937
|
-
this._y = quaternion.y;
|
|
938
|
-
this._z = quaternion.z;
|
|
939
|
-
this._w = quaternion.w;
|
|
940
|
-
this._onChangeCallback();
|
|
941
|
-
return this;
|
|
942
|
-
}
|
|
943
|
-
/**
|
|
944
|
-
* Sets this quaternion from the rotation specified by the given
|
|
945
|
-
* Euler angles.
|
|
946
|
-
*
|
|
947
|
-
* @param {Euler} euler - The Euler angles.
|
|
948
|
-
* @param {boolean} [update=true] - Whether the internal `onChange` callback should be executed or not.
|
|
949
|
-
* @return {Quaternion} A reference to this quaternion.
|
|
950
|
-
*/
|
|
951
|
-
setFromEuler(euler, update = true) {
|
|
952
|
-
const x = euler._x, y = euler._y, z = euler._z, order = euler._order;
|
|
953
|
-
const cos = Math.cos;
|
|
954
|
-
const sin = Math.sin;
|
|
955
|
-
const c1 = cos(x / 2);
|
|
956
|
-
const c2 = cos(y / 2);
|
|
957
|
-
const c3 = cos(z / 2);
|
|
958
|
-
const s1 = sin(x / 2);
|
|
959
|
-
const s2 = sin(y / 2);
|
|
960
|
-
const s3 = sin(z / 2);
|
|
961
|
-
switch (order) {
|
|
962
|
-
case "XYZ":
|
|
963
|
-
this._x = s1 * c2 * c3 + c1 * s2 * s3;
|
|
964
|
-
this._y = c1 * s2 * c3 - s1 * c2 * s3;
|
|
965
|
-
this._z = c1 * c2 * s3 + s1 * s2 * c3;
|
|
966
|
-
this._w = c1 * c2 * c3 - s1 * s2 * s3;
|
|
967
|
-
break;
|
|
968
|
-
case "YXZ":
|
|
969
|
-
this._x = s1 * c2 * c3 + c1 * s2 * s3;
|
|
970
|
-
this._y = c1 * s2 * c3 - s1 * c2 * s3;
|
|
971
|
-
this._z = c1 * c2 * s3 - s1 * s2 * c3;
|
|
972
|
-
this._w = c1 * c2 * c3 + s1 * s2 * s3;
|
|
973
|
-
break;
|
|
974
|
-
case "ZXY":
|
|
975
|
-
this._x = s1 * c2 * c3 - c1 * s2 * s3;
|
|
976
|
-
this._y = c1 * s2 * c3 + s1 * c2 * s3;
|
|
977
|
-
this._z = c1 * c2 * s3 + s1 * s2 * c3;
|
|
978
|
-
this._w = c1 * c2 * c3 - s1 * s2 * s3;
|
|
979
|
-
break;
|
|
980
|
-
case "ZYX":
|
|
981
|
-
this._x = s1 * c2 * c3 - c1 * s2 * s3;
|
|
982
|
-
this._y = c1 * s2 * c3 + s1 * c2 * s3;
|
|
983
|
-
this._z = c1 * c2 * s3 - s1 * s2 * c3;
|
|
984
|
-
this._w = c1 * c2 * c3 + s1 * s2 * s3;
|
|
985
|
-
break;
|
|
986
|
-
case "YZX":
|
|
987
|
-
this._x = s1 * c2 * c3 + c1 * s2 * s3;
|
|
988
|
-
this._y = c1 * s2 * c3 + s1 * c2 * s3;
|
|
989
|
-
this._z = c1 * c2 * s3 - s1 * s2 * c3;
|
|
990
|
-
this._w = c1 * c2 * c3 - s1 * s2 * s3;
|
|
991
|
-
break;
|
|
992
|
-
case "XZY":
|
|
993
|
-
this._x = s1 * c2 * c3 - c1 * s2 * s3;
|
|
994
|
-
this._y = c1 * s2 * c3 - s1 * c2 * s3;
|
|
995
|
-
this._z = c1 * c2 * s3 + s1 * s2 * c3;
|
|
996
|
-
this._w = c1 * c2 * c3 + s1 * s2 * s3;
|
|
997
|
-
break;
|
|
998
|
-
default:
|
|
999
|
-
warn("Quaternion: .setFromEuler() encountered an unknown order: " + order);
|
|
1000
|
-
}
|
|
1001
|
-
if (update === true) this._onChangeCallback();
|
|
1002
|
-
return this;
|
|
1003
|
-
}
|
|
1004
|
-
/**
|
|
1005
|
-
* Sets this quaternion from the given axis and angle.
|
|
1006
|
-
*
|
|
1007
|
-
* @param {Vector3} axis - The normalized axis.
|
|
1008
|
-
* @param {number} angle - The angle in radians.
|
|
1009
|
-
* @return {Quaternion} A reference to this quaternion.
|
|
1010
|
-
*/
|
|
1011
|
-
setFromAxisAngle(axis, angle) {
|
|
1012
|
-
const halfAngle = angle / 2, s = Math.sin(halfAngle);
|
|
1013
|
-
this._x = axis.x * s;
|
|
1014
|
-
this._y = axis.y * s;
|
|
1015
|
-
this._z = axis.z * s;
|
|
1016
|
-
this._w = Math.cos(halfAngle);
|
|
1017
|
-
this._onChangeCallback();
|
|
1018
|
-
return this;
|
|
1019
|
-
}
|
|
1020
|
-
/**
|
|
1021
|
-
* Sets this quaternion from the given rotation matrix.
|
|
1022
|
-
*
|
|
1023
|
-
* @param {Matrix4} m - A 4x4 matrix of which the upper 3x3 of matrix is a pure rotation matrix (i.e. unscaled).
|
|
1024
|
-
* @return {Quaternion} A reference to this quaternion.
|
|
1025
|
-
*/
|
|
1026
|
-
setFromRotationMatrix(m) {
|
|
1027
|
-
const te = m.elements, m11 = te[0], m12 = te[4], m13 = te[8], m21 = te[1], m22 = te[5], m23 = te[9], m31 = te[2], m32 = te[6], m33 = te[10], trace = m11 + m22 + m33;
|
|
1028
|
-
if (trace > 0) {
|
|
1029
|
-
const s = 0.5 / Math.sqrt(trace + 1);
|
|
1030
|
-
this._w = 0.25 / s;
|
|
1031
|
-
this._x = (m32 - m23) * s;
|
|
1032
|
-
this._y = (m13 - m31) * s;
|
|
1033
|
-
this._z = (m21 - m12) * s;
|
|
1034
|
-
} else if (m11 > m22 && m11 > m33) {
|
|
1035
|
-
const s = 2 * Math.sqrt(1 + m11 - m22 - m33);
|
|
1036
|
-
this._w = (m32 - m23) / s;
|
|
1037
|
-
this._x = 0.25 * s;
|
|
1038
|
-
this._y = (m12 + m21) / s;
|
|
1039
|
-
this._z = (m13 + m31) / s;
|
|
1040
|
-
} else if (m22 > m33) {
|
|
1041
|
-
const s = 2 * Math.sqrt(1 + m22 - m11 - m33);
|
|
1042
|
-
this._w = (m13 - m31) / s;
|
|
1043
|
-
this._x = (m12 + m21) / s;
|
|
1044
|
-
this._y = 0.25 * s;
|
|
1045
|
-
this._z = (m23 + m32) / s;
|
|
1046
|
-
} else {
|
|
1047
|
-
const s = 2 * Math.sqrt(1 + m33 - m11 - m22);
|
|
1048
|
-
this._w = (m21 - m12) / s;
|
|
1049
|
-
this._x = (m13 + m31) / s;
|
|
1050
|
-
this._y = (m23 + m32) / s;
|
|
1051
|
-
this._z = 0.25 * s;
|
|
1052
|
-
}
|
|
1053
|
-
this._onChangeCallback();
|
|
1054
|
-
return this;
|
|
1055
|
-
}
|
|
1056
|
-
/**
|
|
1057
|
-
* Sets this quaternion to the rotation required to rotate the direction vector
|
|
1058
|
-
* `vFrom` to the direction vector `vTo`.
|
|
1059
|
-
*
|
|
1060
|
-
* @param {Vector3} vFrom - The first (normalized) direction vector.
|
|
1061
|
-
* @param {Vector3} vTo - The second (normalized) direction vector.
|
|
1062
|
-
* @return {Quaternion} A reference to this quaternion.
|
|
1063
|
-
*/
|
|
1064
|
-
setFromUnitVectors(vFrom, vTo) {
|
|
1065
|
-
let r = vFrom.dot(vTo) + 1;
|
|
1066
|
-
if (r < 1e-8) {
|
|
1067
|
-
r = 0;
|
|
1068
|
-
if (Math.abs(vFrom.x) > Math.abs(vFrom.z)) {
|
|
1069
|
-
this._x = -vFrom.y;
|
|
1070
|
-
this._y = vFrom.x;
|
|
1071
|
-
this._z = 0;
|
|
1072
|
-
this._w = r;
|
|
1073
|
-
} else {
|
|
1074
|
-
this._x = 0;
|
|
1075
|
-
this._y = -vFrom.z;
|
|
1076
|
-
this._z = vFrom.y;
|
|
1077
|
-
this._w = r;
|
|
1078
|
-
}
|
|
1079
|
-
} else {
|
|
1080
|
-
this._x = vFrom.y * vTo.z - vFrom.z * vTo.y;
|
|
1081
|
-
this._y = vFrom.z * vTo.x - vFrom.x * vTo.z;
|
|
1082
|
-
this._z = vFrom.x * vTo.y - vFrom.y * vTo.x;
|
|
1083
|
-
this._w = r;
|
|
1084
|
-
}
|
|
1085
|
-
return this.normalize();
|
|
1086
|
-
}
|
|
1087
|
-
/**
|
|
1088
|
-
* Returns the angle between this quaternion and the given one in radians.
|
|
1089
|
-
*
|
|
1090
|
-
* @param {Quaternion} q - The quaternion to compute the angle with.
|
|
1091
|
-
* @return {number} The angle in radians.
|
|
1092
|
-
*/
|
|
1093
|
-
angleTo(q) {
|
|
1094
|
-
return 2 * Math.acos(Math.abs(clamp(this.dot(q), -1, 1)));
|
|
1095
|
-
}
|
|
1096
|
-
/**
|
|
1097
|
-
* Rotates this quaternion by a given angular step to the given quaternion.
|
|
1098
|
-
* The method ensures that the final quaternion will not overshoot `q`.
|
|
1099
|
-
*
|
|
1100
|
-
* @param {Quaternion} q - The target quaternion.
|
|
1101
|
-
* @param {number} step - The angular step in radians.
|
|
1102
|
-
* @return {Quaternion} A reference to this quaternion.
|
|
1103
|
-
*/
|
|
1104
|
-
rotateTowards(q, step) {
|
|
1105
|
-
const angle = this.angleTo(q);
|
|
1106
|
-
if (angle === 0) return this;
|
|
1107
|
-
const t = Math.min(1, step / angle);
|
|
1108
|
-
this.slerp(q, t);
|
|
1109
|
-
return this;
|
|
1110
|
-
}
|
|
1111
|
-
/**
|
|
1112
|
-
* Sets this quaternion to the identity quaternion; that is, to the
|
|
1113
|
-
* quaternion that represents "no rotation".
|
|
1114
|
-
*
|
|
1115
|
-
* @return {Quaternion} A reference to this quaternion.
|
|
1116
|
-
*/
|
|
1117
|
-
identity() {
|
|
1118
|
-
return this.set(0, 0, 0, 1);
|
|
1119
|
-
}
|
|
1120
|
-
/**
|
|
1121
|
-
* Inverts this quaternion via {@link Quaternion#conjugate}. The
|
|
1122
|
-
* quaternion is assumed to have unit length.
|
|
1123
|
-
*
|
|
1124
|
-
* @return {Quaternion} A reference to this quaternion.
|
|
1125
|
-
*/
|
|
1126
|
-
invert() {
|
|
1127
|
-
return this.conjugate();
|
|
1128
|
-
}
|
|
1129
|
-
/**
|
|
1130
|
-
* Returns the rotational conjugate of this quaternion. The conjugate of a
|
|
1131
|
-
* quaternion represents the same rotation in the opposite direction about
|
|
1132
|
-
* the rotational axis.
|
|
1133
|
-
*
|
|
1134
|
-
* @return {Quaternion} A reference to this quaternion.
|
|
1135
|
-
*/
|
|
1136
|
-
conjugate() {
|
|
1137
|
-
this._x *= -1;
|
|
1138
|
-
this._y *= -1;
|
|
1139
|
-
this._z *= -1;
|
|
1140
|
-
this._onChangeCallback();
|
|
1141
|
-
return this;
|
|
1142
|
-
}
|
|
1143
|
-
/**
|
|
1144
|
-
* Calculates the dot product of this quaternion and the given one.
|
|
1145
|
-
*
|
|
1146
|
-
* @param {Quaternion} v - The quaternion to compute the dot product with.
|
|
1147
|
-
* @return {number} The result of the dot product.
|
|
1148
|
-
*/
|
|
1149
|
-
dot(v) {
|
|
1150
|
-
return this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w;
|
|
1151
|
-
}
|
|
1152
|
-
/**
|
|
1153
|
-
* Computes the squared Euclidean length (straight-line length) of this quaternion,
|
|
1154
|
-
* considered as a 4 dimensional vector. This can be useful if you are comparing the
|
|
1155
|
-
* lengths of two quaternions, as this is a slightly more efficient calculation than
|
|
1156
|
-
* {@link Quaternion#length}.
|
|
1157
|
-
*
|
|
1158
|
-
* @return {number} The squared Euclidean length.
|
|
1159
|
-
*/
|
|
1160
|
-
lengthSq() {
|
|
1161
|
-
return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
|
|
1162
|
-
}
|
|
1163
|
-
/**
|
|
1164
|
-
* Computes the Euclidean length (straight-line length) of this quaternion,
|
|
1165
|
-
* considered as a 4 dimensional vector.
|
|
1166
|
-
*
|
|
1167
|
-
* @return {number} The Euclidean length.
|
|
1168
|
-
*/
|
|
1169
|
-
length() {
|
|
1170
|
-
return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w);
|
|
1171
|
-
}
|
|
1172
|
-
/**
|
|
1173
|
-
* Normalizes this quaternion - that is, calculated the quaternion that performs
|
|
1174
|
-
* the same rotation as this one, but has a length equal to `1`.
|
|
1175
|
-
*
|
|
1176
|
-
* @return {Quaternion} A reference to this quaternion.
|
|
1177
|
-
*/
|
|
1178
|
-
normalize() {
|
|
1179
|
-
let l = this.length();
|
|
1180
|
-
if (l === 0) {
|
|
1181
|
-
this._x = 0;
|
|
1182
|
-
this._y = 0;
|
|
1183
|
-
this._z = 0;
|
|
1184
|
-
this._w = 1;
|
|
1185
|
-
} else {
|
|
1186
|
-
l = 1 / l;
|
|
1187
|
-
this._x = this._x * l;
|
|
1188
|
-
this._y = this._y * l;
|
|
1189
|
-
this._z = this._z * l;
|
|
1190
|
-
this._w = this._w * l;
|
|
1191
|
-
}
|
|
1192
|
-
this._onChangeCallback();
|
|
1193
|
-
return this;
|
|
1194
|
-
}
|
|
1195
|
-
/**
|
|
1196
|
-
* Multiplies this quaternion by the given one.
|
|
1197
|
-
*
|
|
1198
|
-
* @param {Quaternion} q - The quaternion.
|
|
1199
|
-
* @return {Quaternion} A reference to this quaternion.
|
|
1200
|
-
*/
|
|
1201
|
-
multiply(q) {
|
|
1202
|
-
return this.multiplyQuaternions(this, q);
|
|
1203
|
-
}
|
|
1204
|
-
/**
|
|
1205
|
-
* Pre-multiplies this quaternion by the given one.
|
|
1206
|
-
*
|
|
1207
|
-
* @param {Quaternion} q - The quaternion.
|
|
1208
|
-
* @return {Quaternion} A reference to this quaternion.
|
|
1209
|
-
*/
|
|
1210
|
-
premultiply(q) {
|
|
1211
|
-
return this.multiplyQuaternions(q, this);
|
|
1212
|
-
}
|
|
1213
|
-
/**
|
|
1214
|
-
* Multiplies the given quaternions and stores the result in this instance.
|
|
1215
|
-
*
|
|
1216
|
-
* @param {Quaternion} a - The first quaternion.
|
|
1217
|
-
* @param {Quaternion} b - The second quaternion.
|
|
1218
|
-
* @return {Quaternion} A reference to this quaternion.
|
|
1219
|
-
*/
|
|
1220
|
-
multiplyQuaternions(a, b) {
|
|
1221
|
-
const qax = a._x, qay = a._y, qaz = a._z, qaw = a._w;
|
|
1222
|
-
const qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w;
|
|
1223
|
-
this._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
|
|
1224
|
-
this._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
|
|
1225
|
-
this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
|
|
1226
|
-
this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
|
|
1227
|
-
this._onChangeCallback();
|
|
1228
|
-
return this;
|
|
1229
|
-
}
|
|
1230
|
-
/**
|
|
1231
|
-
* Performs a spherical linear interpolation between this quaternion and the target quaternion.
|
|
1232
|
-
*
|
|
1233
|
-
* @param {Quaternion} qb - The target quaternion.
|
|
1234
|
-
* @param {number} t - The interpolation factor. A value in the range `[0,1]` will interpolate. A value outside the range `[0,1]` will extrapolate.
|
|
1235
|
-
* @return {Quaternion} A reference to this quaternion.
|
|
1236
|
-
*/
|
|
1237
|
-
slerp(qb, t) {
|
|
1238
|
-
let x = qb._x, y = qb._y, z = qb._z, w = qb._w;
|
|
1239
|
-
let dot = this.dot(qb);
|
|
1240
|
-
if (dot < 0) {
|
|
1241
|
-
x = -x;
|
|
1242
|
-
y = -y;
|
|
1243
|
-
z = -z;
|
|
1244
|
-
w = -w;
|
|
1245
|
-
dot = -dot;
|
|
1246
|
-
}
|
|
1247
|
-
let s = 1 - t;
|
|
1248
|
-
if (dot < 0.9995) {
|
|
1249
|
-
const theta = Math.acos(dot);
|
|
1250
|
-
const sin = Math.sin(theta);
|
|
1251
|
-
s = Math.sin(s * theta) / sin;
|
|
1252
|
-
t = Math.sin(t * theta) / sin;
|
|
1253
|
-
this._x = this._x * s + x * t;
|
|
1254
|
-
this._y = this._y * s + y * t;
|
|
1255
|
-
this._z = this._z * s + z * t;
|
|
1256
|
-
this._w = this._w * s + w * t;
|
|
1257
|
-
this._onChangeCallback();
|
|
1258
|
-
} else {
|
|
1259
|
-
this._x = this._x * s + x * t;
|
|
1260
|
-
this._y = this._y * s + y * t;
|
|
1261
|
-
this._z = this._z * s + z * t;
|
|
1262
|
-
this._w = this._w * s + w * t;
|
|
1263
|
-
this.normalize();
|
|
1264
|
-
}
|
|
1265
|
-
return this;
|
|
1266
|
-
}
|
|
1267
|
-
/**
|
|
1268
|
-
* Performs a spherical linear interpolation between the given quaternions
|
|
1269
|
-
* and stores the result in this quaternion.
|
|
1270
|
-
*
|
|
1271
|
-
* @param {Quaternion} qa - The source quaternion.
|
|
1272
|
-
* @param {Quaternion} qb - The target quaternion.
|
|
1273
|
-
* @param {number} t - The interpolation factor in the closed interval `[0, 1]`.
|
|
1274
|
-
* @return {Quaternion} A reference to this quaternion.
|
|
1275
|
-
*/
|
|
1276
|
-
slerpQuaternions(qa, qb, t) {
|
|
1277
|
-
return this.copy(qa).slerp(qb, t);
|
|
1278
|
-
}
|
|
1279
|
-
/**
|
|
1280
|
-
* Sets this quaternion to a uniformly random, normalized quaternion.
|
|
1281
|
-
*
|
|
1282
|
-
* @return {Quaternion} A reference to this quaternion.
|
|
1283
|
-
*/
|
|
1284
|
-
random() {
|
|
1285
|
-
const theta1 = 2 * Math.PI * Math.random();
|
|
1286
|
-
const theta2 = 2 * Math.PI * Math.random();
|
|
1287
|
-
const x0 = Math.random();
|
|
1288
|
-
const r1 = Math.sqrt(1 - x0);
|
|
1289
|
-
const r2 = Math.sqrt(x0);
|
|
1290
|
-
return this.set(
|
|
1291
|
-
r1 * Math.sin(theta1),
|
|
1292
|
-
r1 * Math.cos(theta1),
|
|
1293
|
-
r2 * Math.sin(theta2),
|
|
1294
|
-
r2 * Math.cos(theta2)
|
|
1295
|
-
);
|
|
1296
|
-
}
|
|
1297
|
-
/**
|
|
1298
|
-
* Returns `true` if this quaternion is equal with the given one.
|
|
1299
|
-
*
|
|
1300
|
-
* @param {Quaternion} quaternion - The quaternion to test for equality.
|
|
1301
|
-
* @return {boolean} Whether this quaternion is equal with the given one.
|
|
1302
|
-
*/
|
|
1303
|
-
equals(quaternion) {
|
|
1304
|
-
return quaternion._x === this._x && quaternion._y === this._y && quaternion._z === this._z && quaternion._w === this._w;
|
|
1305
|
-
}
|
|
1306
|
-
/**
|
|
1307
|
-
* Sets this quaternion's components from the given array.
|
|
1308
|
-
*
|
|
1309
|
-
* @param {Array<number>} array - An array holding the quaternion component values.
|
|
1310
|
-
* @param {number} [offset=0] - The offset into the array.
|
|
1311
|
-
* @return {Quaternion} A reference to this quaternion.
|
|
1312
|
-
*/
|
|
1313
|
-
fromArray(array, offset = 0) {
|
|
1314
|
-
this._x = array[offset];
|
|
1315
|
-
this._y = array[offset + 1];
|
|
1316
|
-
this._z = array[offset + 2];
|
|
1317
|
-
this._w = array[offset + 3];
|
|
1318
|
-
this._onChangeCallback();
|
|
1319
|
-
return this;
|
|
1320
|
-
}
|
|
1321
|
-
/**
|
|
1322
|
-
* Writes the components of this quaternion to the given array. If no array is provided,
|
|
1323
|
-
* the method returns a new instance.
|
|
1324
|
-
*
|
|
1325
|
-
* @param {Array<number>} [array=[]] - The target array holding the quaternion components.
|
|
1326
|
-
* @param {number} [offset=0] - Index of the first element in the array.
|
|
1327
|
-
* @return {Array<number>} The quaternion components.
|
|
1328
|
-
*/
|
|
1329
|
-
toArray(array = [], offset = 0) {
|
|
1330
|
-
array[offset] = this._x;
|
|
1331
|
-
array[offset + 1] = this._y;
|
|
1332
|
-
array[offset + 2] = this._z;
|
|
1333
|
-
array[offset + 3] = this._w;
|
|
1334
|
-
return array;
|
|
1335
|
-
}
|
|
1336
|
-
/**
|
|
1337
|
-
* Sets the components of this quaternion from the given buffer attribute.
|
|
1338
|
-
*
|
|
1339
|
-
* @param {BufferAttribute} attribute - The buffer attribute holding quaternion data.
|
|
1340
|
-
* @param {number} index - The index into the attribute.
|
|
1341
|
-
* @return {Quaternion} A reference to this quaternion.
|
|
1342
|
-
*/
|
|
1343
|
-
fromBufferAttribute(attribute, index) {
|
|
1344
|
-
this._x = attribute.getX(index);
|
|
1345
|
-
this._y = attribute.getY(index);
|
|
1346
|
-
this._z = attribute.getZ(index);
|
|
1347
|
-
this._w = attribute.getW(index);
|
|
1348
|
-
this._onChangeCallback();
|
|
1349
|
-
return this;
|
|
1350
|
-
}
|
|
1351
|
-
/**
|
|
1352
|
-
* This methods defines the serialization result of this class. Returns the
|
|
1353
|
-
* numerical elements of this quaternion in an array of format `[x, y, z, w]`.
|
|
1354
|
-
*
|
|
1355
|
-
* @return {Array<number>} The serialized quaternion.
|
|
1356
|
-
*/
|
|
1357
|
-
toJSON() {
|
|
1358
|
-
return this.toArray();
|
|
1359
|
-
}
|
|
1360
|
-
_onChange(callback) {
|
|
1361
|
-
this._onChangeCallback = callback;
|
|
1362
|
-
return this;
|
|
1363
|
-
}
|
|
1364
|
-
_onChangeCallback() {
|
|
1365
|
-
}
|
|
1366
|
-
*[Symbol.iterator]() {
|
|
1367
|
-
yield this._x;
|
|
1368
|
-
yield this._y;
|
|
1369
|
-
yield this._z;
|
|
1370
|
-
yield this._w;
|
|
1371
|
-
}
|
|
1372
|
-
};
|
|
1373
|
-
|
|
1374
|
-
// ../../node_modules/.pnpm/three@0.183.2/node_modules/three/src/math/Vector3.js
|
|
1375
|
-
var Vector3 = class _Vector3 {
|
|
1376
|
-
/**
|
|
1377
|
-
* Constructs a new 3D vector.
|
|
1378
|
-
*
|
|
1379
|
-
* @param {number} [x=0] - The x value of this vector.
|
|
1380
|
-
* @param {number} [y=0] - The y value of this vector.
|
|
1381
|
-
* @param {number} [z=0] - The z value of this vector.
|
|
1382
|
-
*/
|
|
1383
|
-
constructor(x = 0, y = 0, z = 0) {
|
|
1384
|
-
_Vector3.prototype.isVector3 = true;
|
|
1385
|
-
this.x = x;
|
|
1386
|
-
this.y = y;
|
|
1387
|
-
this.z = z;
|
|
1388
|
-
}
|
|
1389
|
-
/**
|
|
1390
|
-
* Sets the vector components.
|
|
1391
|
-
*
|
|
1392
|
-
* @param {number} x - The value of the x component.
|
|
1393
|
-
* @param {number} y - The value of the y component.
|
|
1394
|
-
* @param {number} z - The value of the z component.
|
|
1395
|
-
* @return {Vector3} A reference to this vector.
|
|
1396
|
-
*/
|
|
1397
|
-
set(x, y, z) {
|
|
1398
|
-
if (z === void 0) z = this.z;
|
|
1399
|
-
this.x = x;
|
|
1400
|
-
this.y = y;
|
|
1401
|
-
this.z = z;
|
|
1402
|
-
return this;
|
|
1403
|
-
}
|
|
1404
|
-
/**
|
|
1405
|
-
* Sets the vector components to the same value.
|
|
1406
|
-
*
|
|
1407
|
-
* @param {number} scalar - The value to set for all vector components.
|
|
1408
|
-
* @return {Vector3} A reference to this vector.
|
|
1409
|
-
*/
|
|
1410
|
-
setScalar(scalar) {
|
|
1411
|
-
this.x = scalar;
|
|
1412
|
-
this.y = scalar;
|
|
1413
|
-
this.z = scalar;
|
|
1414
|
-
return this;
|
|
1415
|
-
}
|
|
1416
|
-
/**
|
|
1417
|
-
* Sets the vector's x component to the given value.
|
|
1418
|
-
*
|
|
1419
|
-
* @param {number} x - The value to set.
|
|
1420
|
-
* @return {Vector3} A reference to this vector.
|
|
1421
|
-
*/
|
|
1422
|
-
setX(x) {
|
|
1423
|
-
this.x = x;
|
|
1424
|
-
return this;
|
|
1425
|
-
}
|
|
1426
|
-
/**
|
|
1427
|
-
* Sets the vector's y component to the given value.
|
|
1428
|
-
*
|
|
1429
|
-
* @param {number} y - The value to set.
|
|
1430
|
-
* @return {Vector3} A reference to this vector.
|
|
1431
|
-
*/
|
|
1432
|
-
setY(y) {
|
|
1433
|
-
this.y = y;
|
|
1434
|
-
return this;
|
|
1435
|
-
}
|
|
1436
|
-
/**
|
|
1437
|
-
* Sets the vector's z component to the given value.
|
|
1438
|
-
*
|
|
1439
|
-
* @param {number} z - The value to set.
|
|
1440
|
-
* @return {Vector3} A reference to this vector.
|
|
1441
|
-
*/
|
|
1442
|
-
setZ(z) {
|
|
1443
|
-
this.z = z;
|
|
1444
|
-
return this;
|
|
1445
|
-
}
|
|
1446
|
-
/**
|
|
1447
|
-
* Allows to set a vector component with an index.
|
|
1448
|
-
*
|
|
1449
|
-
* @param {number} index - The component index. `0` equals to x, `1` equals to y, `2` equals to z.
|
|
1450
|
-
* @param {number} value - The value to set.
|
|
1451
|
-
* @return {Vector3} A reference to this vector.
|
|
1452
|
-
*/
|
|
1453
|
-
setComponent(index, value) {
|
|
1454
|
-
switch (index) {
|
|
1455
|
-
case 0:
|
|
1456
|
-
this.x = value;
|
|
1457
|
-
break;
|
|
1458
|
-
case 1:
|
|
1459
|
-
this.y = value;
|
|
1460
|
-
break;
|
|
1461
|
-
case 2:
|
|
1462
|
-
this.z = value;
|
|
1463
|
-
break;
|
|
1464
|
-
default:
|
|
1465
|
-
throw new Error("index is out of range: " + index);
|
|
1466
|
-
}
|
|
1467
|
-
return this;
|
|
1468
|
-
}
|
|
1469
|
-
/**
|
|
1470
|
-
* Returns the value of the vector component which matches the given index.
|
|
1471
|
-
*
|
|
1472
|
-
* @param {number} index - The component index. `0` equals to x, `1` equals to y, `2` equals to z.
|
|
1473
|
-
* @return {number} A vector component value.
|
|
1474
|
-
*/
|
|
1475
|
-
getComponent(index) {
|
|
1476
|
-
switch (index) {
|
|
1477
|
-
case 0:
|
|
1478
|
-
return this.x;
|
|
1479
|
-
case 1:
|
|
1480
|
-
return this.y;
|
|
1481
|
-
case 2:
|
|
1482
|
-
return this.z;
|
|
1483
|
-
default:
|
|
1484
|
-
throw new Error("index is out of range: " + index);
|
|
1485
|
-
}
|
|
1486
|
-
}
|
|
1487
|
-
/**
|
|
1488
|
-
* Returns a new vector with copied values from this instance.
|
|
1489
|
-
*
|
|
1490
|
-
* @return {Vector3} A clone of this instance.
|
|
1491
|
-
*/
|
|
1492
|
-
clone() {
|
|
1493
|
-
return new this.constructor(this.x, this.y, this.z);
|
|
1494
|
-
}
|
|
1495
|
-
/**
|
|
1496
|
-
* Copies the values of the given vector to this instance.
|
|
1497
|
-
*
|
|
1498
|
-
* @param {Vector3} v - The vector to copy.
|
|
1499
|
-
* @return {Vector3} A reference to this vector.
|
|
1500
|
-
*/
|
|
1501
|
-
copy(v) {
|
|
1502
|
-
this.x = v.x;
|
|
1503
|
-
this.y = v.y;
|
|
1504
|
-
this.z = v.z;
|
|
1505
|
-
return this;
|
|
1506
|
-
}
|
|
1507
|
-
/**
|
|
1508
|
-
* Adds the given vector to this instance.
|
|
1509
|
-
*
|
|
1510
|
-
* @param {Vector3} v - The vector to add.
|
|
1511
|
-
* @return {Vector3} A reference to this vector.
|
|
1512
|
-
*/
|
|
1513
|
-
add(v) {
|
|
1514
|
-
this.x += v.x;
|
|
1515
|
-
this.y += v.y;
|
|
1516
|
-
this.z += v.z;
|
|
1517
|
-
return this;
|
|
1518
|
-
}
|
|
1519
|
-
/**
|
|
1520
|
-
* Adds the given scalar value to all components of this instance.
|
|
1521
|
-
*
|
|
1522
|
-
* @param {number} s - The scalar to add.
|
|
1523
|
-
* @return {Vector3} A reference to this vector.
|
|
1524
|
-
*/
|
|
1525
|
-
addScalar(s) {
|
|
1526
|
-
this.x += s;
|
|
1527
|
-
this.y += s;
|
|
1528
|
-
this.z += s;
|
|
1529
|
-
return this;
|
|
1530
|
-
}
|
|
1531
|
-
/**
|
|
1532
|
-
* Adds the given vectors and stores the result in this instance.
|
|
1533
|
-
*
|
|
1534
|
-
* @param {Vector3} a - The first vector.
|
|
1535
|
-
* @param {Vector3} b - The second vector.
|
|
1536
|
-
* @return {Vector3} A reference to this vector.
|
|
1537
|
-
*/
|
|
1538
|
-
addVectors(a, b) {
|
|
1539
|
-
this.x = a.x + b.x;
|
|
1540
|
-
this.y = a.y + b.y;
|
|
1541
|
-
this.z = a.z + b.z;
|
|
1542
|
-
return this;
|
|
1543
|
-
}
|
|
1544
|
-
/**
|
|
1545
|
-
* Adds the given vector scaled by the given factor to this instance.
|
|
1546
|
-
*
|
|
1547
|
-
* @param {Vector3|Vector4} v - The vector.
|
|
1548
|
-
* @param {number} s - The factor that scales `v`.
|
|
1549
|
-
* @return {Vector3} A reference to this vector.
|
|
1550
|
-
*/
|
|
1551
|
-
addScaledVector(v, s) {
|
|
1552
|
-
this.x += v.x * s;
|
|
1553
|
-
this.y += v.y * s;
|
|
1554
|
-
this.z += v.z * s;
|
|
1555
|
-
return this;
|
|
1556
|
-
}
|
|
1557
|
-
/**
|
|
1558
|
-
* Subtracts the given vector from this instance.
|
|
1559
|
-
*
|
|
1560
|
-
* @param {Vector3} v - The vector to subtract.
|
|
1561
|
-
* @return {Vector3} A reference to this vector.
|
|
1562
|
-
*/
|
|
1563
|
-
sub(v) {
|
|
1564
|
-
this.x -= v.x;
|
|
1565
|
-
this.y -= v.y;
|
|
1566
|
-
this.z -= v.z;
|
|
1567
|
-
return this;
|
|
1568
|
-
}
|
|
1569
|
-
/**
|
|
1570
|
-
* Subtracts the given scalar value from all components of this instance.
|
|
1571
|
-
*
|
|
1572
|
-
* @param {number} s - The scalar to subtract.
|
|
1573
|
-
* @return {Vector3} A reference to this vector.
|
|
1574
|
-
*/
|
|
1575
|
-
subScalar(s) {
|
|
1576
|
-
this.x -= s;
|
|
1577
|
-
this.y -= s;
|
|
1578
|
-
this.z -= s;
|
|
1579
|
-
return this;
|
|
1580
|
-
}
|
|
1581
|
-
/**
|
|
1582
|
-
* Subtracts the given vectors and stores the result in this instance.
|
|
1583
|
-
*
|
|
1584
|
-
* @param {Vector3} a - The first vector.
|
|
1585
|
-
* @param {Vector3} b - The second vector.
|
|
1586
|
-
* @return {Vector3} A reference to this vector.
|
|
1587
|
-
*/
|
|
1588
|
-
subVectors(a, b) {
|
|
1589
|
-
this.x = a.x - b.x;
|
|
1590
|
-
this.y = a.y - b.y;
|
|
1591
|
-
this.z = a.z - b.z;
|
|
1592
|
-
return this;
|
|
1593
|
-
}
|
|
1594
|
-
/**
|
|
1595
|
-
* Multiplies the given vector with this instance.
|
|
1596
|
-
*
|
|
1597
|
-
* @param {Vector3} v - The vector to multiply.
|
|
1598
|
-
* @return {Vector3} A reference to this vector.
|
|
1599
|
-
*/
|
|
1600
|
-
multiply(v) {
|
|
1601
|
-
this.x *= v.x;
|
|
1602
|
-
this.y *= v.y;
|
|
1603
|
-
this.z *= v.z;
|
|
1604
|
-
return this;
|
|
1605
|
-
}
|
|
1606
|
-
/**
|
|
1607
|
-
* Multiplies the given scalar value with all components of this instance.
|
|
1608
|
-
*
|
|
1609
|
-
* @param {number} scalar - The scalar to multiply.
|
|
1610
|
-
* @return {Vector3} A reference to this vector.
|
|
1611
|
-
*/
|
|
1612
|
-
multiplyScalar(scalar) {
|
|
1613
|
-
this.x *= scalar;
|
|
1614
|
-
this.y *= scalar;
|
|
1615
|
-
this.z *= scalar;
|
|
1616
|
-
return this;
|
|
1617
|
-
}
|
|
1618
|
-
/**
|
|
1619
|
-
* Multiplies the given vectors and stores the result in this instance.
|
|
1620
|
-
*
|
|
1621
|
-
* @param {Vector3} a - The first vector.
|
|
1622
|
-
* @param {Vector3} b - The second vector.
|
|
1623
|
-
* @return {Vector3} A reference to this vector.
|
|
1624
|
-
*/
|
|
1625
|
-
multiplyVectors(a, b) {
|
|
1626
|
-
this.x = a.x * b.x;
|
|
1627
|
-
this.y = a.y * b.y;
|
|
1628
|
-
this.z = a.z * b.z;
|
|
1629
|
-
return this;
|
|
1630
|
-
}
|
|
1631
|
-
/**
|
|
1632
|
-
* Applies the given Euler rotation to this vector.
|
|
1633
|
-
*
|
|
1634
|
-
* @param {Euler} euler - The Euler angles.
|
|
1635
|
-
* @return {Vector3} A reference to this vector.
|
|
1636
|
-
*/
|
|
1637
|
-
applyEuler(euler) {
|
|
1638
|
-
return this.applyQuaternion(_quaternion.setFromEuler(euler));
|
|
1639
|
-
}
|
|
1640
|
-
/**
|
|
1641
|
-
* Applies a rotation specified by an axis and an angle to this vector.
|
|
1642
|
-
*
|
|
1643
|
-
* @param {Vector3} axis - A normalized vector representing the rotation axis.
|
|
1644
|
-
* @param {number} angle - The angle in radians.
|
|
1645
|
-
* @return {Vector3} A reference to this vector.
|
|
1646
|
-
*/
|
|
1647
|
-
applyAxisAngle(axis, angle) {
|
|
1648
|
-
return this.applyQuaternion(_quaternion.setFromAxisAngle(axis, angle));
|
|
1649
|
-
}
|
|
1650
|
-
/**
|
|
1651
|
-
* Multiplies this vector with the given 3x3 matrix.
|
|
1652
|
-
*
|
|
1653
|
-
* @param {Matrix3} m - The 3x3 matrix.
|
|
1654
|
-
* @return {Vector3} A reference to this vector.
|
|
1655
|
-
*/
|
|
1656
|
-
applyMatrix3(m) {
|
|
1657
|
-
const x = this.x, y = this.y, z = this.z;
|
|
1658
|
-
const e = m.elements;
|
|
1659
|
-
this.x = e[0] * x + e[3] * y + e[6] * z;
|
|
1660
|
-
this.y = e[1] * x + e[4] * y + e[7] * z;
|
|
1661
|
-
this.z = e[2] * x + e[5] * y + e[8] * z;
|
|
1662
|
-
return this;
|
|
1663
|
-
}
|
|
1664
|
-
/**
|
|
1665
|
-
* Multiplies this vector by the given normal matrix and normalizes
|
|
1666
|
-
* the result.
|
|
1667
|
-
*
|
|
1668
|
-
* @param {Matrix3} m - The normal matrix.
|
|
1669
|
-
* @return {Vector3} A reference to this vector.
|
|
1670
|
-
*/
|
|
1671
|
-
applyNormalMatrix(m) {
|
|
1672
|
-
return this.applyMatrix3(m).normalize();
|
|
1673
|
-
}
|
|
1674
|
-
/**
|
|
1675
|
-
* Multiplies this vector (with an implicit 1 in the 4th dimension) by m, and
|
|
1676
|
-
* divides by perspective.
|
|
1677
|
-
*
|
|
1678
|
-
* @param {Matrix4} m - The matrix to apply.
|
|
1679
|
-
* @return {Vector3} A reference to this vector.
|
|
1680
|
-
*/
|
|
1681
|
-
applyMatrix4(m) {
|
|
1682
|
-
const x = this.x, y = this.y, z = this.z;
|
|
1683
|
-
const e = m.elements;
|
|
1684
|
-
const w = 1 / (e[3] * x + e[7] * y + e[11] * z + e[15]);
|
|
1685
|
-
this.x = (e[0] * x + e[4] * y + e[8] * z + e[12]) * w;
|
|
1686
|
-
this.y = (e[1] * x + e[5] * y + e[9] * z + e[13]) * w;
|
|
1687
|
-
this.z = (e[2] * x + e[6] * y + e[10] * z + e[14]) * w;
|
|
1688
|
-
return this;
|
|
1689
|
-
}
|
|
1690
|
-
/**
|
|
1691
|
-
* Applies the given Quaternion to this vector.
|
|
1692
|
-
*
|
|
1693
|
-
* @param {Quaternion} q - The Quaternion.
|
|
1694
|
-
* @return {Vector3} A reference to this vector.
|
|
1695
|
-
*/
|
|
1696
|
-
applyQuaternion(q) {
|
|
1697
|
-
const vx = this.x, vy = this.y, vz = this.z;
|
|
1698
|
-
const qx = q.x, qy = q.y, qz = q.z, qw = q.w;
|
|
1699
|
-
const tx = 2 * (qy * vz - qz * vy);
|
|
1700
|
-
const ty = 2 * (qz * vx - qx * vz);
|
|
1701
|
-
const tz = 2 * (qx * vy - qy * vx);
|
|
1702
|
-
this.x = vx + qw * tx + qy * tz - qz * ty;
|
|
1703
|
-
this.y = vy + qw * ty + qz * tx - qx * tz;
|
|
1704
|
-
this.z = vz + qw * tz + qx * ty - qy * tx;
|
|
1705
|
-
return this;
|
|
1706
|
-
}
|
|
1707
|
-
/**
|
|
1708
|
-
* Projects this vector from world space into the camera's normalized
|
|
1709
|
-
* device coordinate (NDC) space.
|
|
1710
|
-
*
|
|
1711
|
-
* @param {Camera} camera - The camera.
|
|
1712
|
-
* @return {Vector3} A reference to this vector.
|
|
1713
|
-
*/
|
|
1714
|
-
project(camera) {
|
|
1715
|
-
return this.applyMatrix4(camera.matrixWorldInverse).applyMatrix4(camera.projectionMatrix);
|
|
1716
|
-
}
|
|
1717
|
-
/**
|
|
1718
|
-
* Unprojects this vector from the camera's normalized device coordinate (NDC)
|
|
1719
|
-
* space into world space.
|
|
1720
|
-
*
|
|
1721
|
-
* @param {Camera} camera - The camera.
|
|
1722
|
-
* @return {Vector3} A reference to this vector.
|
|
1723
|
-
*/
|
|
1724
|
-
unproject(camera) {
|
|
1725
|
-
return this.applyMatrix4(camera.projectionMatrixInverse).applyMatrix4(camera.matrixWorld);
|
|
1726
|
-
}
|
|
1727
|
-
/**
|
|
1728
|
-
* Transforms the direction of this vector by a matrix (the upper left 3 x 3
|
|
1729
|
-
* subset of the given 4x4 matrix and then normalizes the result.
|
|
1730
|
-
*
|
|
1731
|
-
* @param {Matrix4} m - The matrix.
|
|
1732
|
-
* @return {Vector3} A reference to this vector.
|
|
1733
|
-
*/
|
|
1734
|
-
transformDirection(m) {
|
|
1735
|
-
const x = this.x, y = this.y, z = this.z;
|
|
1736
|
-
const e = m.elements;
|
|
1737
|
-
this.x = e[0] * x + e[4] * y + e[8] * z;
|
|
1738
|
-
this.y = e[1] * x + e[5] * y + e[9] * z;
|
|
1739
|
-
this.z = e[2] * x + e[6] * y + e[10] * z;
|
|
1740
|
-
return this.normalize();
|
|
1741
|
-
}
|
|
1742
|
-
/**
|
|
1743
|
-
* Divides this instance by the given vector.
|
|
1744
|
-
*
|
|
1745
|
-
* @param {Vector3} v - The vector to divide.
|
|
1746
|
-
* @return {Vector3} A reference to this vector.
|
|
1747
|
-
*/
|
|
1748
|
-
divide(v) {
|
|
1749
|
-
this.x /= v.x;
|
|
1750
|
-
this.y /= v.y;
|
|
1751
|
-
this.z /= v.z;
|
|
1752
|
-
return this;
|
|
1753
|
-
}
|
|
1754
|
-
/**
|
|
1755
|
-
* Divides this vector by the given scalar.
|
|
1756
|
-
*
|
|
1757
|
-
* @param {number} scalar - The scalar to divide.
|
|
1758
|
-
* @return {Vector3} A reference to this vector.
|
|
1759
|
-
*/
|
|
1760
|
-
divideScalar(scalar) {
|
|
1761
|
-
return this.multiplyScalar(1 / scalar);
|
|
1762
|
-
}
|
|
1763
|
-
/**
|
|
1764
|
-
* If this vector's x, y or z value is greater than the given vector's x, y or z
|
|
1765
|
-
* value, replace that value with the corresponding min value.
|
|
1766
|
-
*
|
|
1767
|
-
* @param {Vector3} v - The vector.
|
|
1768
|
-
* @return {Vector3} A reference to this vector.
|
|
1769
|
-
*/
|
|
1770
|
-
min(v) {
|
|
1771
|
-
this.x = Math.min(this.x, v.x);
|
|
1772
|
-
this.y = Math.min(this.y, v.y);
|
|
1773
|
-
this.z = Math.min(this.z, v.z);
|
|
1774
|
-
return this;
|
|
1775
|
-
}
|
|
1776
|
-
/**
|
|
1777
|
-
* If this vector's x, y or z value is less than the given vector's x, y or z
|
|
1778
|
-
* value, replace that value with the corresponding max value.
|
|
1779
|
-
*
|
|
1780
|
-
* @param {Vector3} v - The vector.
|
|
1781
|
-
* @return {Vector3} A reference to this vector.
|
|
1782
|
-
*/
|
|
1783
|
-
max(v) {
|
|
1784
|
-
this.x = Math.max(this.x, v.x);
|
|
1785
|
-
this.y = Math.max(this.y, v.y);
|
|
1786
|
-
this.z = Math.max(this.z, v.z);
|
|
1787
|
-
return this;
|
|
1788
|
-
}
|
|
1789
|
-
/**
|
|
1790
|
-
* If this vector's x, y or z value is greater than the max vector's x, y or z
|
|
1791
|
-
* value, it is replaced by the corresponding value.
|
|
1792
|
-
* If this vector's x, y or z value is less than the min vector's x, y or z value,
|
|
1793
|
-
* it is replaced by the corresponding value.
|
|
1794
|
-
*
|
|
1795
|
-
* @param {Vector3} min - The minimum x, y and z values.
|
|
1796
|
-
* @param {Vector3} max - The maximum x, y and z values in the desired range.
|
|
1797
|
-
* @return {Vector3} A reference to this vector.
|
|
1798
|
-
*/
|
|
1799
|
-
clamp(min, max) {
|
|
1800
|
-
this.x = clamp(this.x, min.x, max.x);
|
|
1801
|
-
this.y = clamp(this.y, min.y, max.y);
|
|
1802
|
-
this.z = clamp(this.z, min.z, max.z);
|
|
1803
|
-
return this;
|
|
1804
|
-
}
|
|
1805
|
-
/**
|
|
1806
|
-
* If this vector's x, y or z values are greater than the max value, they are
|
|
1807
|
-
* replaced by the max value.
|
|
1808
|
-
* If this vector's x, y or z values are less than the min value, they are
|
|
1809
|
-
* replaced by the min value.
|
|
1810
|
-
*
|
|
1811
|
-
* @param {number} minVal - The minimum value the components will be clamped to.
|
|
1812
|
-
* @param {number} maxVal - The maximum value the components will be clamped to.
|
|
1813
|
-
* @return {Vector3} A reference to this vector.
|
|
1814
|
-
*/
|
|
1815
|
-
clampScalar(minVal, maxVal) {
|
|
1816
|
-
this.x = clamp(this.x, minVal, maxVal);
|
|
1817
|
-
this.y = clamp(this.y, minVal, maxVal);
|
|
1818
|
-
this.z = clamp(this.z, minVal, maxVal);
|
|
1819
|
-
return this;
|
|
1820
|
-
}
|
|
1821
|
-
/**
|
|
1822
|
-
* If this vector's length is greater than the max value, it is replaced by
|
|
1823
|
-
* the max value.
|
|
1824
|
-
* If this vector's length is less than the min value, it is replaced by the
|
|
1825
|
-
* min value.
|
|
1826
|
-
*
|
|
1827
|
-
* @param {number} min - The minimum value the vector length will be clamped to.
|
|
1828
|
-
* @param {number} max - The maximum value the vector length will be clamped to.
|
|
1829
|
-
* @return {Vector3} A reference to this vector.
|
|
1830
|
-
*/
|
|
1831
|
-
clampLength(min, max) {
|
|
1832
|
-
const length = this.length();
|
|
1833
|
-
return this.divideScalar(length || 1).multiplyScalar(clamp(length, min, max));
|
|
1834
|
-
}
|
|
1835
|
-
/**
|
|
1836
|
-
* The components of this vector are rounded down to the nearest integer value.
|
|
1837
|
-
*
|
|
1838
|
-
* @return {Vector3} A reference to this vector.
|
|
1839
|
-
*/
|
|
1840
|
-
floor() {
|
|
1841
|
-
this.x = Math.floor(this.x);
|
|
1842
|
-
this.y = Math.floor(this.y);
|
|
1843
|
-
this.z = Math.floor(this.z);
|
|
1844
|
-
return this;
|
|
1845
|
-
}
|
|
1846
|
-
/**
|
|
1847
|
-
* The components of this vector are rounded up to the nearest integer value.
|
|
1848
|
-
*
|
|
1849
|
-
* @return {Vector3} A reference to this vector.
|
|
1850
|
-
*/
|
|
1851
|
-
ceil() {
|
|
1852
|
-
this.x = Math.ceil(this.x);
|
|
1853
|
-
this.y = Math.ceil(this.y);
|
|
1854
|
-
this.z = Math.ceil(this.z);
|
|
1855
|
-
return this;
|
|
1856
|
-
}
|
|
1857
|
-
/**
|
|
1858
|
-
* The components of this vector are rounded to the nearest integer value
|
|
1859
|
-
*
|
|
1860
|
-
* @return {Vector3} A reference to this vector.
|
|
1861
|
-
*/
|
|
1862
|
-
round() {
|
|
1863
|
-
this.x = Math.round(this.x);
|
|
1864
|
-
this.y = Math.round(this.y);
|
|
1865
|
-
this.z = Math.round(this.z);
|
|
1866
|
-
return this;
|
|
1867
|
-
}
|
|
1868
|
-
/**
|
|
1869
|
-
* The components of this vector are rounded towards zero (up if negative,
|
|
1870
|
-
* down if positive) to an integer value.
|
|
1871
|
-
*
|
|
1872
|
-
* @return {Vector3} A reference to this vector.
|
|
1873
|
-
*/
|
|
1874
|
-
roundToZero() {
|
|
1875
|
-
this.x = Math.trunc(this.x);
|
|
1876
|
-
this.y = Math.trunc(this.y);
|
|
1877
|
-
this.z = Math.trunc(this.z);
|
|
1878
|
-
return this;
|
|
1879
|
-
}
|
|
1880
|
-
/**
|
|
1881
|
-
* Inverts this vector - i.e. sets x = -x, y = -y and z = -z.
|
|
1882
|
-
*
|
|
1883
|
-
* @return {Vector3} A reference to this vector.
|
|
1884
|
-
*/
|
|
1885
|
-
negate() {
|
|
1886
|
-
this.x = -this.x;
|
|
1887
|
-
this.y = -this.y;
|
|
1888
|
-
this.z = -this.z;
|
|
1889
|
-
return this;
|
|
1890
|
-
}
|
|
1891
|
-
/**
|
|
1892
|
-
* Calculates the dot product of the given vector with this instance.
|
|
1893
|
-
*
|
|
1894
|
-
* @param {Vector3} v - The vector to compute the dot product with.
|
|
1895
|
-
* @return {number} The result of the dot product.
|
|
1896
|
-
*/
|
|
1897
|
-
dot(v) {
|
|
1898
|
-
return this.x * v.x + this.y * v.y + this.z * v.z;
|
|
1899
|
-
}
|
|
1900
|
-
/**
|
|
1901
|
-
* Computes the square of the Euclidean length (straight-line length) from
|
|
1902
|
-
* (0, 0, 0) to (x, y, z). If you are comparing the lengths of vectors, you should
|
|
1903
|
-
* compare the length squared instead as it is slightly more efficient to calculate.
|
|
1904
|
-
*
|
|
1905
|
-
* @return {number} The square length of this vector.
|
|
1906
|
-
*/
|
|
1907
|
-
lengthSq() {
|
|
1908
|
-
return this.x * this.x + this.y * this.y + this.z * this.z;
|
|
1909
|
-
}
|
|
1910
|
-
/**
|
|
1911
|
-
* Computes the Euclidean length (straight-line length) from (0, 0, 0) to (x, y, z).
|
|
1912
|
-
*
|
|
1913
|
-
* @return {number} The length of this vector.
|
|
1914
|
-
*/
|
|
1915
|
-
length() {
|
|
1916
|
-
return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
|
|
1917
|
-
}
|
|
1918
|
-
/**
|
|
1919
|
-
* Computes the Manhattan length of this vector.
|
|
1920
|
-
*
|
|
1921
|
-
* @return {number} The length of this vector.
|
|
1922
|
-
*/
|
|
1923
|
-
manhattanLength() {
|
|
1924
|
-
return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z);
|
|
1925
|
-
}
|
|
1926
|
-
/**
|
|
1927
|
-
* Converts this vector to a unit vector - that is, sets it equal to a vector
|
|
1928
|
-
* with the same direction as this one, but with a vector length of `1`.
|
|
1929
|
-
*
|
|
1930
|
-
* @return {Vector3} A reference to this vector.
|
|
1931
|
-
*/
|
|
1932
|
-
normalize() {
|
|
1933
|
-
return this.divideScalar(this.length() || 1);
|
|
1934
|
-
}
|
|
1935
|
-
/**
|
|
1936
|
-
* Sets this vector to a vector with the same direction as this one, but
|
|
1937
|
-
* with the specified length.
|
|
1938
|
-
*
|
|
1939
|
-
* @param {number} length - The new length of this vector.
|
|
1940
|
-
* @return {Vector3} A reference to this vector.
|
|
1941
|
-
*/
|
|
1942
|
-
setLength(length) {
|
|
1943
|
-
return this.normalize().multiplyScalar(length);
|
|
1944
|
-
}
|
|
1945
|
-
/**
|
|
1946
|
-
* Linearly interpolates between the given vector and this instance, where
|
|
1947
|
-
* alpha is the percent distance along the line - alpha = 0 will be this
|
|
1948
|
-
* vector, and alpha = 1 will be the given one.
|
|
1949
|
-
*
|
|
1950
|
-
* @param {Vector3} v - The vector to interpolate towards.
|
|
1951
|
-
* @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.
|
|
1952
|
-
* @return {Vector3} A reference to this vector.
|
|
1953
|
-
*/
|
|
1954
|
-
lerp(v, alpha) {
|
|
1955
|
-
this.x += (v.x - this.x) * alpha;
|
|
1956
|
-
this.y += (v.y - this.y) * alpha;
|
|
1957
|
-
this.z += (v.z - this.z) * alpha;
|
|
1958
|
-
return this;
|
|
1959
|
-
}
|
|
1960
|
-
/**
|
|
1961
|
-
* Linearly interpolates between the given vectors, where alpha is the percent
|
|
1962
|
-
* distance along the line - alpha = 0 will be first vector, and alpha = 1 will
|
|
1963
|
-
* be the second one. The result is stored in this instance.
|
|
1964
|
-
*
|
|
1965
|
-
* @param {Vector3} v1 - The first vector.
|
|
1966
|
-
* @param {Vector3} v2 - The second vector.
|
|
1967
|
-
* @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.
|
|
1968
|
-
* @return {Vector3} A reference to this vector.
|
|
1969
|
-
*/
|
|
1970
|
-
lerpVectors(v1, v2, alpha) {
|
|
1971
|
-
this.x = v1.x + (v2.x - v1.x) * alpha;
|
|
1972
|
-
this.y = v1.y + (v2.y - v1.y) * alpha;
|
|
1973
|
-
this.z = v1.z + (v2.z - v1.z) * alpha;
|
|
1974
|
-
return this;
|
|
1975
|
-
}
|
|
1976
|
-
/**
|
|
1977
|
-
* Calculates the cross product of the given vector with this instance.
|
|
1978
|
-
*
|
|
1979
|
-
* @param {Vector3} v - The vector to compute the cross product with.
|
|
1980
|
-
* @return {Vector3} The result of the cross product.
|
|
1981
|
-
*/
|
|
1982
|
-
cross(v) {
|
|
1983
|
-
return this.crossVectors(this, v);
|
|
1984
|
-
}
|
|
1985
|
-
/**
|
|
1986
|
-
* Calculates the cross product of the given vectors and stores the result
|
|
1987
|
-
* in this instance.
|
|
1988
|
-
*
|
|
1989
|
-
* @param {Vector3} a - The first vector.
|
|
1990
|
-
* @param {Vector3} b - The second vector.
|
|
1991
|
-
* @return {Vector3} A reference to this vector.
|
|
1992
|
-
*/
|
|
1993
|
-
crossVectors(a, b) {
|
|
1994
|
-
const ax = a.x, ay = a.y, az = a.z;
|
|
1995
|
-
const bx = b.x, by = b.y, bz = b.z;
|
|
1996
|
-
this.x = ay * bz - az * by;
|
|
1997
|
-
this.y = az * bx - ax * bz;
|
|
1998
|
-
this.z = ax * by - ay * bx;
|
|
1999
|
-
return this;
|
|
2000
|
-
}
|
|
2001
|
-
/**
|
|
2002
|
-
* Projects this vector onto the given one.
|
|
2003
|
-
*
|
|
2004
|
-
* @param {Vector3} v - The vector to project to.
|
|
2005
|
-
* @return {Vector3} A reference to this vector.
|
|
2006
|
-
*/
|
|
2007
|
-
projectOnVector(v) {
|
|
2008
|
-
const denominator = v.lengthSq();
|
|
2009
|
-
if (denominator === 0) return this.set(0, 0, 0);
|
|
2010
|
-
const scalar = v.dot(this) / denominator;
|
|
2011
|
-
return this.copy(v).multiplyScalar(scalar);
|
|
2012
|
-
}
|
|
2013
|
-
/**
|
|
2014
|
-
* Projects this vector onto a plane by subtracting this
|
|
2015
|
-
* vector projected onto the plane's normal from this vector.
|
|
2016
|
-
*
|
|
2017
|
-
* @param {Vector3} planeNormal - The plane normal.
|
|
2018
|
-
* @return {Vector3} A reference to this vector.
|
|
2019
|
-
*/
|
|
2020
|
-
projectOnPlane(planeNormal) {
|
|
2021
|
-
_vector.copy(this).projectOnVector(planeNormal);
|
|
2022
|
-
return this.sub(_vector);
|
|
2023
|
-
}
|
|
2024
|
-
/**
|
|
2025
|
-
* Reflects this vector off a plane orthogonal to the given normal vector.
|
|
2026
|
-
*
|
|
2027
|
-
* @param {Vector3} normal - The (normalized) normal vector.
|
|
2028
|
-
* @return {Vector3} A reference to this vector.
|
|
2029
|
-
*/
|
|
2030
|
-
reflect(normal) {
|
|
2031
|
-
return this.sub(_vector.copy(normal).multiplyScalar(2 * this.dot(normal)));
|
|
2032
|
-
}
|
|
2033
|
-
/**
|
|
2034
|
-
* Returns the angle between the given vector and this instance in radians.
|
|
2035
|
-
*
|
|
2036
|
-
* @param {Vector3} v - The vector to compute the angle with.
|
|
2037
|
-
* @return {number} The angle in radians.
|
|
2038
|
-
*/
|
|
2039
|
-
angleTo(v) {
|
|
2040
|
-
const denominator = Math.sqrt(this.lengthSq() * v.lengthSq());
|
|
2041
|
-
if (denominator === 0) return Math.PI / 2;
|
|
2042
|
-
const theta = this.dot(v) / denominator;
|
|
2043
|
-
return Math.acos(clamp(theta, -1, 1));
|
|
2044
|
-
}
|
|
2045
|
-
/**
|
|
2046
|
-
* Computes the distance from the given vector to this instance.
|
|
2047
|
-
*
|
|
2048
|
-
* @param {Vector3} v - The vector to compute the distance to.
|
|
2049
|
-
* @return {number} The distance.
|
|
2050
|
-
*/
|
|
2051
|
-
distanceTo(v) {
|
|
2052
|
-
return Math.sqrt(this.distanceToSquared(v));
|
|
2053
|
-
}
|
|
2054
|
-
/**
|
|
2055
|
-
* Computes the squared distance from the given vector to this instance.
|
|
2056
|
-
* If you are just comparing the distance with another distance, you should compare
|
|
2057
|
-
* the distance squared instead as it is slightly more efficient to calculate.
|
|
2058
|
-
*
|
|
2059
|
-
* @param {Vector3} v - The vector to compute the squared distance to.
|
|
2060
|
-
* @return {number} The squared distance.
|
|
2061
|
-
*/
|
|
2062
|
-
distanceToSquared(v) {
|
|
2063
|
-
const dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;
|
|
2064
|
-
return dx * dx + dy * dy + dz * dz;
|
|
2065
|
-
}
|
|
2066
|
-
/**
|
|
2067
|
-
* Computes the Manhattan distance from the given vector to this instance.
|
|
2068
|
-
*
|
|
2069
|
-
* @param {Vector3} v - The vector to compute the Manhattan distance to.
|
|
2070
|
-
* @return {number} The Manhattan distance.
|
|
2071
|
-
*/
|
|
2072
|
-
manhattanDistanceTo(v) {
|
|
2073
|
-
return Math.abs(this.x - v.x) + Math.abs(this.y - v.y) + Math.abs(this.z - v.z);
|
|
2074
|
-
}
|
|
2075
|
-
/**
|
|
2076
|
-
* Sets the vector components from the given spherical coordinates.
|
|
2077
|
-
*
|
|
2078
|
-
* @param {Spherical} s - The spherical coordinates.
|
|
2079
|
-
* @return {Vector3} A reference to this vector.
|
|
2080
|
-
*/
|
|
2081
|
-
setFromSpherical(s) {
|
|
2082
|
-
return this.setFromSphericalCoords(s.radius, s.phi, s.theta);
|
|
2083
|
-
}
|
|
2084
|
-
/**
|
|
2085
|
-
* Sets the vector components from the given spherical coordinates.
|
|
2086
|
-
*
|
|
2087
|
-
* @param {number} radius - The radius.
|
|
2088
|
-
* @param {number} phi - The phi angle in radians.
|
|
2089
|
-
* @param {number} theta - The theta angle in radians.
|
|
2090
|
-
* @return {Vector3} A reference to this vector.
|
|
2091
|
-
*/
|
|
2092
|
-
setFromSphericalCoords(radius, phi, theta) {
|
|
2093
|
-
const sinPhiRadius = Math.sin(phi) * radius;
|
|
2094
|
-
this.x = sinPhiRadius * Math.sin(theta);
|
|
2095
|
-
this.y = Math.cos(phi) * radius;
|
|
2096
|
-
this.z = sinPhiRadius * Math.cos(theta);
|
|
2097
|
-
return this;
|
|
2098
|
-
}
|
|
2099
|
-
/**
|
|
2100
|
-
* Sets the vector components from the given cylindrical coordinates.
|
|
2101
|
-
*
|
|
2102
|
-
* @param {Cylindrical} c - The cylindrical coordinates.
|
|
2103
|
-
* @return {Vector3} A reference to this vector.
|
|
2104
|
-
*/
|
|
2105
|
-
setFromCylindrical(c) {
|
|
2106
|
-
return this.setFromCylindricalCoords(c.radius, c.theta, c.y);
|
|
2107
|
-
}
|
|
2108
|
-
/**
|
|
2109
|
-
* Sets the vector components from the given cylindrical coordinates.
|
|
2110
|
-
*
|
|
2111
|
-
* @param {number} radius - The radius.
|
|
2112
|
-
* @param {number} theta - The theta angle in radians.
|
|
2113
|
-
* @param {number} y - The y value.
|
|
2114
|
-
* @return {Vector3} A reference to this vector.
|
|
2115
|
-
*/
|
|
2116
|
-
setFromCylindricalCoords(radius, theta, y) {
|
|
2117
|
-
this.x = radius * Math.sin(theta);
|
|
2118
|
-
this.y = y;
|
|
2119
|
-
this.z = radius * Math.cos(theta);
|
|
2120
|
-
return this;
|
|
2121
|
-
}
|
|
2122
|
-
/**
|
|
2123
|
-
* Sets the vector components to the position elements of the
|
|
2124
|
-
* given transformation matrix.
|
|
2125
|
-
*
|
|
2126
|
-
* @param {Matrix4} m - The 4x4 matrix.
|
|
2127
|
-
* @return {Vector3} A reference to this vector.
|
|
2128
|
-
*/
|
|
2129
|
-
setFromMatrixPosition(m) {
|
|
2130
|
-
const e = m.elements;
|
|
2131
|
-
this.x = e[12];
|
|
2132
|
-
this.y = e[13];
|
|
2133
|
-
this.z = e[14];
|
|
2134
|
-
return this;
|
|
2135
|
-
}
|
|
2136
|
-
/**
|
|
2137
|
-
* Sets the vector components to the scale elements of the
|
|
2138
|
-
* given transformation matrix.
|
|
2139
|
-
*
|
|
2140
|
-
* @param {Matrix4} m - The 4x4 matrix.
|
|
2141
|
-
* @return {Vector3} A reference to this vector.
|
|
2142
|
-
*/
|
|
2143
|
-
setFromMatrixScale(m) {
|
|
2144
|
-
const sx = this.setFromMatrixColumn(m, 0).length();
|
|
2145
|
-
const sy = this.setFromMatrixColumn(m, 1).length();
|
|
2146
|
-
const sz = this.setFromMatrixColumn(m, 2).length();
|
|
2147
|
-
this.x = sx;
|
|
2148
|
-
this.y = sy;
|
|
2149
|
-
this.z = sz;
|
|
2150
|
-
return this;
|
|
2151
|
-
}
|
|
2152
|
-
/**
|
|
2153
|
-
* Sets the vector components from the specified matrix column.
|
|
2154
|
-
*
|
|
2155
|
-
* @param {Matrix4} m - The 4x4 matrix.
|
|
2156
|
-
* @param {number} index - The column index.
|
|
2157
|
-
* @return {Vector3} A reference to this vector.
|
|
2158
|
-
*/
|
|
2159
|
-
setFromMatrixColumn(m, index) {
|
|
2160
|
-
return this.fromArray(m.elements, index * 4);
|
|
2161
|
-
}
|
|
2162
|
-
/**
|
|
2163
|
-
* Sets the vector components from the specified matrix column.
|
|
2164
|
-
*
|
|
2165
|
-
* @param {Matrix3} m - The 3x3 matrix.
|
|
2166
|
-
* @param {number} index - The column index.
|
|
2167
|
-
* @return {Vector3} A reference to this vector.
|
|
2168
|
-
*/
|
|
2169
|
-
setFromMatrix3Column(m, index) {
|
|
2170
|
-
return this.fromArray(m.elements, index * 3);
|
|
2171
|
-
}
|
|
2172
|
-
/**
|
|
2173
|
-
* Sets the vector components from the given Euler angles.
|
|
2174
|
-
*
|
|
2175
|
-
* @param {Euler} e - The Euler angles to set.
|
|
2176
|
-
* @return {Vector3} A reference to this vector.
|
|
2177
|
-
*/
|
|
2178
|
-
setFromEuler(e) {
|
|
2179
|
-
this.x = e._x;
|
|
2180
|
-
this.y = e._y;
|
|
2181
|
-
this.z = e._z;
|
|
2182
|
-
return this;
|
|
2183
|
-
}
|
|
2184
|
-
/**
|
|
2185
|
-
* Sets the vector components from the RGB components of the
|
|
2186
|
-
* given color.
|
|
2187
|
-
*
|
|
2188
|
-
* @param {Color} c - The color to set.
|
|
2189
|
-
* @return {Vector3} A reference to this vector.
|
|
2190
|
-
*/
|
|
2191
|
-
setFromColor(c) {
|
|
2192
|
-
this.x = c.r;
|
|
2193
|
-
this.y = c.g;
|
|
2194
|
-
this.z = c.b;
|
|
2195
|
-
return this;
|
|
2196
|
-
}
|
|
2197
|
-
/**
|
|
2198
|
-
* Returns `true` if this vector is equal with the given one.
|
|
2199
|
-
*
|
|
2200
|
-
* @param {Vector3} v - The vector to test for equality.
|
|
2201
|
-
* @return {boolean} Whether this vector is equal with the given one.
|
|
2202
|
-
*/
|
|
2203
|
-
equals(v) {
|
|
2204
|
-
return v.x === this.x && v.y === this.y && v.z === this.z;
|
|
2205
|
-
}
|
|
2206
|
-
/**
|
|
2207
|
-
* Sets this vector's x value to be `array[ offset ]`, y value to be `array[ offset + 1 ]`
|
|
2208
|
-
* and z value to be `array[ offset + 2 ]`.
|
|
2209
|
-
*
|
|
2210
|
-
* @param {Array<number>} array - An array holding the vector component values.
|
|
2211
|
-
* @param {number} [offset=0] - The offset into the array.
|
|
2212
|
-
* @return {Vector3} A reference to this vector.
|
|
2213
|
-
*/
|
|
2214
|
-
fromArray(array, offset = 0) {
|
|
2215
|
-
this.x = array[offset];
|
|
2216
|
-
this.y = array[offset + 1];
|
|
2217
|
-
this.z = array[offset + 2];
|
|
2218
|
-
return this;
|
|
2219
|
-
}
|
|
2220
|
-
/**
|
|
2221
|
-
* Writes the components of this vector to the given array. If no array is provided,
|
|
2222
|
-
* the method returns a new instance.
|
|
2223
|
-
*
|
|
2224
|
-
* @param {Array<number>} [array=[]] - The target array holding the vector components.
|
|
2225
|
-
* @param {number} [offset=0] - Index of the first element in the array.
|
|
2226
|
-
* @return {Array<number>} The vector components.
|
|
2227
|
-
*/
|
|
2228
|
-
toArray(array = [], offset = 0) {
|
|
2229
|
-
array[offset] = this.x;
|
|
2230
|
-
array[offset + 1] = this.y;
|
|
2231
|
-
array[offset + 2] = this.z;
|
|
2232
|
-
return array;
|
|
2233
|
-
}
|
|
2234
|
-
/**
|
|
2235
|
-
* Sets the components of this vector from the given buffer attribute.
|
|
2236
|
-
*
|
|
2237
|
-
* @param {BufferAttribute} attribute - The buffer attribute holding vector data.
|
|
2238
|
-
* @param {number} index - The index into the attribute.
|
|
2239
|
-
* @return {Vector3} A reference to this vector.
|
|
2240
|
-
*/
|
|
2241
|
-
fromBufferAttribute(attribute, index) {
|
|
2242
|
-
this.x = attribute.getX(index);
|
|
2243
|
-
this.y = attribute.getY(index);
|
|
2244
|
-
this.z = attribute.getZ(index);
|
|
2245
|
-
return this;
|
|
2246
|
-
}
|
|
2247
|
-
/**
|
|
2248
|
-
* Sets each component of this vector to a pseudo-random value between `0` and
|
|
2249
|
-
* `1`, excluding `1`.
|
|
2250
|
-
*
|
|
2251
|
-
* @return {Vector3} A reference to this vector.
|
|
2252
|
-
*/
|
|
2253
|
-
random() {
|
|
2254
|
-
this.x = Math.random();
|
|
2255
|
-
this.y = Math.random();
|
|
2256
|
-
this.z = Math.random();
|
|
2257
|
-
return this;
|
|
2258
|
-
}
|
|
2259
|
-
/**
|
|
2260
|
-
* Sets this vector to a uniformly random point on a unit sphere.
|
|
2261
|
-
*
|
|
2262
|
-
* @return {Vector3} A reference to this vector.
|
|
2263
|
-
*/
|
|
2264
|
-
randomDirection() {
|
|
2265
|
-
const theta = Math.random() * Math.PI * 2;
|
|
2266
|
-
const u = Math.random() * 2 - 1;
|
|
2267
|
-
const c = Math.sqrt(1 - u * u);
|
|
2268
|
-
this.x = c * Math.cos(theta);
|
|
2269
|
-
this.y = u;
|
|
2270
|
-
this.z = c * Math.sin(theta);
|
|
2271
|
-
return this;
|
|
2272
|
-
}
|
|
2273
|
-
*[Symbol.iterator]() {
|
|
2274
|
-
yield this.x;
|
|
2275
|
-
yield this.y;
|
|
2276
|
-
yield this.z;
|
|
2277
|
-
}
|
|
2278
|
-
};
|
|
2279
|
-
var _vector = /* @__PURE__ */ new Vector3();
|
|
2280
|
-
var _quaternion = /* @__PURE__ */ new Quaternion();
|
|
2281
|
-
|
|
2282
|
-
// ../../node_modules/.pnpm/three@0.183.2/node_modules/three/src/math/Matrix3.js
|
|
2283
|
-
var Matrix3 = class _Matrix3 {
|
|
2284
|
-
/**
|
|
2285
|
-
* Constructs a new 3x3 matrix. The arguments are supposed to be
|
|
2286
|
-
* in row-major order. If no arguments are provided, the constructor
|
|
2287
|
-
* initializes the matrix as an identity matrix.
|
|
2288
|
-
*
|
|
2289
|
-
* @param {number} [n11] - 1-1 matrix element.
|
|
2290
|
-
* @param {number} [n12] - 1-2 matrix element.
|
|
2291
|
-
* @param {number} [n13] - 1-3 matrix element.
|
|
2292
|
-
* @param {number} [n21] - 2-1 matrix element.
|
|
2293
|
-
* @param {number} [n22] - 2-2 matrix element.
|
|
2294
|
-
* @param {number} [n23] - 2-3 matrix element.
|
|
2295
|
-
* @param {number} [n31] - 3-1 matrix element.
|
|
2296
|
-
* @param {number} [n32] - 3-2 matrix element.
|
|
2297
|
-
* @param {number} [n33] - 3-3 matrix element.
|
|
2298
|
-
*/
|
|
2299
|
-
constructor(n11, n12, n13, n21, n22, n23, n31, n32, n33) {
|
|
2300
|
-
_Matrix3.prototype.isMatrix3 = true;
|
|
2301
|
-
this.elements = [
|
|
2302
|
-
1,
|
|
2303
|
-
0,
|
|
2304
|
-
0,
|
|
2305
|
-
0,
|
|
2306
|
-
1,
|
|
2307
|
-
0,
|
|
2308
|
-
0,
|
|
2309
|
-
0,
|
|
2310
|
-
1
|
|
2311
|
-
];
|
|
2312
|
-
if (n11 !== void 0) {
|
|
2313
|
-
this.set(n11, n12, n13, n21, n22, n23, n31, n32, n33);
|
|
2314
|
-
}
|
|
2315
|
-
}
|
|
2316
|
-
/**
|
|
2317
|
-
* Sets the elements of the matrix.The arguments are supposed to be
|
|
2318
|
-
* in row-major order.
|
|
2319
|
-
*
|
|
2320
|
-
* @param {number} [n11] - 1-1 matrix element.
|
|
2321
|
-
* @param {number} [n12] - 1-2 matrix element.
|
|
2322
|
-
* @param {number} [n13] - 1-3 matrix element.
|
|
2323
|
-
* @param {number} [n21] - 2-1 matrix element.
|
|
2324
|
-
* @param {number} [n22] - 2-2 matrix element.
|
|
2325
|
-
* @param {number} [n23] - 2-3 matrix element.
|
|
2326
|
-
* @param {number} [n31] - 3-1 matrix element.
|
|
2327
|
-
* @param {number} [n32] - 3-2 matrix element.
|
|
2328
|
-
* @param {number} [n33] - 3-3 matrix element.
|
|
2329
|
-
* @return {Matrix3} A reference to this matrix.
|
|
2330
|
-
*/
|
|
2331
|
-
set(n11, n12, n13, n21, n22, n23, n31, n32, n33) {
|
|
2332
|
-
const te = this.elements;
|
|
2333
|
-
te[0] = n11;
|
|
2334
|
-
te[1] = n21;
|
|
2335
|
-
te[2] = n31;
|
|
2336
|
-
te[3] = n12;
|
|
2337
|
-
te[4] = n22;
|
|
2338
|
-
te[5] = n32;
|
|
2339
|
-
te[6] = n13;
|
|
2340
|
-
te[7] = n23;
|
|
2341
|
-
te[8] = n33;
|
|
2342
|
-
return this;
|
|
2343
|
-
}
|
|
2344
|
-
/**
|
|
2345
|
-
* Sets this matrix to the 3x3 identity matrix.
|
|
2346
|
-
*
|
|
2347
|
-
* @return {Matrix3} A reference to this matrix.
|
|
2348
|
-
*/
|
|
2349
|
-
identity() {
|
|
2350
|
-
this.set(
|
|
2351
|
-
1,
|
|
2352
|
-
0,
|
|
2353
|
-
0,
|
|
2354
|
-
0,
|
|
2355
|
-
1,
|
|
2356
|
-
0,
|
|
2357
|
-
0,
|
|
2358
|
-
0,
|
|
2359
|
-
1
|
|
2360
|
-
);
|
|
2361
|
-
return this;
|
|
2362
|
-
}
|
|
2363
|
-
/**
|
|
2364
|
-
* Copies the values of the given matrix to this instance.
|
|
2365
|
-
*
|
|
2366
|
-
* @param {Matrix3} m - The matrix to copy.
|
|
2367
|
-
* @return {Matrix3} A reference to this matrix.
|
|
2368
|
-
*/
|
|
2369
|
-
copy(m) {
|
|
2370
|
-
const te = this.elements;
|
|
2371
|
-
const me = m.elements;
|
|
2372
|
-
te[0] = me[0];
|
|
2373
|
-
te[1] = me[1];
|
|
2374
|
-
te[2] = me[2];
|
|
2375
|
-
te[3] = me[3];
|
|
2376
|
-
te[4] = me[4];
|
|
2377
|
-
te[5] = me[5];
|
|
2378
|
-
te[6] = me[6];
|
|
2379
|
-
te[7] = me[7];
|
|
2380
|
-
te[8] = me[8];
|
|
2381
|
-
return this;
|
|
2382
|
-
}
|
|
2383
|
-
/**
|
|
2384
|
-
* Extracts the basis of this matrix into the three axis vectors provided.
|
|
2385
|
-
*
|
|
2386
|
-
* @param {Vector3} xAxis - The basis's x axis.
|
|
2387
|
-
* @param {Vector3} yAxis - The basis's y axis.
|
|
2388
|
-
* @param {Vector3} zAxis - The basis's z axis.
|
|
2389
|
-
* @return {Matrix3} A reference to this matrix.
|
|
2390
|
-
*/
|
|
2391
|
-
extractBasis(xAxis, yAxis, zAxis) {
|
|
2392
|
-
xAxis.setFromMatrix3Column(this, 0);
|
|
2393
|
-
yAxis.setFromMatrix3Column(this, 1);
|
|
2394
|
-
zAxis.setFromMatrix3Column(this, 2);
|
|
2395
|
-
return this;
|
|
2396
|
-
}
|
|
2397
|
-
/**
|
|
2398
|
-
* Set this matrix to the upper 3x3 matrix of the given 4x4 matrix.
|
|
2399
|
-
*
|
|
2400
|
-
* @param {Matrix4} m - The 4x4 matrix.
|
|
2401
|
-
* @return {Matrix3} A reference to this matrix.
|
|
2402
|
-
*/
|
|
2403
|
-
setFromMatrix4(m) {
|
|
2404
|
-
const me = m.elements;
|
|
2405
|
-
this.set(
|
|
2406
|
-
me[0],
|
|
2407
|
-
me[4],
|
|
2408
|
-
me[8],
|
|
2409
|
-
me[1],
|
|
2410
|
-
me[5],
|
|
2411
|
-
me[9],
|
|
2412
|
-
me[2],
|
|
2413
|
-
me[6],
|
|
2414
|
-
me[10]
|
|
2415
|
-
);
|
|
2416
|
-
return this;
|
|
2417
|
-
}
|
|
2418
|
-
/**
|
|
2419
|
-
* Post-multiplies this matrix by the given 3x3 matrix.
|
|
2420
|
-
*
|
|
2421
|
-
* @param {Matrix3} m - The matrix to multiply with.
|
|
2422
|
-
* @return {Matrix3} A reference to this matrix.
|
|
2423
|
-
*/
|
|
2424
|
-
multiply(m) {
|
|
2425
|
-
return this.multiplyMatrices(this, m);
|
|
2426
|
-
}
|
|
2427
|
-
/**
|
|
2428
|
-
* Pre-multiplies this matrix by the given 3x3 matrix.
|
|
2429
|
-
*
|
|
2430
|
-
* @param {Matrix3} m - The matrix to multiply with.
|
|
2431
|
-
* @return {Matrix3} A reference to this matrix.
|
|
2432
|
-
*/
|
|
2433
|
-
premultiply(m) {
|
|
2434
|
-
return this.multiplyMatrices(m, this);
|
|
2435
|
-
}
|
|
2436
|
-
/**
|
|
2437
|
-
* Multiples the given 3x3 matrices and stores the result
|
|
2438
|
-
* in this matrix.
|
|
2439
|
-
*
|
|
2440
|
-
* @param {Matrix3} a - The first matrix.
|
|
2441
|
-
* @param {Matrix3} b - The second matrix.
|
|
2442
|
-
* @return {Matrix3} A reference to this matrix.
|
|
2443
|
-
*/
|
|
2444
|
-
multiplyMatrices(a, b) {
|
|
2445
|
-
const ae = a.elements;
|
|
2446
|
-
const be = b.elements;
|
|
2447
|
-
const te = this.elements;
|
|
2448
|
-
const a11 = ae[0], a12 = ae[3], a13 = ae[6];
|
|
2449
|
-
const a21 = ae[1], a22 = ae[4], a23 = ae[7];
|
|
2450
|
-
const a31 = ae[2], a32 = ae[5], a33 = ae[8];
|
|
2451
|
-
const b11 = be[0], b12 = be[3], b13 = be[6];
|
|
2452
|
-
const b21 = be[1], b22 = be[4], b23 = be[7];
|
|
2453
|
-
const b31 = be[2], b32 = be[5], b33 = be[8];
|
|
2454
|
-
te[0] = a11 * b11 + a12 * b21 + a13 * b31;
|
|
2455
|
-
te[3] = a11 * b12 + a12 * b22 + a13 * b32;
|
|
2456
|
-
te[6] = a11 * b13 + a12 * b23 + a13 * b33;
|
|
2457
|
-
te[1] = a21 * b11 + a22 * b21 + a23 * b31;
|
|
2458
|
-
te[4] = a21 * b12 + a22 * b22 + a23 * b32;
|
|
2459
|
-
te[7] = a21 * b13 + a22 * b23 + a23 * b33;
|
|
2460
|
-
te[2] = a31 * b11 + a32 * b21 + a33 * b31;
|
|
2461
|
-
te[5] = a31 * b12 + a32 * b22 + a33 * b32;
|
|
2462
|
-
te[8] = a31 * b13 + a32 * b23 + a33 * b33;
|
|
2463
|
-
return this;
|
|
2464
|
-
}
|
|
2465
|
-
/**
|
|
2466
|
-
* Multiplies every component of the matrix by the given scalar.
|
|
2467
|
-
*
|
|
2468
|
-
* @param {number} s - The scalar.
|
|
2469
|
-
* @return {Matrix3} A reference to this matrix.
|
|
2470
|
-
*/
|
|
2471
|
-
multiplyScalar(s) {
|
|
2472
|
-
const te = this.elements;
|
|
2473
|
-
te[0] *= s;
|
|
2474
|
-
te[3] *= s;
|
|
2475
|
-
te[6] *= s;
|
|
2476
|
-
te[1] *= s;
|
|
2477
|
-
te[4] *= s;
|
|
2478
|
-
te[7] *= s;
|
|
2479
|
-
te[2] *= s;
|
|
2480
|
-
te[5] *= s;
|
|
2481
|
-
te[8] *= s;
|
|
2482
|
-
return this;
|
|
2483
|
-
}
|
|
2484
|
-
/**
|
|
2485
|
-
* Computes and returns the determinant of this matrix.
|
|
2486
|
-
*
|
|
2487
|
-
* @return {number} The determinant.
|
|
2488
|
-
*/
|
|
2489
|
-
determinant() {
|
|
2490
|
-
const te = this.elements;
|
|
2491
|
-
const a = te[0], b = te[1], c = te[2], d = te[3], e = te[4], f = te[5], g = te[6], h = te[7], i = te[8];
|
|
2492
|
-
return a * e * i - a * f * h - b * d * i + b * f * g + c * d * h - c * e * g;
|
|
2493
|
-
}
|
|
2494
|
-
/**
|
|
2495
|
-
* Inverts this matrix, using the [analytic method](https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution).
|
|
2496
|
-
* You can not invert with a determinant of zero. If you attempt this, the method produces
|
|
2497
|
-
* a zero matrix instead.
|
|
2498
|
-
*
|
|
2499
|
-
* @return {Matrix3} A reference to this matrix.
|
|
2500
|
-
*/
|
|
2501
|
-
invert() {
|
|
2502
|
-
const te = this.elements, n11 = te[0], n21 = te[1], n31 = te[2], n12 = te[3], n22 = te[4], n32 = te[5], n13 = te[6], n23 = te[7], n33 = te[8], t11 = n33 * n22 - n32 * n23, t12 = n32 * n13 - n33 * n12, t13 = n23 * n12 - n22 * n13, det = n11 * t11 + n21 * t12 + n31 * t13;
|
|
2503
|
-
if (det === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
2504
|
-
const detInv = 1 / det;
|
|
2505
|
-
te[0] = t11 * detInv;
|
|
2506
|
-
te[1] = (n31 * n23 - n33 * n21) * detInv;
|
|
2507
|
-
te[2] = (n32 * n21 - n31 * n22) * detInv;
|
|
2508
|
-
te[3] = t12 * detInv;
|
|
2509
|
-
te[4] = (n33 * n11 - n31 * n13) * detInv;
|
|
2510
|
-
te[5] = (n31 * n12 - n32 * n11) * detInv;
|
|
2511
|
-
te[6] = t13 * detInv;
|
|
2512
|
-
te[7] = (n21 * n13 - n23 * n11) * detInv;
|
|
2513
|
-
te[8] = (n22 * n11 - n21 * n12) * detInv;
|
|
2514
|
-
return this;
|
|
2515
|
-
}
|
|
2516
|
-
/**
|
|
2517
|
-
* Transposes this matrix in place.
|
|
2518
|
-
*
|
|
2519
|
-
* @return {Matrix3} A reference to this matrix.
|
|
2520
|
-
*/
|
|
2521
|
-
transpose() {
|
|
2522
|
-
let tmp;
|
|
2523
|
-
const m = this.elements;
|
|
2524
|
-
tmp = m[1];
|
|
2525
|
-
m[1] = m[3];
|
|
2526
|
-
m[3] = tmp;
|
|
2527
|
-
tmp = m[2];
|
|
2528
|
-
m[2] = m[6];
|
|
2529
|
-
m[6] = tmp;
|
|
2530
|
-
tmp = m[5];
|
|
2531
|
-
m[5] = m[7];
|
|
2532
|
-
m[7] = tmp;
|
|
2533
|
-
return this;
|
|
2534
|
-
}
|
|
2535
|
-
/**
|
|
2536
|
-
* Computes the normal matrix which is the inverse transpose of the upper
|
|
2537
|
-
* left 3x3 portion of the given 4x4 matrix.
|
|
2538
|
-
*
|
|
2539
|
-
* @param {Matrix4} matrix4 - The 4x4 matrix.
|
|
2540
|
-
* @return {Matrix3} A reference to this matrix.
|
|
2541
|
-
*/
|
|
2542
|
-
getNormalMatrix(matrix4) {
|
|
2543
|
-
return this.setFromMatrix4(matrix4).invert().transpose();
|
|
2544
|
-
}
|
|
2545
|
-
/**
|
|
2546
|
-
* Transposes this matrix into the supplied array, and returns itself unchanged.
|
|
2547
|
-
*
|
|
2548
|
-
* @param {Array<number>} r - An array to store the transposed matrix elements.
|
|
2549
|
-
* @return {Matrix3} A reference to this matrix.
|
|
2550
|
-
*/
|
|
2551
|
-
transposeIntoArray(r) {
|
|
2552
|
-
const m = this.elements;
|
|
2553
|
-
r[0] = m[0];
|
|
2554
|
-
r[1] = m[3];
|
|
2555
|
-
r[2] = m[6];
|
|
2556
|
-
r[3] = m[1];
|
|
2557
|
-
r[4] = m[4];
|
|
2558
|
-
r[5] = m[7];
|
|
2559
|
-
r[6] = m[2];
|
|
2560
|
-
r[7] = m[5];
|
|
2561
|
-
r[8] = m[8];
|
|
2562
|
-
return this;
|
|
2563
|
-
}
|
|
2564
|
-
/**
|
|
2565
|
-
* Sets the UV transform matrix from offset, repeat, rotation, and center.
|
|
2566
|
-
*
|
|
2567
|
-
* @param {number} tx - Offset x.
|
|
2568
|
-
* @param {number} ty - Offset y.
|
|
2569
|
-
* @param {number} sx - Repeat x.
|
|
2570
|
-
* @param {number} sy - Repeat y.
|
|
2571
|
-
* @param {number} rotation - Rotation, in radians. Positive values rotate counterclockwise.
|
|
2572
|
-
* @param {number} cx - Center x of rotation.
|
|
2573
|
-
* @param {number} cy - Center y of rotation
|
|
2574
|
-
* @return {Matrix3} A reference to this matrix.
|
|
2575
|
-
*/
|
|
2576
|
-
setUvTransform(tx, ty, sx, sy, rotation, cx, cy) {
|
|
2577
|
-
const c = Math.cos(rotation);
|
|
2578
|
-
const s = Math.sin(rotation);
|
|
2579
|
-
this.set(
|
|
2580
|
-
sx * c,
|
|
2581
|
-
sx * s,
|
|
2582
|
-
-sx * (c * cx + s * cy) + cx + tx,
|
|
2583
|
-
-sy * s,
|
|
2584
|
-
sy * c,
|
|
2585
|
-
-sy * (-s * cx + c * cy) + cy + ty,
|
|
2586
|
-
0,
|
|
2587
|
-
0,
|
|
2588
|
-
1
|
|
2589
|
-
);
|
|
2590
|
-
return this;
|
|
2591
|
-
}
|
|
2592
|
-
/**
|
|
2593
|
-
* Scales this matrix with the given scalar values.
|
|
2594
|
-
*
|
|
2595
|
-
* @param {number} sx - The amount to scale in the X axis.
|
|
2596
|
-
* @param {number} sy - The amount to scale in the Y axis.
|
|
2597
|
-
* @return {Matrix3} A reference to this matrix.
|
|
2598
|
-
*/
|
|
2599
|
-
scale(sx, sy) {
|
|
2600
|
-
this.premultiply(_m3.makeScale(sx, sy));
|
|
2601
|
-
return this;
|
|
2602
|
-
}
|
|
2603
|
-
/**
|
|
2604
|
-
* Rotates this matrix by the given angle.
|
|
2605
|
-
*
|
|
2606
|
-
* @param {number} theta - The rotation in radians.
|
|
2607
|
-
* @return {Matrix3} A reference to this matrix.
|
|
2608
|
-
*/
|
|
2609
|
-
rotate(theta) {
|
|
2610
|
-
this.premultiply(_m3.makeRotation(-theta));
|
|
2611
|
-
return this;
|
|
2612
|
-
}
|
|
2613
|
-
/**
|
|
2614
|
-
* Translates this matrix by the given scalar values.
|
|
2615
|
-
*
|
|
2616
|
-
* @param {number} tx - The amount to translate in the X axis.
|
|
2617
|
-
* @param {number} ty - The amount to translate in the Y axis.
|
|
2618
|
-
* @return {Matrix3} A reference to this matrix.
|
|
2619
|
-
*/
|
|
2620
|
-
translate(tx, ty) {
|
|
2621
|
-
this.premultiply(_m3.makeTranslation(tx, ty));
|
|
2622
|
-
return this;
|
|
2623
|
-
}
|
|
2624
|
-
// for 2D Transforms
|
|
2625
|
-
/**
|
|
2626
|
-
* Sets this matrix as a 2D translation transform.
|
|
2627
|
-
*
|
|
2628
|
-
* @param {number|Vector2} x - The amount to translate in the X axis or alternatively a translation vector.
|
|
2629
|
-
* @param {number} y - The amount to translate in the Y axis.
|
|
2630
|
-
* @return {Matrix3} A reference to this matrix.
|
|
2631
|
-
*/
|
|
2632
|
-
makeTranslation(x, y) {
|
|
2633
|
-
if (x.isVector2) {
|
|
2634
|
-
this.set(
|
|
2635
|
-
1,
|
|
2636
|
-
0,
|
|
2637
|
-
x.x,
|
|
2638
|
-
0,
|
|
2639
|
-
1,
|
|
2640
|
-
x.y,
|
|
2641
|
-
0,
|
|
2642
|
-
0,
|
|
2643
|
-
1
|
|
2644
|
-
);
|
|
2645
|
-
} else {
|
|
2646
|
-
this.set(
|
|
2647
|
-
1,
|
|
2648
|
-
0,
|
|
2649
|
-
x,
|
|
2650
|
-
0,
|
|
2651
|
-
1,
|
|
2652
|
-
y,
|
|
2653
|
-
0,
|
|
2654
|
-
0,
|
|
2655
|
-
1
|
|
2656
|
-
);
|
|
2657
|
-
}
|
|
2658
|
-
return this;
|
|
2659
|
-
}
|
|
2660
|
-
/**
|
|
2661
|
-
* Sets this matrix as a 2D rotational transformation.
|
|
2662
|
-
*
|
|
2663
|
-
* @param {number} theta - The rotation in radians.
|
|
2664
|
-
* @return {Matrix3} A reference to this matrix.
|
|
2665
|
-
*/
|
|
2666
|
-
makeRotation(theta) {
|
|
2667
|
-
const c = Math.cos(theta);
|
|
2668
|
-
const s = Math.sin(theta);
|
|
2669
|
-
this.set(
|
|
2670
|
-
c,
|
|
2671
|
-
-s,
|
|
2672
|
-
0,
|
|
2673
|
-
s,
|
|
2674
|
-
c,
|
|
2675
|
-
0,
|
|
2676
|
-
0,
|
|
2677
|
-
0,
|
|
2678
|
-
1
|
|
2679
|
-
);
|
|
2680
|
-
return this;
|
|
2681
|
-
}
|
|
2682
|
-
/**
|
|
2683
|
-
* Sets this matrix as a 2D scale transform.
|
|
2684
|
-
*
|
|
2685
|
-
* @param {number} x - The amount to scale in the X axis.
|
|
2686
|
-
* @param {number} y - The amount to scale in the Y axis.
|
|
2687
|
-
* @return {Matrix3} A reference to this matrix.
|
|
2688
|
-
*/
|
|
2689
|
-
makeScale(x, y) {
|
|
2690
|
-
this.set(
|
|
2691
|
-
x,
|
|
2692
|
-
0,
|
|
2693
|
-
0,
|
|
2694
|
-
0,
|
|
2695
|
-
y,
|
|
2696
|
-
0,
|
|
2697
|
-
0,
|
|
2698
|
-
0,
|
|
2699
|
-
1
|
|
2700
|
-
);
|
|
2701
|
-
return this;
|
|
2702
|
-
}
|
|
2703
|
-
/**
|
|
2704
|
-
* Returns `true` if this matrix is equal with the given one.
|
|
2705
|
-
*
|
|
2706
|
-
* @param {Matrix3} matrix - The matrix to test for equality.
|
|
2707
|
-
* @return {boolean} Whether this matrix is equal with the given one.
|
|
2708
|
-
*/
|
|
2709
|
-
equals(matrix) {
|
|
2710
|
-
const te = this.elements;
|
|
2711
|
-
const me = matrix.elements;
|
|
2712
|
-
for (let i = 0; i < 9; i++) {
|
|
2713
|
-
if (te[i] !== me[i]) return false;
|
|
2714
|
-
}
|
|
2715
|
-
return true;
|
|
2716
|
-
}
|
|
2717
|
-
/**
|
|
2718
|
-
* Sets the elements of the matrix from the given array.
|
|
2719
|
-
*
|
|
2720
|
-
* @param {Array<number>} array - The matrix elements in column-major order.
|
|
2721
|
-
* @param {number} [offset=0] - Index of the first element in the array.
|
|
2722
|
-
* @return {Matrix3} A reference to this matrix.
|
|
2723
|
-
*/
|
|
2724
|
-
fromArray(array, offset = 0) {
|
|
2725
|
-
for (let i = 0; i < 9; i++) {
|
|
2726
|
-
this.elements[i] = array[i + offset];
|
|
2727
|
-
}
|
|
2728
|
-
return this;
|
|
2729
|
-
}
|
|
2730
|
-
/**
|
|
2731
|
-
* Writes the elements of this matrix to the given array. If no array is provided,
|
|
2732
|
-
* the method returns a new instance.
|
|
2733
|
-
*
|
|
2734
|
-
* @param {Array<number>} [array=[]] - The target array holding the matrix elements in column-major order.
|
|
2735
|
-
* @param {number} [offset=0] - Index of the first element in the array.
|
|
2736
|
-
* @return {Array<number>} The matrix elements in column-major order.
|
|
2737
|
-
*/
|
|
2738
|
-
toArray(array = [], offset = 0) {
|
|
2739
|
-
const te = this.elements;
|
|
2740
|
-
array[offset] = te[0];
|
|
2741
|
-
array[offset + 1] = te[1];
|
|
2742
|
-
array[offset + 2] = te[2];
|
|
2743
|
-
array[offset + 3] = te[3];
|
|
2744
|
-
array[offset + 4] = te[4];
|
|
2745
|
-
array[offset + 5] = te[5];
|
|
2746
|
-
array[offset + 6] = te[6];
|
|
2747
|
-
array[offset + 7] = te[7];
|
|
2748
|
-
array[offset + 8] = te[8];
|
|
2749
|
-
return array;
|
|
2750
|
-
}
|
|
2751
|
-
/**
|
|
2752
|
-
* Returns a matrix with copied values from this instance.
|
|
2753
|
-
*
|
|
2754
|
-
* @return {Matrix3} A clone of this instance.
|
|
2755
|
-
*/
|
|
2756
|
-
clone() {
|
|
2757
|
-
return new this.constructor().fromArray(this.elements);
|
|
2758
|
-
}
|
|
2759
|
-
};
|
|
2760
|
-
var _m3 = /* @__PURE__ */ new Matrix3();
|
|
2761
|
-
|
|
2762
|
-
// ../../node_modules/.pnpm/three@0.183.2/node_modules/three/src/math/ColorManagement.js
|
|
2763
|
-
function SRGBToLinear(c) {
|
|
2764
|
-
return c < 0.04045 ? c * 0.0773993808 : Math.pow(c * 0.9478672986 + 0.0521327014, 2.4);
|
|
2765
|
-
}
|
|
2766
|
-
|
|
2767
|
-
// ../../node_modules/.pnpm/three@0.183.2/node_modules/three/src/extras/ImageUtils.js
|
|
2768
|
-
var _canvas;
|
|
2769
|
-
var ImageUtils = class {
|
|
2770
|
-
/**
|
|
2771
|
-
* Returns a data URI containing a representation of the given image.
|
|
2772
|
-
*
|
|
2773
|
-
* @param {(HTMLImageElement|HTMLCanvasElement)} image - The image object.
|
|
2774
|
-
* @param {string} [type='image/png'] - Indicates the image format.
|
|
2775
|
-
* @return {string} The data URI.
|
|
2776
|
-
*/
|
|
2777
|
-
static getDataURL(image, type = "image/png") {
|
|
2778
|
-
if (/^data:/i.test(image.src)) {
|
|
2779
|
-
return image.src;
|
|
2780
|
-
}
|
|
2781
|
-
if (typeof HTMLCanvasElement === "undefined") {
|
|
2782
|
-
return image.src;
|
|
2783
|
-
}
|
|
2784
|
-
let canvas;
|
|
2785
|
-
if (image instanceof HTMLCanvasElement) {
|
|
2786
|
-
canvas = image;
|
|
2787
|
-
} else {
|
|
2788
|
-
if (_canvas === void 0) _canvas = createElementNS("canvas");
|
|
2789
|
-
_canvas.width = image.width;
|
|
2790
|
-
_canvas.height = image.height;
|
|
2791
|
-
const context = _canvas.getContext("2d");
|
|
2792
|
-
if (image instanceof ImageData) {
|
|
2793
|
-
context.putImageData(image, 0, 0);
|
|
2794
|
-
} else {
|
|
2795
|
-
context.drawImage(image, 0, 0, image.width, image.height);
|
|
2796
|
-
}
|
|
2797
|
-
canvas = _canvas;
|
|
2798
|
-
}
|
|
2799
|
-
return canvas.toDataURL(type);
|
|
2800
|
-
}
|
|
2801
|
-
/**
|
|
2802
|
-
* Converts the given sRGB image data to linear color space.
|
|
2803
|
-
*
|
|
2804
|
-
* @param {(HTMLImageElement|HTMLCanvasElement|ImageBitmap|Object)} image - The image object.
|
|
2805
|
-
* @return {HTMLCanvasElement|Object} The converted image.
|
|
2806
|
-
*/
|
|
2807
|
-
static sRGBToLinear(image) {
|
|
2808
|
-
if (typeof HTMLImageElement !== "undefined" && image instanceof HTMLImageElement || typeof HTMLCanvasElement !== "undefined" && image instanceof HTMLCanvasElement || typeof ImageBitmap !== "undefined" && image instanceof ImageBitmap) {
|
|
2809
|
-
const canvas = createElementNS("canvas");
|
|
2810
|
-
canvas.width = image.width;
|
|
2811
|
-
canvas.height = image.height;
|
|
2812
|
-
const context = canvas.getContext("2d");
|
|
2813
|
-
context.drawImage(image, 0, 0, image.width, image.height);
|
|
2814
|
-
const imageData = context.getImageData(0, 0, image.width, image.height);
|
|
2815
|
-
const data = imageData.data;
|
|
2816
|
-
for (let i = 0; i < data.length; i++) {
|
|
2817
|
-
data[i] = SRGBToLinear(data[i] / 255) * 255;
|
|
2818
|
-
}
|
|
2819
|
-
context.putImageData(imageData, 0, 0);
|
|
2820
|
-
return canvas;
|
|
2821
|
-
} else if (image.data) {
|
|
2822
|
-
const data = image.data.slice(0);
|
|
2823
|
-
for (let i = 0; i < data.length; i++) {
|
|
2824
|
-
if (data instanceof Uint8Array || data instanceof Uint8ClampedArray) {
|
|
2825
|
-
data[i] = Math.floor(SRGBToLinear(data[i] / 255) * 255);
|
|
2826
|
-
} else {
|
|
2827
|
-
data[i] = SRGBToLinear(data[i]);
|
|
2828
|
-
}
|
|
2829
|
-
}
|
|
2830
|
-
return {
|
|
2831
|
-
data,
|
|
2832
|
-
width: image.width,
|
|
2833
|
-
height: image.height
|
|
2834
|
-
};
|
|
2835
|
-
} else {
|
|
2836
|
-
warn("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.");
|
|
2837
|
-
return image;
|
|
2838
|
-
}
|
|
2839
|
-
}
|
|
2840
|
-
};
|
|
2841
|
-
|
|
2842
|
-
// ../../node_modules/.pnpm/three@0.183.2/node_modules/three/src/textures/Source.js
|
|
2843
|
-
var _sourceId = 0;
|
|
2844
|
-
var Source = class {
|
|
2845
|
-
/**
|
|
2846
|
-
* Constructs a new video texture.
|
|
2847
|
-
*
|
|
2848
|
-
* @param {any} [data=null] - The data definition of a texture.
|
|
2849
|
-
*/
|
|
2850
|
-
constructor(data = null) {
|
|
2851
|
-
this.isSource = true;
|
|
2852
|
-
Object.defineProperty(this, "id", { value: _sourceId++ });
|
|
2853
|
-
this.uuid = generateUUID();
|
|
2854
|
-
this.data = data;
|
|
2855
|
-
this.dataReady = true;
|
|
2856
|
-
this.version = 0;
|
|
2857
|
-
}
|
|
2858
|
-
/**
|
|
2859
|
-
* Returns the dimensions of the source into the given target vector.
|
|
2860
|
-
*
|
|
2861
|
-
* @param {(Vector2|Vector3)} target - The target object the result is written into.
|
|
2862
|
-
* @return {(Vector2|Vector3)} The dimensions of the source.
|
|
2863
|
-
*/
|
|
2864
|
-
getSize(target) {
|
|
2865
|
-
const data = this.data;
|
|
2866
|
-
if (typeof HTMLVideoElement !== "undefined" && data instanceof HTMLVideoElement) {
|
|
2867
|
-
target.set(data.videoWidth, data.videoHeight, 0);
|
|
2868
|
-
} else if (typeof VideoFrame !== "undefined" && data instanceof VideoFrame) {
|
|
2869
|
-
target.set(data.displayHeight, data.displayWidth, 0);
|
|
2870
|
-
} else if (data !== null) {
|
|
2871
|
-
target.set(data.width, data.height, data.depth || 0);
|
|
2872
|
-
} else {
|
|
2873
|
-
target.set(0, 0, 0);
|
|
2874
|
-
}
|
|
2875
|
-
return target;
|
|
2876
|
-
}
|
|
2877
|
-
/**
|
|
2878
|
-
* When the property is set to `true`, the engine allocates the memory
|
|
2879
|
-
* for the texture (if necessary) and triggers the actual texture upload
|
|
2880
|
-
* to the GPU next time the source is used.
|
|
2881
|
-
*
|
|
2882
|
-
* @type {boolean}
|
|
2883
|
-
* @default false
|
|
2884
|
-
* @param {boolean} value
|
|
2885
|
-
*/
|
|
2886
|
-
set needsUpdate(value) {
|
|
2887
|
-
if (value === true) this.version++;
|
|
2888
|
-
}
|
|
2889
|
-
/**
|
|
2890
|
-
* Serializes the source into JSON.
|
|
2891
|
-
*
|
|
2892
|
-
* @param {?(Object|string)} meta - An optional value holding meta information about the serialization.
|
|
2893
|
-
* @return {Object} A JSON object representing the serialized source.
|
|
2894
|
-
* @see {@link ObjectLoader#parse}
|
|
2895
|
-
*/
|
|
2896
|
-
toJSON(meta) {
|
|
2897
|
-
const isRootObject = meta === void 0 || typeof meta === "string";
|
|
2898
|
-
if (!isRootObject && meta.images[this.uuid] !== void 0) {
|
|
2899
|
-
return meta.images[this.uuid];
|
|
2900
|
-
}
|
|
2901
|
-
const output = {
|
|
2902
|
-
uuid: this.uuid,
|
|
2903
|
-
url: ""
|
|
2904
|
-
};
|
|
2905
|
-
const data = this.data;
|
|
2906
|
-
if (data !== null) {
|
|
2907
|
-
let url;
|
|
2908
|
-
if (Array.isArray(data)) {
|
|
2909
|
-
url = [];
|
|
2910
|
-
for (let i = 0, l = data.length; i < l; i++) {
|
|
2911
|
-
if (data[i].isDataTexture) {
|
|
2912
|
-
url.push(serializeImage(data[i].image));
|
|
2913
|
-
} else {
|
|
2914
|
-
url.push(serializeImage(data[i]));
|
|
2915
|
-
}
|
|
2916
|
-
}
|
|
2917
|
-
} else {
|
|
2918
|
-
url = serializeImage(data);
|
|
2919
|
-
}
|
|
2920
|
-
output.url = url;
|
|
2921
|
-
}
|
|
2922
|
-
if (!isRootObject) {
|
|
2923
|
-
meta.images[this.uuid] = output;
|
|
2924
|
-
}
|
|
2925
|
-
return output;
|
|
2926
|
-
}
|
|
2927
|
-
};
|
|
2928
|
-
function serializeImage(image) {
|
|
2929
|
-
if (typeof HTMLImageElement !== "undefined" && image instanceof HTMLImageElement || typeof HTMLCanvasElement !== "undefined" && image instanceof HTMLCanvasElement || typeof ImageBitmap !== "undefined" && image instanceof ImageBitmap) {
|
|
2930
|
-
return ImageUtils.getDataURL(image);
|
|
2931
|
-
} else {
|
|
2932
|
-
if (image.data) {
|
|
2933
|
-
return {
|
|
2934
|
-
data: Array.from(image.data),
|
|
2935
|
-
width: image.width,
|
|
2936
|
-
height: image.height,
|
|
2937
|
-
type: image.data.constructor.name
|
|
2938
|
-
};
|
|
2939
|
-
} else {
|
|
2940
|
-
warn("Texture: Unable to serialize Texture.");
|
|
2941
|
-
return {};
|
|
2942
|
-
}
|
|
2943
|
-
}
|
|
2944
|
-
}
|
|
2945
|
-
|
|
2946
|
-
// ../../node_modules/.pnpm/three@0.183.2/node_modules/three/src/textures/Texture.js
|
|
2947
|
-
var _textureId = 0;
|
|
2948
|
-
var _tempVec3 = /* @__PURE__ */ new Vector3();
|
|
2949
|
-
var Texture = class _Texture extends EventDispatcher {
|
|
2950
|
-
/**
|
|
2951
|
-
* Constructs a new texture.
|
|
2952
|
-
*
|
|
2953
|
-
* @param {?Object} [image=Texture.DEFAULT_IMAGE] - The image holding the texture data.
|
|
2954
|
-
* @param {number} [mapping=Texture.DEFAULT_MAPPING] - The texture mapping.
|
|
2955
|
-
* @param {number} [wrapS=ClampToEdgeWrapping] - The wrapS value.
|
|
2956
|
-
* @param {number} [wrapT=ClampToEdgeWrapping] - The wrapT value.
|
|
2957
|
-
* @param {number} [magFilter=LinearFilter] - The mag filter value.
|
|
2958
|
-
* @param {number} [minFilter=LinearMipmapLinearFilter] - The min filter value.
|
|
2959
|
-
* @param {number} [format=RGBAFormat] - The texture format.
|
|
2960
|
-
* @param {number} [type=UnsignedByteType] - The texture type.
|
|
2961
|
-
* @param {number} [anisotropy=Texture.DEFAULT_ANISOTROPY] - The anisotropy value.
|
|
2962
|
-
* @param {string} [colorSpace=NoColorSpace] - The color space.
|
|
2963
|
-
*/
|
|
2964
|
-
constructor(image = _Texture.DEFAULT_IMAGE, mapping = _Texture.DEFAULT_MAPPING, wrapS = ClampToEdgeWrapping, wrapT = ClampToEdgeWrapping, magFilter = LinearFilter, minFilter = LinearMipmapLinearFilter, format = RGBAFormat, type = UnsignedByteType, anisotropy = _Texture.DEFAULT_ANISOTROPY, colorSpace = NoColorSpace) {
|
|
2965
|
-
super();
|
|
2966
|
-
this.isTexture = true;
|
|
2967
|
-
Object.defineProperty(this, "id", { value: _textureId++ });
|
|
2968
|
-
this.uuid = generateUUID();
|
|
2969
|
-
this.name = "";
|
|
2970
|
-
this.source = new Source(image);
|
|
2971
|
-
this.mipmaps = [];
|
|
2972
|
-
this.mapping = mapping;
|
|
2973
|
-
this.channel = 0;
|
|
2974
|
-
this.wrapS = wrapS;
|
|
2975
|
-
this.wrapT = wrapT;
|
|
2976
|
-
this.magFilter = magFilter;
|
|
2977
|
-
this.minFilter = minFilter;
|
|
2978
|
-
this.anisotropy = anisotropy;
|
|
2979
|
-
this.format = format;
|
|
2980
|
-
this.internalFormat = null;
|
|
2981
|
-
this.type = type;
|
|
2982
|
-
this.offset = new Vector2(0, 0);
|
|
2983
|
-
this.repeat = new Vector2(1, 1);
|
|
2984
|
-
this.center = new Vector2(0, 0);
|
|
2985
|
-
this.rotation = 0;
|
|
2986
|
-
this.matrixAutoUpdate = true;
|
|
2987
|
-
this.matrix = new Matrix3();
|
|
2988
|
-
this.generateMipmaps = true;
|
|
2989
|
-
this.premultiplyAlpha = false;
|
|
2990
|
-
this.flipY = true;
|
|
2991
|
-
this.unpackAlignment = 4;
|
|
2992
|
-
this.colorSpace = colorSpace;
|
|
2993
|
-
this.userData = {};
|
|
2994
|
-
this.updateRanges = [];
|
|
2995
|
-
this.version = 0;
|
|
2996
|
-
this.onUpdate = null;
|
|
2997
|
-
this.renderTarget = null;
|
|
2998
|
-
this.isRenderTargetTexture = false;
|
|
2999
|
-
this.isArrayTexture = image && image.depth && image.depth > 1 ? true : false;
|
|
3000
|
-
this.pmremVersion = 0;
|
|
3001
|
-
}
|
|
3002
|
-
/**
|
|
3003
|
-
* The width of the texture in pixels.
|
|
3004
|
-
*/
|
|
3005
|
-
get width() {
|
|
3006
|
-
return this.source.getSize(_tempVec3).x;
|
|
3007
|
-
}
|
|
3008
|
-
/**
|
|
3009
|
-
* The height of the texture in pixels.
|
|
3010
|
-
*/
|
|
3011
|
-
get height() {
|
|
3012
|
-
return this.source.getSize(_tempVec3).y;
|
|
3013
|
-
}
|
|
3014
|
-
/**
|
|
3015
|
-
* The depth of the texture in pixels.
|
|
3016
|
-
*/
|
|
3017
|
-
get depth() {
|
|
3018
|
-
return this.source.getSize(_tempVec3).z;
|
|
3019
|
-
}
|
|
3020
|
-
/**
|
|
3021
|
-
* The image object holding the texture data.
|
|
3022
|
-
*
|
|
3023
|
-
* @type {?Object}
|
|
3024
|
-
*/
|
|
3025
|
-
get image() {
|
|
3026
|
-
return this.source.data;
|
|
3027
|
-
}
|
|
3028
|
-
set image(value = null) {
|
|
3029
|
-
this.source.data = value;
|
|
3030
|
-
}
|
|
3031
|
-
/**
|
|
3032
|
-
* Updates the texture transformation matrix from the from the properties {@link Texture#offset},
|
|
3033
|
-
* {@link Texture#repeat}, {@link Texture#rotation}, and {@link Texture#center}.
|
|
3034
|
-
*/
|
|
3035
|
-
updateMatrix() {
|
|
3036
|
-
this.matrix.setUvTransform(this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y);
|
|
3037
|
-
}
|
|
3038
|
-
/**
|
|
3039
|
-
* Adds a range of data in the data texture to be updated on the GPU.
|
|
3040
|
-
*
|
|
3041
|
-
* @param {number} start - Position at which to start update.
|
|
3042
|
-
* @param {number} count - The number of components to update.
|
|
3043
|
-
*/
|
|
3044
|
-
addUpdateRange(start, count) {
|
|
3045
|
-
this.updateRanges.push({ start, count });
|
|
3046
|
-
}
|
|
3047
|
-
/**
|
|
3048
|
-
* Clears the update ranges.
|
|
3049
|
-
*/
|
|
3050
|
-
clearUpdateRanges() {
|
|
3051
|
-
this.updateRanges.length = 0;
|
|
3052
|
-
}
|
|
3053
|
-
/**
|
|
3054
|
-
* Returns a new texture with copied values from this instance.
|
|
3055
|
-
*
|
|
3056
|
-
* @return {Texture} A clone of this instance.
|
|
3057
|
-
*/
|
|
3058
|
-
clone() {
|
|
3059
|
-
return new this.constructor().copy(this);
|
|
3060
|
-
}
|
|
3061
|
-
/**
|
|
3062
|
-
* Copies the values of the given texture to this instance.
|
|
3063
|
-
*
|
|
3064
|
-
* @param {Texture} source - The texture to copy.
|
|
3065
|
-
* @return {Texture} A reference to this instance.
|
|
3066
|
-
*/
|
|
3067
|
-
copy(source) {
|
|
3068
|
-
this.name = source.name;
|
|
3069
|
-
this.source = source.source;
|
|
3070
|
-
this.mipmaps = source.mipmaps.slice(0);
|
|
3071
|
-
this.mapping = source.mapping;
|
|
3072
|
-
this.channel = source.channel;
|
|
3073
|
-
this.wrapS = source.wrapS;
|
|
3074
|
-
this.wrapT = source.wrapT;
|
|
3075
|
-
this.magFilter = source.magFilter;
|
|
3076
|
-
this.minFilter = source.minFilter;
|
|
3077
|
-
this.anisotropy = source.anisotropy;
|
|
3078
|
-
this.format = source.format;
|
|
3079
|
-
this.internalFormat = source.internalFormat;
|
|
3080
|
-
this.type = source.type;
|
|
3081
|
-
this.offset.copy(source.offset);
|
|
3082
|
-
this.repeat.copy(source.repeat);
|
|
3083
|
-
this.center.copy(source.center);
|
|
3084
|
-
this.rotation = source.rotation;
|
|
3085
|
-
this.matrixAutoUpdate = source.matrixAutoUpdate;
|
|
3086
|
-
this.matrix.copy(source.matrix);
|
|
3087
|
-
this.generateMipmaps = source.generateMipmaps;
|
|
3088
|
-
this.premultiplyAlpha = source.premultiplyAlpha;
|
|
3089
|
-
this.flipY = source.flipY;
|
|
3090
|
-
this.unpackAlignment = source.unpackAlignment;
|
|
3091
|
-
this.colorSpace = source.colorSpace;
|
|
3092
|
-
this.renderTarget = source.renderTarget;
|
|
3093
|
-
this.isRenderTargetTexture = source.isRenderTargetTexture;
|
|
3094
|
-
this.isArrayTexture = source.isArrayTexture;
|
|
3095
|
-
this.userData = JSON.parse(JSON.stringify(source.userData));
|
|
3096
|
-
this.needsUpdate = true;
|
|
3097
|
-
return this;
|
|
3098
|
-
}
|
|
3099
|
-
/**
|
|
3100
|
-
* Sets this texture's properties based on `values`.
|
|
3101
|
-
* @param {Object} values - A container with texture parameters.
|
|
3102
|
-
*/
|
|
3103
|
-
setValues(values) {
|
|
3104
|
-
for (const key in values) {
|
|
3105
|
-
const newValue = values[key];
|
|
3106
|
-
if (newValue === void 0) {
|
|
3107
|
-
warn(`Texture.setValues(): parameter '${key}' has value of undefined.`);
|
|
3108
|
-
continue;
|
|
3109
|
-
}
|
|
3110
|
-
const currentValue = this[key];
|
|
3111
|
-
if (currentValue === void 0) {
|
|
3112
|
-
warn(`Texture.setValues(): property '${key}' does not exist.`);
|
|
3113
|
-
continue;
|
|
3114
|
-
}
|
|
3115
|
-
if (currentValue && newValue && (currentValue.isVector2 && newValue.isVector2)) {
|
|
3116
|
-
currentValue.copy(newValue);
|
|
3117
|
-
} else if (currentValue && newValue && (currentValue.isVector3 && newValue.isVector3)) {
|
|
3118
|
-
currentValue.copy(newValue);
|
|
3119
|
-
} else if (currentValue && newValue && (currentValue.isMatrix3 && newValue.isMatrix3)) {
|
|
3120
|
-
currentValue.copy(newValue);
|
|
3121
|
-
} else {
|
|
3122
|
-
this[key] = newValue;
|
|
3123
|
-
}
|
|
3124
|
-
}
|
|
3125
|
-
}
|
|
3126
|
-
/**
|
|
3127
|
-
* Serializes the texture into JSON.
|
|
3128
|
-
*
|
|
3129
|
-
* @param {?(Object|string)} meta - An optional value holding meta information about the serialization.
|
|
3130
|
-
* @return {Object} A JSON object representing the serialized texture.
|
|
3131
|
-
* @see {@link ObjectLoader#parse}
|
|
3132
|
-
*/
|
|
3133
|
-
toJSON(meta) {
|
|
3134
|
-
const isRootObject = meta === void 0 || typeof meta === "string";
|
|
3135
|
-
if (!isRootObject && meta.textures[this.uuid] !== void 0) {
|
|
3136
|
-
return meta.textures[this.uuid];
|
|
3137
|
-
}
|
|
3138
|
-
const output = {
|
|
3139
|
-
metadata: {
|
|
3140
|
-
version: 4.7,
|
|
3141
|
-
type: "Texture",
|
|
3142
|
-
generator: "Texture.toJSON"
|
|
3143
|
-
},
|
|
3144
|
-
uuid: this.uuid,
|
|
3145
|
-
name: this.name,
|
|
3146
|
-
image: this.source.toJSON(meta).uuid,
|
|
3147
|
-
mapping: this.mapping,
|
|
3148
|
-
channel: this.channel,
|
|
3149
|
-
repeat: [this.repeat.x, this.repeat.y],
|
|
3150
|
-
offset: [this.offset.x, this.offset.y],
|
|
3151
|
-
center: [this.center.x, this.center.y],
|
|
3152
|
-
rotation: this.rotation,
|
|
3153
|
-
wrap: [this.wrapS, this.wrapT],
|
|
3154
|
-
format: this.format,
|
|
3155
|
-
internalFormat: this.internalFormat,
|
|
3156
|
-
type: this.type,
|
|
3157
|
-
colorSpace: this.colorSpace,
|
|
3158
|
-
minFilter: this.minFilter,
|
|
3159
|
-
magFilter: this.magFilter,
|
|
3160
|
-
anisotropy: this.anisotropy,
|
|
3161
|
-
flipY: this.flipY,
|
|
3162
|
-
generateMipmaps: this.generateMipmaps,
|
|
3163
|
-
premultiplyAlpha: this.premultiplyAlpha,
|
|
3164
|
-
unpackAlignment: this.unpackAlignment
|
|
3165
|
-
};
|
|
3166
|
-
if (Object.keys(this.userData).length > 0) output.userData = this.userData;
|
|
3167
|
-
if (!isRootObject) {
|
|
3168
|
-
meta.textures[this.uuid] = output;
|
|
3169
|
-
}
|
|
3170
|
-
return output;
|
|
3171
|
-
}
|
|
3172
|
-
/**
|
|
3173
|
-
* Frees the GPU-related resources allocated by this instance. Call this
|
|
3174
|
-
* method whenever this instance is no longer used in your app.
|
|
3175
|
-
*
|
|
3176
|
-
* @fires Texture#dispose
|
|
3177
|
-
*/
|
|
3178
|
-
dispose() {
|
|
3179
|
-
this.dispatchEvent({ type: "dispose" });
|
|
3180
|
-
}
|
|
3181
|
-
/**
|
|
3182
|
-
* Transforms the given uv vector with the textures uv transformation matrix.
|
|
3183
|
-
*
|
|
3184
|
-
* @param {Vector2} uv - The uv vector.
|
|
3185
|
-
* @return {Vector2} The transformed uv vector.
|
|
3186
|
-
*/
|
|
3187
|
-
transformUv(uv) {
|
|
3188
|
-
if (this.mapping !== UVMapping) return uv;
|
|
3189
|
-
uv.applyMatrix3(this.matrix);
|
|
3190
|
-
if (uv.x < 0 || uv.x > 1) {
|
|
3191
|
-
switch (this.wrapS) {
|
|
3192
|
-
case RepeatWrapping:
|
|
3193
|
-
uv.x = uv.x - Math.floor(uv.x);
|
|
3194
|
-
break;
|
|
3195
|
-
case ClampToEdgeWrapping:
|
|
3196
|
-
uv.x = uv.x < 0 ? 0 : 1;
|
|
3197
|
-
break;
|
|
3198
|
-
case MirroredRepeatWrapping:
|
|
3199
|
-
if (Math.abs(Math.floor(uv.x) % 2) === 1) {
|
|
3200
|
-
uv.x = Math.ceil(uv.x) - uv.x;
|
|
3201
|
-
} else {
|
|
3202
|
-
uv.x = uv.x - Math.floor(uv.x);
|
|
3203
|
-
}
|
|
3204
|
-
break;
|
|
3205
|
-
}
|
|
3206
|
-
}
|
|
3207
|
-
if (uv.y < 0 || uv.y > 1) {
|
|
3208
|
-
switch (this.wrapT) {
|
|
3209
|
-
case RepeatWrapping:
|
|
3210
|
-
uv.y = uv.y - Math.floor(uv.y);
|
|
3211
|
-
break;
|
|
3212
|
-
case ClampToEdgeWrapping:
|
|
3213
|
-
uv.y = uv.y < 0 ? 0 : 1;
|
|
3214
|
-
break;
|
|
3215
|
-
case MirroredRepeatWrapping:
|
|
3216
|
-
if (Math.abs(Math.floor(uv.y) % 2) === 1) {
|
|
3217
|
-
uv.y = Math.ceil(uv.y) - uv.y;
|
|
3218
|
-
} else {
|
|
3219
|
-
uv.y = uv.y - Math.floor(uv.y);
|
|
3220
|
-
}
|
|
3221
|
-
break;
|
|
3222
|
-
}
|
|
3223
|
-
}
|
|
3224
|
-
if (this.flipY) {
|
|
3225
|
-
uv.y = 1 - uv.y;
|
|
3226
|
-
}
|
|
3227
|
-
return uv;
|
|
3228
|
-
}
|
|
3229
|
-
/**
|
|
3230
|
-
* Setting this property to `true` indicates the engine the texture
|
|
3231
|
-
* must be updated in the next render. This triggers a texture upload
|
|
3232
|
-
* to the GPU and ensures correct texture parameter configuration.
|
|
3233
|
-
*
|
|
3234
|
-
* @type {boolean}
|
|
3235
|
-
* @default false
|
|
3236
|
-
* @param {boolean} value
|
|
3237
|
-
*/
|
|
3238
|
-
set needsUpdate(value) {
|
|
3239
|
-
if (value === true) {
|
|
3240
|
-
this.version++;
|
|
3241
|
-
this.source.needsUpdate = true;
|
|
3242
|
-
}
|
|
3243
|
-
}
|
|
3244
|
-
/**
|
|
3245
|
-
* Setting this property to `true` indicates the engine the PMREM
|
|
3246
|
-
* must be regenerated.
|
|
3247
|
-
*
|
|
3248
|
-
* @type {boolean}
|
|
3249
|
-
* @default false
|
|
3250
|
-
* @param {boolean} value
|
|
3251
|
-
*/
|
|
3252
|
-
set needsPMREMUpdate(value) {
|
|
3253
|
-
if (value === true) {
|
|
3254
|
-
this.pmremVersion++;
|
|
3255
|
-
}
|
|
3256
|
-
}
|
|
3257
|
-
};
|
|
3258
|
-
Texture.DEFAULT_IMAGE = null;
|
|
3259
|
-
Texture.DEFAULT_MAPPING = UVMapping;
|
|
3260
|
-
Texture.DEFAULT_ANISOTROPY = 1;
|
|
3261
|
-
|
|
3262
|
-
export {
|
|
3263
|
-
LinearFilter,
|
|
3264
|
-
createElementNS,
|
|
3265
|
-
Texture
|
|
3266
|
-
};
|