Visecall commited on
Commit
103d38d
·
verified ·
1 Parent(s): 155fbcd

Transition assets: scripts (part 32)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/ShaderPass.js +1 -0
  2. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/scriptScene.js +1 -0
  3. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/three-amg-wrapper.js +1 -0
  4. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/tween.js +1 -0
  5. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Box2.js +1 -0
  6. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Box3.js +1 -0
  7. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js +1 -0
  8. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/BufferAttribute.js +1 -0
  9. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js +1 -0
  10. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/CapsuleGeometry.js +1 -0
  11. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Color.js +1 -0
  12. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Constants.js +1 -0
  13. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js +1 -0
  14. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js +1 -0
  15. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Earcut.js +1 -0
  16. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Euler.js +1 -0
  17. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/ExtrudeGeometry.js +1 -0
  18. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Group.js +1 -0
  19. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Material.js +1 -0
  20. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js +1 -0
  21. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js +1 -0
  22. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Mesh.js +1 -0
  23. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js +1 -0
  24. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Object3D.js +1 -0
  25. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js +1 -0
  26. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js +1 -0
  27. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Quaternion.js +1 -0
  28. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js +1 -0
  29. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Shape.js +1 -0
  30. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js +1 -0
  31. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js +1 -0
  32. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Texture.js +1 -0
  33. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Vector2.js +1 -0
  34. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Vector3.js +1 -0
  35. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Vector4.js +1 -0
  36. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/WebGLRenderer.js +1 -0
  37. scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/runtime.js +1 -0
  38. scripts/7681304008023215368/AmazingFeature/xshader/Unlit.frag +25 -0
  39. scripts/7681304008023215368/AmazingFeature/xshader/Unlit.vert +35 -0
  40. scripts/7681304008023215368/AmazingFeature/xshader/noface.frag +7 -0
  41. scripts/7681304008023215368/AmazingFeature/xshader/noface.vert +12 -0
  42. scripts/7681304008023215368/config.json +16 -0
  43. scripts/7681304008023215368/extra.json +35 -0
  44. scripts/7681318995261132040/AmazingFeature/content.json +7 -0
  45. scripts/7681318995261132040/AmazingFeature/js/JSSys.js +89 -0
  46. scripts/7681318995261132040/AmazingFeature/js/ThreeJS/EffectComposer.js +1 -0
  47. scripts/7681318995261132040/AmazingFeature/js/ThreeJS/RenderPass.js +34 -0
  48. scripts/7681318995261132040/AmazingFeature/js/ThreeJS/ShaderPass.js +166 -0
  49. scripts/7681318995261132040/AmazingFeature/js/ThreeJS/customEasings.js +1127 -0
  50. scripts/7681318995261132040/AmazingFeature/js/ThreeJS/scriptScene.js +800 -0
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/ShaderPass.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const effect_api="undefined"!=typeof effect?effect:"undefined"!=typeof tt?tt:"undefined"!=typeof lynx?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const THREE=require("./three-amg-wrapper.js").THREE;const getCurrentScene=require("./three-amg-wrapper.js").getCurrentScene;const ShaderMaterial=require("./wrapper/ShaderMaterial").ShaderMaterial;const VideoTexture=require("./wrapper/Texture").VideoTexture;class ShaderPass{constructor(parameters={}){this.progress=0;this.prevTexture=null;this.nextTexture=null;console.log("getCurrentScene():");this.scene=getCurrentScene();console.log("getCurrentScene():",this.scene);if(parameters.name&&!parameters.isDynamic){this.postProcessPrefab=this.scene._amgScene.assetMgr.SyncLoad("prefabs/postProcess.prefab");this._amgEntity=new Amaz.Entity;this._amgEntity.name=parameters.name;this._amgEntity.scene=this.scene._amgScene;this._transform=this._amgEntity.addComponent("Transform");this.postProcessPrefab.instantiateToEntity(this.scene._amgScene,this._amgEntity);this.meshEntity=this._amgEntity.searchEntity("PassWarp");this.cameraEntity=this._amgEntity.searchEntity("CameraWarp")}else{const baseName=parameters.name||"DynamicShaderPass_"+Math.random().toString(36).substr(2,9);this._amgEntity=new Amaz.Entity;this._amgEntity.name=baseName+"Entity";this._amgEntity.scene=this.scene._amgScene;this._transform=this._amgEntity.addComponent("Transform");this.meshEntity=new Amaz.Entity;this.meshEntity.name="Mesh"+baseName+"Pass";this.meshEntity.scene=this.scene._amgScene;this.meshEntity.selfvisible=true;this.meshEntity.visible=true;const meshTransform=this.meshEntity.addComponent("Transform");const mr=this.meshEntity.addComponent("MeshRenderer");if(!ShaderPass.quadMesh){ShaderPass.quadMesh=this.scene._amgScene.assetMgr.SyncLoad("prefabs/Quad.mesh")}mr.mesh=ShaderPass.quadMesh;this.cameraEntity=new Amaz.Entity;this.cameraEntity.name="Camera"+baseName+"Pass";this.cameraEntity.scene=this.scene._amgScene;this.cameraEntity.selfvisible=true;this.cameraEntity.visible=true;const cameraTransform=this.cameraEntity.addComponent("Transform");this._transform.addTransform(cameraTransform);cameraTransform.localPosition=new Amaz.Vector3f(0,0,20);cameraTransform.addTransform(meshTransform);meshTransform.localPosition=new Amaz.Vector3f(0,0,-10);const cam=this.cameraEntity.addComponent("Camera");cam.type=Amaz&&Amaz.CameraType?Amaz.CameraType.ORTHO:1;cam.clearType=Amaz&&Amaz.CameraClearType?Amaz.CameraClearType.COLOR_DEPTH:cam.clearType;cam.clearColor=Amaz&&Amaz.Color?new Amaz.Color(0,0,0,0):cam.clearColor;cam.alwaysClear=false;cam.isRootCamera=true;cam.renderOrder=1;cam.layerVisibleMask=Amaz&&Amaz.DynamicBitset?new Amaz.DynamicBitset(3,4):cam.layerVisibleMask;cam.orthoScale=1;if(this.scene&&this.scene._amgScene){this.scene._amgScene.addEntity(this.meshEntity);this.scene._amgScene.addEntity(this.cameraEntity)}}this.material=new ShaderMaterial(parameters);this._amgMaterialObject=this.material._amgObject;const meshRenderer=this.meshEntity?this.meshEntity.getComponent("MeshRenderer"):null;if(meshRenderer){meshRenderer.sharedMaterial=this._amgMaterialObject}}setParentTransform(parentTransform){if(!parentTransform||!this._transform)return;if(this._transform.parent&&typeof this._transform.parent.removeTransform==="function"){this._transform.parent.removeTransform(this._transform)}if(typeof parentTransform.addTransform==="function"){parentTransform.addTransform(this._transform)}}seekToTime(time){if(!this.material||!this.material.uniforms)return;for(const[key,uniform]of Object.entries(this.material.uniforms)){if(!uniform)continue;const value=Object.prototype.hasOwnProperty.call(uniform,"value")?uniform.value:uniform;if(!(value instanceof VideoTexture))continue;const renderer=value._amgSprite2DRenderer;if(!renderer||renderer.materials.size()!==1)continue;const texture=renderer.materials.get(0).getTex("_MainTex");value.setImage(texture);if(typeof this.material._syncUniformToAMG==="function"){this.material._syncUniformToAMG(key,uniform)}if(value._amgVideoAnimSeq){value._amgVideoAnimSeq.seekToTime(time/1e3)}}}get uniforms(){return this.material?this.material.uniforms:undefined}render(renderer,writeBuffer,readBuffer,delta,maskActive){return}dispose(){if(this.scene&&this.scene._amgScene){if(this.meshEntity){this.scene._amgScene.removeEntity(this.meshEntity)}if(this.cameraEntity){this.scene._amgScene.removeEntity(this.cameraEntity)}}if(this.material&&typeof this.material.dispose==="function"){this.material.dispose()}this.postProcessPrefab=null;this.material=null;this._amgMaterialObject=null;if(this.prevTexture){this.prevTexture.dispose()}if(this.nextTexture){this.nextTexture.dispose()}this.prevTexture=null;this.nextTexture=null;this.scene=null;this.meshEntity=null;this.cameraEntity=null}}ShaderPass.quadMesh=null;ShaderPass.camType=undefined;ShaderPass.camOrthoScale=undefined;exports.ShaderPass=ShaderPass;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/scriptScene.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const TWEEN=require("./tween");const customEasings=require("./customEasings").customEasings;const THREE=require("./three-amg-wrapper").THREE;const{ShaderPass}=require("./ShaderPass.js");class ScriptScene{constructor(amgScene=null,container=null){if(amgScene){this.scene=new THREE.Scene;this.scene._amgScene=amgScene}else{this.scene=new THREE.Scene}this.effect_type="transition";this.camera=null;this.renderer=null;this.scene.background=new THREE.Color(3355443);this.isAnimating=false;this.animationFrameId=null;this.sceneObjects=null;this.texture1=null;this.texture2=null;this.composer=null;this.renderPass=null;this.usePostProcessing=true;this.initCoreObjects();if(container){this.init(container)}}destroy(){this.isAnimating=false;if(this.animationFrameId!==null&&typeof cancelAnimationFrame!=="undefined"){cancelAnimationFrame(this.animationFrameId);this.animationFrameId=null}if(this.renderer){this.renderer.setAnimationLoop(null);this.renderer.dispose();if(this.renderer.domElement&&this.renderer.domElement.parentNode){this.renderer.domElement.parentNode.removeChild(this.renderer.domElement)}}if(this.texture1){if(typeof this.texture1.dispose==="function")this.texture1.dispose();this.texture1=null}if(this.texture2){if(typeof this.texture2.dispose==="function")this.texture2.dispose();this.texture2=null}if(this.scene){this.scene.dispose()}if(typeof window!=="undefined"){window.removeEventListener("resize",this.handleResize)}if(this.sceneObjects&&this.sceneObjects.tweens){this.sceneObjects.tweens.forEach(tween=>{if(tween&&typeof tween.stop==="function"){tween.stop()}});this.sceneObjects.tweens=[]}if(this.shaderPasses&&this.shaderPasses.length){this.shaderPasses.forEach(pass=>{if(pass&&typeof pass.dispose==="function"){try{pass.dispose()}catch(e){}}});this.shaderPasses=[]}if(this.shaderPass&&typeof this.shaderPass.dispose==="function"){try{this.shaderPass.dispose()}catch(e){}}this.shaderPass=null;if(this.composer){this.composer.dispose();this.composer=null}this.renderPass=null;this.scene=null;this.camera=null;this.renderer=null;this.sceneObjects=null}initCoreObjects(){if(typeof window!=="undefined"){if(!window.innerWidth||!window.innerHeight){window.innerWidth=600;window.innerHeight=600}window.devicePixelRatio=window.devicePixelRatio||1;if(this.scene&&this.scene._amgScene&&this.scene._amgScene.assetMgr){const inputTexture=this.scene._amgScene.assetMgr.SyncLoad("share://input.texture");if(inputTexture&&inputTexture.width>0&&inputTexture.height>0){window.innerWidth=inputTexture.width;window.innerHeight=inputTexture.height}}}this.camera=new THREE.PerspectiveCamera(53.1,window.innerWidth/window.innerHeight,.1,1e4);this.camera.position.z=10;this.scene.add(this.camera);if(this.scene._amgScene==null){this.renderer=new THREE.WebGLRenderer({antialias:true});this.renderer.outputColorSpace=THREE.LinearSRGBColorSpace}if(this.renderer){this.renderer.setSize(window.innerWidth,window.innerHeight);this.renderer.setPixelRatio(window.devicePixelRatio)}this.sliders={};this.TWEEN=TWEEN;this.customEasings=customEasings;this.Duration=2e3}addShaderPass(shaderPassConfigs){if(!Array.isArray(shaderPassConfigs)){shaderPassConfigs=[shaderPassConfigs]}shaderPassConfigs.forEach(config=>{const atomicName=config.name;const className=atomicName.startsWith("Lumi")?atomicName.substring(4):atomicName;const shaderPassModule=require("../pp/Lumi"+className+"/"+className+"ShaderPass.js");const ShaderPassClass=shaderPassModule[className+"ShaderPass"];const initConfig=config&&(config.initConfig||config.config||config.params)||{};const shaderPass=new ShaderPassClass(initConfig);this.composer.addPass(shaderPass);this.shaderPasses.push(shaderPass)})}setupPostProcessing(shaderPassConfigs){const{EffectComposer}=require("./EffectComposer.js");const{RenderPass}=require("./RenderPass.js");this.composer=new EffectComposer(this.renderer);this.renderPass=new RenderPass(this.scene,this.camera);this.composer.addPass(this.renderPass);this.shaderPasses=[];this.addShaderPass(shaderPassConfigs)}initPostProcessing(){}init(container){if(this.renderer){if(container){container.appendChild(this.renderer.domElement)}else if(typeof document!=="undefined"){document.body.appendChild(this.renderer.domElement)}}if(typeof window!=="undefined"){window.addEventListener("resize",()=>this.handleResize())}}start(updateCallback){if(this.isAnimating)return;this.isAnimating=true;if(updateCallback){const animateFrame=()=>{if(!this.isAnimating)return;updateCallback();this.animationFrameId=requestAnimationFrame(animateFrame)};animateFrame()}else{this.renderer.setAnimationLoop(()=>{this.update()})}}updateScene(timestamp){if(!this.isAnimating){this.isAnimating=true}this.defaultUpdate(timestamp)}update(){if(this.usePostProcessing&&this.composer){if(this.renderPass){this.renderPass.camera=this.camera}this.composer.render()}else if(this.renderer){this.renderer.render(this.scene,this.camera)}}handleResize(){this.camera.aspect=window.innerWidth/window.innerHeight;this.camera.updateProjectionMatrix();if(this.renderer){this.renderer.setSize(window.innerWidth,window.innerHeight)}if(!this.isAnimating){this.update()}}loadTextures(){const textureLoader=new THREE.TextureLoader;return Promise.all([new Promise(resolve=>{this.texture1=textureLoader.load("image/Sample1.jpg",resolve);this.texture1.colorSpace=THREE.LinearSRGBColorSpace;this.texture1.wrapS=THREE.RepeatWrapping;this.texture1.wrapT=THREE.RepeatWrapping}),new Promise(resolve=>{this.texture2=textureLoader.load("image/Sample2.jpg",resolve);this.texture2.colorSpace=THREE.LinearSRGBColorSpace;this.texture2.wrapS=THREE.RepeatWrapping;this.texture2.wrapT=THREE.RepeatWrapping})])}_applyTweenInitialState(tween){if(!tween._propertiesAreSetUp){tween.start(0)}if(!tween._valuesStart||!tween._valuesEnd){return}tween._updateProperties(tween._object,tween._valuesStart,tween._valuesEnd,0);if(typeof tween._onUpdateCallback==="function"){tween._onUpdateCallback(tween._object,0)}}_applyTweenFinalState(tween){if(!tween._propertiesAreSetUp){tween.start(0)}if(!tween._valuesStart||!tween._valuesEnd){return}tween._updateProperties(tween._object,tween._valuesStart,tween._valuesEnd,1);if(typeof tween._onUpdateCallback==="function"){tween._onUpdateCallback(tween._object,1)}}seekToTime(time){if(!this.isAnimating){this.isAnimating=true}const clampedTime=Math.max(0,Math.min(time,this.Duration));if(this._predef_seekShaderPass){this._predef_seekShaderPass(clampedTime)}if(!this.sceneObjects.tweens||this.sceneObjects.tweens.length===0){return}let notStartTweens=[];let runningTweens=[];let finishedTweens=[];for(let i=0;i<=this.sceneObjects.tweens.length-1;i++){const tween=this.sceneObjects.tweens[i];let TweenStartTime=tween._delayTime+10;let TweenEndTime=tween._delayTime+tween._duration;if(clampedTime<=TweenStartTime){notStartTweens.push({time:TweenStartTime,tween:tween})}else if(clampedTime>=TweenEndTime){finishedTweens.push({time:TweenEndTime,tween:tween})}else{runningTweens.push(tween)}}notStartTweens.sort((a,b)=>b.time-a.time);finishedTweens.sort((a,b)=>a.time-b.time);notStartTweens.forEach(item=>{this._applyTweenInitialState(item.tween)});finishedTweens.forEach(item=>{this._applyTweenFinalState(item.tween)});runningTweens.forEach(tween=>{tween.stop();tween.start(0);tween.update(clampedTime)});this.update()}setupSliders(){}updateSliders(){}setupScene(){this.initSceneObjects();this.setupSliders();this.updateSliders();this.scene.background=new THREE.Color(0);this.createPlane();this.setupAnimation();return this.sceneObjects}initSceneObjects(){this.sceneObjects={plane:null,material:null,tweens:[]}}createPlane(){const geometry=new THREE.PlaneGeometry(10,10,100,1);const material=this.createMaterial();this.sceneObjects.material=material;const plane=new THREE.Mesh(geometry,material);plane.name="Plane";this.sceneObjects.plane=plane;this.scene.add(plane)}createMaterial(){if(!this.texture1||!this.texture2){console.error("纹理未加载!");return new THREE.MeshBasicMaterial({color:16711680})}this.texture1.minFilter=THREE.LinearFilter;this.texture1.magFilter=THREE.LinearFilter;this.texture1.wrapS=THREE.ClampToEdgeWrapping;this.texture1.wrapT=THREE.ClampToEdgeWrapping;this.texture2.minFilter=THREE.LinearFilter;this.texture2.magFilter=THREE.LinearFilter;this.texture2.wrapS=THREE.ClampToEdgeWrapping;this.texture2.wrapT=THREE.ClampToEdgeWrapping;this.shaderPass=new(require("../pp/LumiCustom/CustomShaderPass.js").CustomShaderPass);var material=this.shaderPass.material;material.uniforms.tDiffuse.value=this.texture1;material.uniforms.tDiffuse1.value=this.texture2;return material}setupAnimation(){if(!this.shaderPass){console.error("着色器传递对象未创建!");return}if(typeof this.shaderPass.setParameter!=="function"){console.error(`${this.shaderPass.constructor.name} 中没有 setParameter 方法`);return}const duration=this.Duration;const tweens=[];this.sceneObjects.tweens=[];const tween1=new TWEEN.Tween({intensity:0,progress:0}).to({intensity:1,progress:.5},duration*.35).delay(duration*.15).easing(TWEEN.Easing.Linear.None).onUpdate(obj=>{for(const key in obj){this.shaderPass.setParameter(key,obj[key])}});const tween2=new TWEEN.Tween({intensity:1,progress:.5}).to({intensity:0,progress:1},duration*.35).delay(duration*.5).easing(TWEEN.Easing.Linear.None).onUpdate(obj=>{for(const key in obj){this.shaderPass.setParameter(key,obj[key])}});tweens.push(tween1,tween2);tweens.forEach(tween=>tween.start());if(tweens.length>0){if(!this.sceneObjects.tweens){this.sceneObjects.tweens=[]}this.sceneObjects.tweens.push(...tweens)}}defaultUpdate(timestamp){if(this.sceneObjects.tweens&&this.sceneObjects.tweens.length>0){this.sceneObjects.tweens.forEach(tween=>{if(tween&&typeof tween.update==="function"){tween.update(timestamp)}})}this.update()}_predef_addTopCenterBottomStyleBorder(parent,offset,texture,cutoutAreaPosition,cutoutAreaSize){const aspectRatio=this.texture1.image.width/this.texture1.image.height;const parentInitScale=parent.scale.y;const parentPosition=parent.position;const textureWidth=texture.image.width;const textureHeight=texture.image.height;const geometry=new THREE.PlaneGeometry(10,10);const textureCenter=texture.clone();textureCenter.repeat.set(1,cutoutAreaSize.y/textureHeight);textureCenter.offset.set(0,(textureHeight-cutoutAreaPosition.y-cutoutAreaSize.y)/textureHeight);const materialCenter=new THREE.MeshBasicMaterial({map:textureCenter,transparent:true,opacity:1,premultipliedAlpha:true,side:THREE.DoubleSide});materialCenter.name="PlaneCenterMaterial";const planeCenter=new THREE.Mesh(geometry,materialCenter);planeCenter.name="PlaneCenter";planeCenter.position.set(parentPosition.x+offset.x,parentPosition.y+offset.y,parentPosition.z+offset.z);planeCenter.scale.set(parentInitScale*aspectRatio/(cutoutAreaSize.x/textureWidth),parentInitScale,1);this.scene.add(planeCenter);parent.attach(planeCenter);const textureTop=texture.clone();textureTop.repeat.set(1,cutoutAreaPosition.y/textureHeight);textureTop.offset.set(0,1-cutoutAreaPosition.y/textureHeight);const materialTop=new THREE.MeshBasicMaterial({map:textureTop,transparent:true,opacity:1,premultipliedAlpha:true,side:THREE.DoubleSide});materialTop.name="PlaneTopMaterial";const scaleXTop=parentInitScale*aspectRatio/(cutoutAreaSize.x/textureWidth);const scaleYTop=scaleXTop*cutoutAreaPosition.y/textureWidth;const planeTop=new THREE.Mesh(geometry,materialTop);planeTop.name="PlaneTop";planeTop.position.set(parentPosition.x+offset.x,parentPosition.y+offset.y+parentInitScale*10*.5+scaleYTop*10*.5,parentPosition.z+offset.z);planeTop.scale.set(scaleXTop,scaleYTop,1);this.scene.add(planeTop);parent.attach(planeTop);const textureBottom=texture.clone();textureBottom.repeat.set(1,(textureHeight-cutoutAreaPosition.y-cutoutAreaSize.y)/textureHeight);textureBottom.offset.set(0,0);const materialBottom=new THREE.MeshBasicMaterial({map:textureBottom,transparent:true,opacity:1,premultipliedAlpha:true,side:THREE.DoubleSide});materialBottom.name="PlaneBottomMaterial";const scaleXBottom=parentInitScale*aspectRatio/(cutoutAreaSize.x/textureWidth);const scaleYBottom=scaleXBottom*(textureHeight-cutoutAreaPosition.y-cutoutAreaSize.y)/textureWidth;const planeBottom=new THREE.Mesh(geometry,materialBottom);planeBottom.name="PlaneBottom";planeBottom.position.set(parentPosition.x+offset.x,parentPosition.y+offset.y-parentInitScale*10*.5-scaleYBottom*10*.5,parentPosition.z+offset.z);planeBottom.scale.set(scaleXBottom,scaleYBottom,1);this.scene.add(planeBottom);parent.attach(planeBottom)}_predef_loadVideoTexture(path,loop,playbackRate){if(this.scene._amgScene==null){const video=document.createElement("video");video.src=path;video.muted=true;video.loop=loop;video.load();const videoTexture=new THREE.VideoTexture(video);videoTexture.currentTime=0;videoTexture.playbackRate=playbackRate;this.videoTexture=videoTexture;return videoTexture}else if(typeof this.scene._amgScene==="string"){return new THREE.Texture}else{const texture=new THREE.VideoTexture(path,loop,playbackRate);texture.load();return texture}}_predef_seekVideoTexture(time){if(this.videoTexture!=null){const videoTexture=this.videoTexture;const video=videoTexture.image;if(video.readyState>=2){const textureProperties=this.renderer.properties.get(videoTexture);var newTime=time/1e3*videoTexture.playbackRate;if(newTime<0){newTime=0}else if(newTime>video.duration){if(video.loop){newTime=newTime%video.duration}else{newTime=video.duration}}if(textureProperties.__version==videoTexture.version){videoTexture.currentTime=newTime;video.currentTime=videoTexture.currentTime}}}}_predef_seekShaderPass(time){if(!("shaderPasses"in this)||this.shaderPasses==null){return}this.shaderPasses.forEach(shaderPass=>{if(shaderPass.constructor.name==="AnimSeqLoadAndCropBlendShaderPass"){if(this.texture1&&this.texture1.image){const ratio=this.texture1.image.width/this.texture1.image.height;if(typeof shaderPass.setAspectRatio==="function"){shaderPass.setAspectRatio(ratio)}}}})}}exports.ScriptScene=ScriptScene;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/three-amg-wrapper.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const effect_api="undefined"!=typeof effect?effect:"undefined"!=typeof tt?tt:"undefined"!=typeof lynx?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const{getCurrentScene,setCurrentScene,clearCurrentScene}=require("./wrapper/runtime");if(typeof window==="undefined"){const mockWindow={innerWidth:720,innerHeight:1280,devicePixelRatio:1,addEventListener:function(event,callback){},requestAnimationFrame:function(callback){},cancelAnimationFrame:function(id){},removeEventListener:function(event,callback){}};const mockDocument={createElement:function(tagName){return{style:{},setAttribute:function(){},appendChild:function(){}}},body:{appendChild:function(){}}};const getGlobalObject=function(){if(typeof global!=="undefined")return global;if(typeof self!=="undefined")return self;if(typeof window!=="undefined")return window;if(typeof this!=="undefined")return this;return{}};const globalObj=getGlobalObject();globalObj.window=mockWindow;globalObj.document=mockDocument;globalObj.cancelAnimationFrame=mockWindow.cancelAnimationFrame}const THREE={};const __THREE_CONSTS=require("./wrapper/Constants");THREE.FrontSide=__THREE_CONSTS.FrontSide;THREE.BackSide=__THREE_CONSTS.BackSide;THREE.DoubleSide=__THREE_CONSTS.DoubleSide;THREE.NoBlending=__THREE_CONSTS.NoBlending;THREE.NormalBlending=__THREE_CONSTS.NormalBlending;THREE.AdditiveBlending=__THREE_CONSTS.AdditiveBlending;THREE.SubtractiveBlending=__THREE_CONSTS.SubtractiveBlending;THREE.MultiplyBlending=__THREE_CONSTS.MultiplyBlending;THREE.CustomBlending=__THREE_CONSTS.CustomBlending;THREE.RepeatWrapping=__THREE_CONSTS.RepeatWrapping;THREE.ClampToEdgeWrapping=__THREE_CONSTS.ClampToEdgeWrapping;THREE.MirroredRepeatWrapping=__THREE_CONSTS.MirroredRepeatWrapping;const Vector2Wrapper=require("./wrapper/Vector2").Vector2;const Vector3Wrapper=require("./wrapper/Vector3").Vector3;const Vector4Wrapper=require("./wrapper/Vector4").Vector4;const EulerWrapper=require("./wrapper/Euler").Euler;const ColorWrapper=require("./wrapper/Color").Color;const Matrix4Wrapper=require("./wrapper/Matrix4").Matrix4;const QuaternionWrapper=require("./wrapper/Quaternion").Quaternion;const MathUtilsWrapper=require("./wrapper/MathUtils").MathUtils;const Box3Wrapper=require("./wrapper/Box3").Box3;const Box2Wrapper=require("./wrapper/Box2").Box2;const WebGLRendererWrapper=require("./wrapper/WebGLRenderer").WebGLRenderer;const Vector2=Vector2Wrapper;const Vector3=Vector3Wrapper;const Vector4=Vector4Wrapper;const Euler=EulerWrapper;const Color=ColorWrapper;const Matrix4=Matrix4Wrapper;const Quaternion=QuaternionWrapper;const MathUtils=MathUtilsWrapper;const Box3=Box3Wrapper;const Box2=Box2Wrapper;const WebGLRenderer=WebGLRendererWrapper;const BufferGeometryWrapper=require("./wrapper/BufferGeometry").BufferGeometry;const BufferAttributeWrapper=require("./wrapper/BufferAttribute").BufferAttribute;const BoxGeometryWrapper=require("./wrapper/BoxGeometry").BoxGeometry;const PlaneGeometryWrapper=require("./wrapper/PlaneGeometry").PlaneGeometry;const SphereGeometryWrapper=require("./wrapper/SphereGeometry").SphereGeometry;const CylinderGeometryWrapper=require("./wrapper/CylinderGeometry").CylinderGeometry;const CapsuleGeometryWrapper=require("./wrapper/CapsuleGeometry").CapsuleGeometry;const ShapeWrapper=require("./wrapper/Shape").Shape;const ShapeGeometryWrapper=require("./wrapper/ShapeGeometry").ShapeGeometry;const ExtrudeGeometryWrapper=require("./wrapper/ExtrudeGeometry").ExtrudeGeometry;const CurvePathWrapper=require("./wrapper/CurvePath").CurvePath;const LineCurveWrapper=require("./wrapper/CurvePath").LineCurve;const BufferGeometry=BufferGeometryWrapper;const BufferAttribute=BufferAttributeWrapper;const BoxGeometry=BoxGeometryWrapper;const PlaneGeometry=PlaneGeometryWrapper;const SphereGeometry=SphereGeometryWrapper;const CylinderGeometry=CylinderGeometryWrapper;const CapsuleGeometry=CapsuleGeometryWrapper;const Shape=ShapeWrapper;const ShapeGeometry=ShapeGeometryWrapper;const ExtrudeGeometry=ExtrudeGeometryWrapper;const CurvePath=CurvePathWrapper;const LineCurve=LineCurveWrapper;const TextureWrapper=require("./wrapper/Texture").Texture;const VideoTextureWrapper=require("./wrapper/Texture").VideoTexture;const TextureLoaderWrapper=require("./wrapper/Texture").TextureLoader;const Texture=TextureWrapper;const VideoTexture=VideoTextureWrapper;const TextureLoader=TextureLoaderWrapper;const MaterialWrapper=require("./wrapper/Material").Material;const MeshBasicMaterialWrapper=require("./wrapper/MeshBasicMaterial").MeshBasicMaterial;const ShaderMaterialWrapper=require("./wrapper/ShaderMaterial").ShaderMaterial;const Material=MaterialWrapper;const MeshBasicMaterial=MeshBasicMaterialWrapper;const ShaderMaterial=ShaderMaterialWrapper;const Object3DWrapper=require("./wrapper/Object3D").Object3D;const GroupWrapper=require("./wrapper/Group").Group;const MeshWrapper=require("./wrapper/Mesh").MeshWrapper;const PerspectiveCameraWrapper=require("./wrapper/PerspectiveCamera").PerspectiveCamera;const Object3D=Object3DWrapper;const Group=GroupWrapper;const Mesh=MeshWrapper;const PerspectiveCamera=PerspectiveCameraWrapper;class Scene{constructor(){this._objects=[];setCurrentScene(this);console.log("AMG scene created")}add(...objects){for(let i=0;i<objects.length;i++){const object=objects[i];if(!object){console.warn("Scene: 尝试添加空对象");continue}if(object._amgEntity){if(this._objects.indexOf(object)===-1){this._objects.push(object);if(this._amgScene){if(object._transform.parent){object._transform.parent.removeTransform(object._transform)}object._transform.parent=null;this._amgScene.addEntity(object._amgEntity)}console.log("Scene: added object to scene:",object._amgEntity.name)}else{console.log("Scene: object already exists:",object._amgEntity.name)}}else{console.warn("Scene: 添加到场景的对象没有_amgEntity属性")}}}remove(object){const index=this._objects.indexOf(object);if(index!==-1){this._objects.splice(index,1);console.log("Scene: removed object from scene, not delete AMG entity.")}}delete(object){const index=this._objects.indexOf(object);if(index!==-1){this._objects.splice(index,1);if(object._amgEntity){this._amgScene.removeEntity(object._amgEntity)}console.log("Scene: delete object from scene, delete AMG entity.")}}update(){this._objects.forEach(obj=>obj.update&&obj.update())}seekToTime(time){this._objects.forEach(obj=>obj.seekToTime&&obj.seekToTime(time))}dispose(){console.log("Scene: 开始清理场景资源");while(this._objects.length>0){const object=this._objects[0];this.delete(object);if(object.dispose&&typeof object.dispose==="function"){object.dispose()}if(object.geometry&&object.geometry.dispose){object.geometry.dispose()}if(object.material){if(Array.isArray(object.material)){object.material.forEach(material=>{if(material.dispose)material.dispose()})}else if(object.material.dispose){object.material.dispose()}}}if(this._amgScene){this._amgScene=null}this._objects=[];if(getCurrentScene()===this){clearCurrentScene()}console.log("Scene: 场景资源清理完成")}}class QuadraticBezierCurve3{constructor(p0,p1,p2){this.p0=p0;this.p1=p1;this.p2=p2}getPoint(t){const u=1-t;const tt=t*t;const uu=u*u;const ut2=2*u*t;return new Vector3(uu*this.p0.x+ut2*this.p1.x+tt*this.p2.x,uu*this.p0.y+ut2*this.p1.y+tt*this.p2.y,uu*this.p0.z+ut2*this.p1.z+tt*this.p2.z)}getPoints(divisions){const points=[];for(let i=0;i<=divisions;i++){points.push(this.getPoint(i/divisions))}return points}}THREE.Vector2=Vector2;THREE.Vector3=Vector3;THREE.Vector4=Vector4;THREE.Euler=Euler;THREE.Color=Color;THREE.Matrix4=Matrix4;THREE.Quaternion=Quaternion;THREE.QuadraticBezierCurve3=QuadraticBezierCurve3;THREE.Box3=Box3;THREE.Box2=Box2;THREE.MathUtils=MathUtils;THREE.Scene=Scene;THREE.WebGLRenderer=WebGLRenderer;THREE.BufferGeometry=BufferGeometry;THREE.BufferAttribute=BufferAttribute;THREE.Float32BufferAttribute=BufferAttribute;THREE.BoxGeometry=BoxGeometry;THREE.PlaneGeometry=PlaneGeometry;THREE.SphereGeometry=SphereGeometry;THREE.CylinderGeometry=CylinderGeometry;THREE.CapsuleGeometry=CapsuleGeometry;THREE.Shape=Shape;THREE.ShapeGeometry=ShapeGeometry;THREE.ExtrudeGeometry=ExtrudeGeometry;THREE.CurvePath=CurvePath;THREE.LineCurve=LineCurve;THREE.Material=Material;THREE.MeshBasicMaterial=MeshBasicMaterial;THREE.ShaderMaterial=ShaderMaterial;THREE.Texture=Texture;THREE.VideoTexture=VideoTexture;THREE.TextureLoader=TextureLoader;THREE.Object3D=Group;THREE.Group=Group;THREE.Mesh=Mesh;THREE.PerspectiveCamera=PerspectiveCamera;exports.THREE=THREE;exports.getCurrentScene=getCurrentScene;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/tween.js ADDED
@@ -0,0 +1 @@
 
 
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});var Easing=Object.freeze({Linear:Object.freeze({None:function(amount){return amount},In:function(amount){return amount},Out:function(amount){return amount},InOut:function(amount){return amount}}),Quadratic:Object.freeze({In:function(amount){return amount*amount},Out:function(amount){return amount*(2-amount)},InOut:function(amount){if((amount*=2)<1){return.5*amount*amount}return-.5*(--amount*(amount-2)-1)}}),Cubic:Object.freeze({In:function(amount){return amount*amount*amount},Out:function(amount){return--amount*amount*amount+1},InOut:function(amount){if((amount*=2)<1){return.5*amount*amount*amount}return.5*((amount-=2)*amount*amount+2)}}),Quartic:Object.freeze({In:function(amount){return amount*amount*amount*amount},Out:function(amount){return 1- --amount*amount*amount*amount},InOut:function(amount){if((amount*=2)<1){return.5*amount*amount*amount*amount}return-.5*((amount-=2)*amount*amount*amount-2)}}),Quintic:Object.freeze({In:function(amount){return amount*amount*amount*amount*amount},Out:function(amount){return--amount*amount*amount*amount*amount+1},InOut:function(amount){if((amount*=2)<1){return.5*amount*amount*amount*amount*amount}return.5*((amount-=2)*amount*amount*amount*amount+2)}}),Sinusoidal:Object.freeze({In:function(amount){return 1-Math.sin((1-amount)*Math.PI/2)},Out:function(amount){return Math.sin(amount*Math.PI/2)},InOut:function(amount){return.5*(1-Math.sin(Math.PI*(.5-amount)))}}),Exponential:Object.freeze({In:function(amount){return amount===0?0:Math.pow(1024,amount-1)},Out:function(amount){return amount===1?1:1-Math.pow(2,-10*amount)},InOut:function(amount){if(amount===0){return 0}if(amount===1){return 1}if((amount*=2)<1){return.5*Math.pow(1024,amount-1)}return.5*(-Math.pow(2,-10*(amount-1))+2)}}),Circular:Object.freeze({In:function(amount){return 1-Math.sqrt(1-amount*amount)},Out:function(amount){return Math.sqrt(1- --amount*amount)},InOut:function(amount){if((amount*=2)<1){return-.5*(Math.sqrt(1-amount*amount)-1)}return.5*(Math.sqrt(1-(amount-=2)*amount)+1)}}),Elastic:Object.freeze({In:function(amount){if(amount===0){return 0}if(amount===1){return 1}return-Math.pow(2,10*(amount-1))*Math.sin((amount-1.1)*5*Math.PI)},Out:function(amount){if(amount===0){return 0}if(amount===1){return 1}return Math.pow(2,-10*amount)*Math.sin((amount-.1)*5*Math.PI)+1},InOut:function(amount){if(amount===0){return 0}if(amount===1){return 1}amount*=2;if(amount<1){return-.5*Math.pow(2,10*(amount-1))*Math.sin((amount-1.1)*5*Math.PI)}return.5*Math.pow(2,-10*(amount-1))*Math.sin((amount-1.1)*5*Math.PI)+1}}),Back:Object.freeze({In:function(amount){var s=1.70158;return amount===1?1:amount*amount*((s+1)*amount-s)},Out:function(amount){var s=1.70158;return amount===0?0:--amount*amount*((s+1)*amount+s)+1},InOut:function(amount){var s=1.70158*1.525;if((amount*=2)<1){return.5*(amount*amount*((s+1)*amount-s))}return.5*((amount-=2)*amount*((s+1)*amount+s)+2)}}),Bounce:Object.freeze({In:function(amount){return 1-Easing.Bounce.Out(1-amount)},Out:function(amount){if(amount<1/2.75){return 7.5625*amount*amount}else if(amount<2/2.75){return 7.5625*(amount-=1.5/2.75)*amount+.75}else if(amount<2.5/2.75){return 7.5625*(amount-=2.25/2.75)*amount+.9375}else{return 7.5625*(amount-=2.625/2.75)*amount+.984375}},InOut:function(amount){if(amount<.5){return Easing.Bounce.In(amount*2)*.5}return Easing.Bounce.Out(amount*2-1)*.5+.5}}),generatePow:function(power){if(power===void 0){power=4}power=power<Number.EPSILON?Number.EPSILON:power;power=power>1e4?1e4:power;return{In:function(amount){return Math.pow(amount,power)},Out:function(amount){return 1-Math.pow(1-amount,power)},InOut:function(amount){if(amount<.5){return Math.pow(amount*2,power)/2}return(1-Math.pow(2-amount*2,power))/2+.5}}}});var now=function(){if(typeof process!=="undefined"&&process.hrtime){if(!now._nodeStartTime){now._nodeStartTime=process.hrtime()}var hrTime=process.hrtime(now._nodeStartTime);return hrTime[0]*1e3+hrTime[1]/1e6}if(typeof now._startTime==="undefined"){now._startTime=Date.now();now._lastReturned=0}var elapsed=Date.now()-now._startTime;if(elapsed<=now._lastReturned){now._lastReturned+=.001}else{now._lastReturned=elapsed}return now._lastReturned};function setNow(nowFunction){_nowFunc=nowFunction}var Group=function(){function Group(){var tweens=[];for(var _i=0;_i<arguments.length;_i++){tweens[_i]=arguments[_i]}this._tweens={};this._tweensAddedDuringUpdate={};this.add.apply(this,tweens)}Group.prototype.getAll=function(){var _this=this;return Object.keys(this._tweens).map(function(tweenId){return _this._tweens[tweenId]})};Group.prototype.removeAll=function(){this._tweens={}};Group.prototype.add=function(){var _a;var tweens=[];for(var _i=0;_i<arguments.length;_i++){tweens[_i]=arguments[_i]}for(var _b=0,tweens_1=tweens;_b<tweens_1.length;_b++){var tween=tweens_1[_b];(_a=tween._group)===null||_a===void 0?void 0:_a.remove(tween);tween._group=this;this._tweens[tween.getId()]=tween;this._tweensAddedDuringUpdate[tween.getId()]=tween}};Group.prototype.remove=function(){var tweens=[];for(var _i=0;_i<arguments.length;_i++){tweens[_i]=arguments[_i]}for(var _a=0,tweens_2=tweens;_a<tweens_2.length;_a++){var tween=tweens_2[_a];tween._group=undefined;delete this._tweens[tween.getId()];delete this._tweensAddedDuringUpdate[tween.getId()]}};Group.prototype.allStopped=function(){return this.getAll().every(function(tween){return!tween.isPlaying()})};Group.prototype.update=function(time,preserve){if(time===void 0){time=now()}if(preserve===void 0){preserve=true}var tweenIds=Object.keys(this._tweens);if(tweenIds.length===0)return;while(tweenIds.length>0){this._tweensAddedDuringUpdate={};for(var i=0;i<tweenIds.length;i++){var tween=this._tweens[tweenIds[i]];var autoStart=!preserve;if(tween&&tween.update(time,autoStart)===false&&!preserve)this.remove(tween)}tweenIds=Object.keys(this._tweensAddedDuringUpdate)}};Group.prototype.onComplete=function(callback){var group=this.getAll();group.forEach(function(tween){var prevCallback=tween.getCompleteCallback();tween.onComplete(function(){prevCallback===null||prevCallback===void 0?void 0:prevCallback(tween);var completedGroup=group.filter(function(tween){return!tween.isPlaying()});if(completedGroup.length===group.length-1)callback(group)})})};return Group}();var Interpolation={Linear:function(v,k){var m=v.length-1;var f=m*k;var i=Math.floor(f);var fn=Interpolation.Utils.Linear;if(k<0){return fn(v[0],v[1],f)}if(k>1){return fn(v[m],v[m-1],m-f)}return fn(v[i],v[i+1>m?m:i+1],f-i)},Bezier:function(v,k){var b=0;var n=v.length-1;var pw=Math.pow;var bn=Interpolation.Utils.Bernstein;for(var i=0;i<=n;i++){b+=pw(1-k,n-i)*pw(k,i)*v[i]*bn(n,i)}return b},CatmullRom:function(v,k){var m=v.length-1;var f=m*k;var i=Math.floor(f);var fn=Interpolation.Utils.CatmullRom;if(v[0]===v[m]){if(k<0){i=Math.floor(f=m*(1+k))}return fn(v[(i-1+m)%m],v[i],v[(i+1)%m],v[(i+2)%m],f-i)}else{if(k<0){return v[0]-(fn(v[0],v[0],v[1],v[1],-f)-v[0])}if(k>1){return v[m]-(fn(v[m],v[m],v[m-1],v[m-1],f-m)-v[m])}return fn(v[i?i-1:0],v[i],v[m<i+1?m:i+1],v[m<i+2?m:i+2],f-i)}},Utils:{Linear:function(p0,p1,t){return(p1-p0)*t+p0},Bernstein:function(n,i){var fc=Interpolation.Utils.Factorial;return fc(n)/fc(i)/fc(n-i)},Factorial:function(){var a=[1];return function(n){var s=1;if(a[n]){return a[n]}for(var i=n;i>1;i--){s*=i}a[n]=s;return s}}(),CatmullRom:function(p0,p1,p2,p3,t){var v0=(p2-p0)*.5;var v1=(p3-p1)*.5;var t2=t*t;var t3=t*t2;return(2*p1-2*p2+v0+v1)*t3+(-3*p1+3*p2-2*v0-v1)*t2+v0*t+p1}}};var Sequence=function(){function Sequence(){}Sequence.nextId=function(){return Sequence._nextId++};Sequence._nextId=0;return Sequence}();var mainGroup=new Group;var Tween=function(){function Tween(object,group){this._isPaused=false;this._pauseStart=0;this._valuesStart={};this._valuesEnd={};this._valuesStartRepeat={};this._duration=1e3;this._isDynamic=false;this._initialRepeat=0;this._repeat=0;this._yoyo=false;this._isPlaying=false;this._reversed=false;this._delayTime=0;this._startTime=0;this._easingFunction=Easing.Linear.None;this._interpolationFunction=Interpolation.Linear;this._chainedTweens=[];this._onStartCallbackFired=false;this._onEveryStartCallbackFired=false;this._id=Sequence.nextId();this._isChainStopped=false;this._propertiesAreSetUp=false;this._goToEnd=false;this._object=object;if(typeof group==="object"){this._group=group;group.add(this)}else if(group===true){this._group=mainGroup;mainGroup.add(this)}}Tween.prototype.getId=function(){return this._id};Tween.prototype.getCompleteCallback=function(){return this._onCompleteCallback};Tween.prototype.isPlaying=function(){return this._isPlaying};Tween.prototype.isPaused=function(){return this._isPaused};Tween.prototype.getDuration=function(){return this._duration};Tween.prototype.to=function(target,duration){if(duration===void 0){duration=1e3}if(this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");this._valuesEnd=target;this._propertiesAreSetUp=false;this._duration=duration<0?0:duration;return this};Tween.prototype.duration=function(duration){if(duration===void 0){duration=1e3}this._duration=duration<0?0:duration;return this};Tween.prototype.dynamic=function(dynamic){if(dynamic===void 0){dynamic=false}this._isDynamic=dynamic;return this};Tween.prototype.start=function(time,overrideStartingValues){if(time===void 0){time=now()}if(overrideStartingValues===void 0){overrideStartingValues=false}if(this._isPlaying){return this}this._repeat=this._initialRepeat;if(this._reversed){this._reversed=false;for(var property in this._valuesStartRepeat){this._swapEndStartRepeatValues(property);this._valuesStart[property]=this._valuesStartRepeat[property]}}this._isPlaying=true;this._isPaused=false;this._onStartCallbackFired=false;this._onEveryStartCallbackFired=false;this._isChainStopped=false;this._startTime=time;this._startTime+=this._delayTime;if(!this._propertiesAreSetUp||overrideStartingValues){this._propertiesAreSetUp=true;if(!this._isDynamic){var tmp={};for(var prop in this._valuesEnd)tmp[prop]=this._valuesEnd[prop];this._valuesEnd=tmp}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,overrideStartingValues)}return this};Tween.prototype.startFromCurrentValues=function(time){return this.start(time,true)};Tween.prototype._setupProperties=function(_object,_valuesStart,_valuesEnd,_valuesStartRepeat,overrideStartingValues){for(var property in _valuesEnd){var startValue=_object[property];var startValueIsArray=Array.isArray(startValue);var propType=startValueIsArray?"array":typeof startValue;var isInterpolationList=!startValueIsArray&&Array.isArray(_valuesEnd[property]);if(propType==="undefined"||propType==="function"){continue}if(isInterpolationList){var endValues=_valuesEnd[property];if(endValues.length===0){continue}var temp=[startValue];for(var i=0,l=endValues.length;i<l;i+=1){var value=this._handleRelativeValue(startValue,endValues[i]);if(isNaN(value)){isInterpolationList=false;console.warn("Found invalid interpolation list. Skipping.");break}temp.push(value)}if(isInterpolationList){_valuesEnd[property]=temp}}if((propType==="object"||startValueIsArray)&&startValue&&!isInterpolationList){_valuesStart[property]=startValueIsArray?[]:{};var nestedObject=startValue;for(var prop in nestedObject){_valuesStart[property][prop]=nestedObject[prop]}_valuesStartRepeat[property]=startValueIsArray?[]:{};var endValues=_valuesEnd[property];if(!this._isDynamic){var tmp={};for(var prop in endValues)tmp[prop]=endValues[prop];_valuesEnd[property]=endValues=tmp}this._setupProperties(nestedObject,_valuesStart[property],endValues,_valuesStartRepeat[property],overrideStartingValues)}else{if(typeof _valuesStart[property]==="undefined"||overrideStartingValues){_valuesStart[property]=startValue}if(!startValueIsArray){_valuesStart[property]*=1}if(isInterpolationList){_valuesStartRepeat[property]=_valuesEnd[property].slice().reverse()}else{_valuesStartRepeat[property]=_valuesStart[property]||0}}}};Tween.prototype.stop=function(){if(!this._isChainStopped){this._isChainStopped=true;this.stopChainedTweens()}if(!this._isPlaying){return this}this._isPlaying=false;this._isPaused=false;if(this._onStopCallback){this._onStopCallback(this._object)}return this};Tween.prototype.end=function(){this._goToEnd=true;this.update(this._startTime+this._duration);return this};Tween.prototype.pause=function(time){if(time===void 0){time=now()}if(this._isPaused||!this._isPlaying){return this}this._isPaused=true;this._pauseStart=time;return this};Tween.prototype.resume=function(time){if(time===void 0){time=now()}if(!this._isPaused||!this._isPlaying){return this}this._isPaused=false;this._startTime+=time-this._pauseStart;this._pauseStart=0;return this};Tween.prototype.stopChainedTweens=function(){for(var i=0,numChainedTweens=this._chainedTweens.length;i<numChainedTweens;i++){this._chainedTweens[i].stop()}return this};Tween.prototype.group=function(group){if(!group){console.warn("tween.group() without args has been removed, use group.add(tween) instead.");return this}group.add(this);return this};Tween.prototype.remove=function(){var _a;(_a=this._group)===null||_a===void 0?void 0:_a.remove(this);return this};Tween.prototype.delay=function(amount){if(amount===void 0){amount=0}this._delayTime=amount;return this};Tween.prototype.repeat=function(times){if(times===void 0){times=0}this._initialRepeat=times;this._repeat=times;return this};Tween.prototype.repeatDelay=function(amount){this._repeatDelayTime=amount;return this};Tween.prototype.yoyo=function(yoyo){if(yoyo===void 0){yoyo=false}this._yoyo=yoyo;return this};Tween.prototype.easing=function(easingFunction){if(easingFunction===void 0){easingFunction=Easing.Linear.None}this._easingFunction=easingFunction;return this};Tween.prototype.interpolation=function(interpolationFunction){if(interpolationFunction===void 0){interpolationFunction=Interpolation.Linear}this._interpolationFunction=interpolationFunction;return this};Tween.prototype.chain=function(){var tweens=[];for(var _i=0;_i<arguments.length;_i++){tweens[_i]=arguments[_i]}this._chainedTweens=tweens;return this};Tween.prototype.onStart=function(callback){this._onStartCallback=callback;return this};Tween.prototype.onEveryStart=function(callback){this._onEveryStartCallback=callback;return this};Tween.prototype.onUpdate=function(callback){this._onUpdateCallback=callback;return this};Tween.prototype.onRepeat=function(callback){this._onRepeatCallback=callback;return this};Tween.prototype.onComplete=function(callback){this._onCompleteCallback=callback;return this};Tween.prototype.onStop=function(callback){this._onStopCallback=callback;return this};Tween.prototype.update=function(time,autoStart){var _this=this;var _a;if(time===void 0){time=now()}if(autoStart===void 0){autoStart=Tween.autoStartOnUpdate}if(this._isPaused)return true;var property;if(!this._goToEnd&&!this._isPlaying){if(autoStart)this.start(time,true);else return false}this._goToEnd=false;if(time<this._startTime){return true}if(this._onStartCallbackFired===false){if(this._onStartCallback){this._onStartCallback(this._object)}this._onStartCallbackFired=true}if(this._onEveryStartCallbackFired===false){if(this._onEveryStartCallback){this._onEveryStartCallback(this._object)}this._onEveryStartCallbackFired=true}var elapsedTime=time-this._startTime;var durationAndDelay=this._duration+((_a=this._repeatDelayTime)!==null&&_a!==void 0?_a:this._delayTime);var totalTime=this._duration+this._repeat*durationAndDelay;var calculateElapsedPortion=function(){if(_this._duration===0)return 1;if(elapsedTime>totalTime){return 1}var timesRepeated=Math.trunc(elapsedTime/durationAndDelay);var timeIntoCurrentRepeat=elapsedTime-timesRepeated*durationAndDelay;var portion=Math.min(timeIntoCurrentRepeat/_this._duration,1);if(portion===0&&elapsedTime===_this._duration){return 1}return portion};var elapsed=calculateElapsedPortion();var value=this._easingFunction(elapsed);this._updateProperties(this._object,this._valuesStart,this._valuesEnd,value);if(this._onUpdateCallback){this._onUpdateCallback(this._object,elapsed)}if(this._duration===0||elapsedTime>=this._duration){if(this._repeat>0){var completeCount=Math.min(Math.trunc((elapsedTime-this._duration)/durationAndDelay)+1,this._repeat);if(isFinite(this._repeat)){this._repeat-=completeCount}for(property in this._valuesStartRepeat){if(!this._yoyo&&typeof this._valuesEnd[property]==="string"){this._valuesStartRepeat[property]=this._valuesStartRepeat[property]+parseFloat(this._valuesEnd[property])}if(this._yoyo){this._swapEndStartRepeatValues(property)}this._valuesStart[property]=this._valuesStartRepeat[property]}if(this._yoyo){this._reversed=!this._reversed}this._startTime+=durationAndDelay*completeCount;if(this._onRepeatCallback){this._onRepeatCallback(this._object)}this._onEveryStartCallbackFired=false;return true}else{if(this._onCompleteCallback){this._onCompleteCallback(this._object)}for(var i=0,numChainedTweens=this._chainedTweens.length;i<numChainedTweens;i++){this._chainedTweens[i].start(this._startTime+this._duration,false)}this._isPlaying=false;return false}}return true};Tween.prototype._updateProperties=function(_object,_valuesStart,_valuesEnd,value){for(var property in _valuesEnd){if(_valuesStart[property]===undefined){continue}var start=_valuesStart[property]||0;var end=_valuesEnd[property];var startIsArray=Array.isArray(_object[property]);var endIsArray=Array.isArray(end);var isInterpolationList=!startIsArray&&endIsArray;if(isInterpolationList){_object[property]=this._interpolationFunction(end,value)}else if(typeof end==="object"&&end){this._updateProperties(_object[property],start,end,value)}else{end=this._handleRelativeValue(start,end);if(typeof end==="number"){_object[property]=start+(end-start)*value}}}};Tween.prototype._handleRelativeValue=function(start,end){if(typeof end!=="string"){return end}if(end.charAt(0)==="+"||end.charAt(0)==="-"){return start+parseFloat(end)}return parseFloat(end)};Tween.prototype._swapEndStartRepeatValues=function(property){var tmp=this._valuesStartRepeat[property];var endValue=this._valuesEnd[property];if(typeof endValue==="string"){this._valuesStartRepeat[property]=this._valuesStartRepeat[property]+parseFloat(endValue)}else{this._valuesStartRepeat[property]=this._valuesEnd[property]}this._valuesEnd[property]=tmp};Tween.autoStartOnUpdate=false;return Tween}();var VERSION="25.0.0";var nextId=Sequence.nextId;var TWEEN=mainGroup;var getAll=TWEEN.getAll.bind(TWEEN);var removeAll=TWEEN.removeAll.bind(TWEEN);var add=TWEEN.add.bind(TWEEN);var remove=TWEEN.remove.bind(TWEEN);var update=TWEEN.update.bind(TWEEN);var exports$1={Easing:Easing,Group:Group,Interpolation:Interpolation,now:now,setNow:setNow,Sequence:Sequence,nextId:nextId,Tween:Tween,VERSION:VERSION,getAll:getAll,removeAll:removeAll,add:add,remove:remove,update:update};exports.Easing=Easing;exports.Group=Group;exports.Interpolation=Interpolation;exports.Sequence=Sequence;exports.Tween=Tween;exports.VERSION=VERSION;exports.add=add;exports.default=exports$1;exports.getAll=getAll;exports.nextId=nextId;exports.now=now;exports.remove=remove;exports.removeAll=removeAll;exports.setNow=setNow;exports.update=update;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Box2.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const{Vector2}=require("./Vector2");class Box2{constructor(min,max){this.min=min!==undefined?min:new Vector2(Infinity,Infinity);this.max=max!==undefined?max:new Vector2(-Infinity,-Infinity)}set(min,max){this.min.copy(min);this.max.copy(max);return this}makeEmpty(){this.min.x=this.min.y=Infinity;this.max.x=this.max.y=-Infinity;return this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(target){if(target===undefined){target=new Vector2}if(this.isEmpty()){return target.set(0,0)}target.x=(this.min.x+this.max.x)*.5;target.y=(this.min.y+this.max.y)*.5;return target}getSize(target){if(target===undefined){target=new Vector2}if(this.isEmpty()){return target.set(0,0)}target.x=this.max.x-this.min.x;target.y=this.max.y-this.min.y;return target}expandByPoint(point){if(point.x<this.min.x)this.min.x=point.x;if(point.y<this.min.y)this.min.y=point.y;if(point.x>this.max.x)this.max.x=point.x;if(point.y>this.max.y)this.max.y=point.y;return this}setFromPoints(points){this.makeEmpty();for(let i=0;i<points.length;i++){this.expandByPoint(points[i])}return this}expandByVector(vector){this.min.x-=vector.x;this.min.y-=vector.y;this.max.x+=vector.x;this.max.y+=vector.y;return this}expandByScalar(scalar){this.min.x-=scalar;this.min.y-=scalar;this.max.x+=scalar;this.max.y+=scalar;return this}union(box){if(box.min.x<this.min.x)this.min.x=box.min.x;if(box.min.y<this.min.y)this.min.y=box.min.y;if(box.max.x>this.max.x)this.max.x=box.max.x;if(box.max.y>this.max.y)this.max.y=box.max.y;return this}intersect(box){this.min.x=Math.max(this.min.x,box.min.x);this.min.y=Math.max(this.min.y,box.min.y);this.max.x=Math.min(this.max.x,box.max.x);this.max.y=Math.min(this.max.y,box.max.y);if(this.isEmpty())this.makeEmpty();return this}translate(offset){this.min.x+=offset.x;this.min.y+=offset.y;this.max.x+=offset.x;this.max.y+=offset.y;return this}copy(box){this.min.copy(box.min);this.max.copy(box.max);return this}clone(){return(new Box2).copy(this)}containsPoint(point){return point.x>=this.min.x&&point.x<=this.max.x&&point.y>=this.min.y&&point.y<=this.max.y}containsBox(box){return this.min.x<=box.min.x&&box.max.x<=this.max.x&&this.min.y<=box.min.y&&box.max.y<=this.max.y}intersectsBox(box){return!(box.max.x<this.min.x||box.min.x>this.max.x||box.max.y<this.min.y||box.min.y>this.max.y)}clampPoint(point,target){if(target===undefined){target=new Vector2}target.x=Math.max(this.min.x,Math.min(this.max.x,point.x));target.y=Math.max(this.min.y,Math.min(this.max.y,point.y));return target}distanceToPoint(point){const clampedPoint=new Vector2;this.clampPoint(point,clampedPoint);return clampedPoint.distanceTo(point)}equals(box){return box.min.equals(this.min)&&box.max.equals(this.max)}}exports.Box2=Box2;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Box3.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const{Vector3}=require("./Vector3");class Box3{constructor(min,max){this.min=min!==undefined?min:new Vector3(Infinity,Infinity,Infinity);this.max=max!==undefined?max:new Vector3(-Infinity,-Infinity,-Infinity)}set(min,max){this.min.copy(min);this.max.copy(max);return this}makeEmpty(){this.min.x=this.min.y=this.min.z=Infinity;this.max.x=this.max.y=this.max.z=-Infinity;return this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(target){if(target===undefined){target=new Vector3}return this.isEmpty()?target.set(0,0,0):target.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(target){if(target===undefined){target=new Vector3}return this.isEmpty()?target.set(0,0,0):target.subVectors(this.max,this.min)}expandByPoint(point){this.min.min(point);this.max.max(point);return this}setFromPoints(points){this.makeEmpty();for(let i=0;i<points.length;i++){this.expandByPoint(points[i])}return this}setFromBufferAttribute(attribute){this.makeEmpty();const array=attribute.array;const itemSize=attribute.itemSize;const count=attribute.count;for(let i=0;i<count;i++){const offset=i*itemSize;const x=array[offset];const y=array[offset+1];const z=itemSize>=3?array[offset+2]:0;if(x<this.min.x)this.min.x=x;if(y<this.min.y)this.min.y=y;if(z<this.min.z)this.min.z=z;if(x>this.max.x)this.max.x=x;if(y>this.max.y)this.max.y=y;if(z>this.max.z)this.max.z=z}return this}setFromObject(object){this.makeEmpty();return this.expandByObject(object)}expandByObject(object){object.updateWorldMatrix(false,false);const geometry=object.geometry;if(geometry!==undefined){if(geometry.boundingBox===null||geometry.boundingBox===undefined){geometry.computeBoundingBox()}const box=new Box3;box.copy(geometry.boundingBox);box.applyMatrix4(object.matrixWorld);this.union(box)}const children=object.children;if(children){for(let i=0;i<children.length;i++){this.expandByObject(children[i])}}return this}applyMatrix4(matrix){if(this.isEmpty())return this;const points=[new Vector3(this.min.x,this.min.y,this.min.z).applyMatrix4(matrix),new Vector3(this.min.x,this.min.y,this.max.z).applyMatrix4(matrix),new Vector3(this.min.x,this.max.y,this.min.z).applyMatrix4(matrix),new Vector3(this.min.x,this.max.y,this.max.z).applyMatrix4(matrix),new Vector3(this.max.x,this.min.y,this.min.z).applyMatrix4(matrix),new Vector3(this.max.x,this.min.y,this.max.z).applyMatrix4(matrix),new Vector3(this.max.x,this.max.y,this.min.z).applyMatrix4(matrix),new Vector3(this.max.x,this.max.y,this.max.z).applyMatrix4(matrix)];this.setFromPoints(points);return this}union(box){this.min.min(box.min);this.max.max(box.max);return this}copy(box){this.min.copy(box.min);this.max.copy(box.max);return this}clone(){return(new Box3).copy(this)}containsPoint(point){return point.x>=this.min.x&&point.x<=this.max.x&&point.y>=this.min.y&&point.y<=this.max.y&&point.z>=this.min.z&&point.z<=this.max.z}intersectsBox(box){return!(box.max.x<this.min.x||box.min.x>this.max.x||box.max.y<this.min.y||box.min.y>this.max.y||box.max.z<this.min.z||box.min.z>this.max.z)}}exports.Box3=Box3;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");class BoxGeometry extends BufferGeometry{constructor(width=1,height=1,depth=1,widthSegments=1,heightSegments=1,depthSegments=1){super();this.width=width;this.height=height;this.depth=depth;const scene=getCurrentScene();if(scene){if(widthSegments>5&&heightSegments>5&&depthSegments>5){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/BoxHighResolution.mesh")}else{this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Box.mesh").clone()}}else{console.warn("BoxGeometry: 无法加载Box.mesh,scene未创建")}let vertexData=this._amgObject.getVertexArray();let uvData=this._amgObject.getUvArray();let vertices=new Float32Array(vertexData.size()*3);let uvs=new Float32Array(uvData.size()*2);for(let i=0;i<vertexData.size();i++){vertices[i*3]=vertexData.get(i).x;vertices[i*3+1]=vertexData.get(i).y;vertices[i*3+2]=vertexData.get(i).z;uvs[i*2]=uvData.get(i).x;uvs[i*2+1]=uvData.get(i).y}this.initAttribute("position",new BufferAttribute(vertices,3));this.initAttribute("uv",new BufferAttribute(uvs,2));this.scale(width,height,depth)}getAttribute(name){if(name=="position"){let data=this._amgObject.getVertexArray();let array=new Float32Array(data.size()*3);for(let i=0;i<data.size();i++){array[i*3]=data.get(i).x;array[i*3+1]=data.get(i).y;array[i*3+2]=data.get(i).z}const bufferAttribute=new BufferAttribute(array,3);bufferAttribute.setNameAndGeometry("position",this);return bufferAttribute}if(name=="uv"){let data=this._amgObject.getUvArray();let array=new Float32Array(data.size()*2);for(let i=0;i<data.size();i++){array[i*2]=data.get(i).x;array[i*2+1]=data.get(i).y}const bufferAttribute=new BufferAttribute(array,2);bufferAttribute.setNameAndGeometry("uv",this);return bufferAttribute}return null}clone(){const clonedGeometry=new BoxGeometry(this.width,this.height,this.depth,this.widthSegments,this.heightSegments,this.depthSegments);clonedGeometry._amgObject=this._amgObject.clone();return clonedGeometry}}exports.BoxGeometry=BoxGeometry;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/BufferAttribute.js ADDED
@@ -0,0 +1 @@
 
 
1
+ class BufferAttribute{constructor(array,itemSize,normalized=false){this.array=array;this.itemSize=itemSize;this.count=array.length/itemSize;this.normalized=normalized;this._needsUpdate=false;this.length=array.length;this._amgGeometry=null}set needsUpdate(value){this._needsUpdate=value;if(value&&this._amgGeometry&&this._amgGeometry._amgObject){this._updateToAMG()}}get needsUpdate(){return this._needsUpdate}setNameAndGeometry(name,geometry){this._name=name;this._amgGeometry=geometry}forceUpdateToAMG(){this._updateToAMG()}_updateToAMG(){if(!this._amgGeometry||!this._amgGeometry._amgObject){console.warn("BufferAttribute: 无法更新到AMG对象,几何体引用不存在");return}try{const amgObj=this._amgGeometry._amgObject;if(this.itemSize==2&&this._name=="uv"){const uvArray=[];for(let i=0;i<this.array.length;i+=2){uvArray.push(new effect.Amaz.Vector2f(this.array[i],this.array[i+1]))}amgObj.setUvArray(0,uvArray);this._needsUpdate=false;return}else if(this.itemSize==3&&this._name=="position"){const buffer=new effect.Amaz.FloatVector;for(let i=0;i<this.array.length;i++)buffer.pushBack(this.array[i]);amgObj.setAttributeData(effect.Amaz.VertexAttribType.POSITION,buffer,0,this.array.length/this.itemSize);this._needsUpdate=false;return}else if(this._name=="colorA"||this._name=="colorR"||this._name=="colorG"||this._name=="colorB"){const colorArrayR=this._amgGeometry.getAttribute("colorR");const colorArrayG=this._amgGeometry.getAttribute("colorG");const colorArrayB=this._amgGeometry.getAttribute("colorB");const colorArrayA=this._amgGeometry.getAttribute("colorA");if(colorArrayR&&colorArrayG&&colorArrayB&&colorArrayA&&colorArrayR._needsUpdate&&colorArrayG._needsUpdate&&colorArrayB._needsUpdate&&colorArrayA._needsUpdate){const buffer=new effect.Amaz.FloatVector;for(let i=0;i<this.array.length;i++){buffer.pushBack(colorArrayR.array[i]);buffer.pushBack(colorArrayG.array[i]);buffer.pushBack(colorArrayB.array[i]);buffer.pushBack(colorArrayA.array[i])}amgObj.setAttributeData(effect.Amaz.VertexAttribType.COLOR,buffer,0,this.array.length/this.itemSize);colorArrayR._needsUpdate=colorArrayG._needsUpdate=colorArrayB._needsUpdate=colorArrayA._needsUpdate=false}return}else if(this._name=="size"||this._name=="rotation"){const sizeAttribute=this._amgGeometry.getAttribute("size");const rotationAttribute=this._amgGeometry.getAttribute("rotation");if(sizeAttribute&&rotationAttribute&&sizeAttribute._needsUpdate&&rotationAttribute._needsUpdate){const buffer=new effect.Amaz.FloatVector;for(let i=0;i<this.array.length;i++){buffer.pushBack(sizeAttribute.array[i]);buffer.pushBack(rotationAttribute.array[i]);buffer.pushBack(0);buffer.pushBack(0)}amgObj.setAttributeData(effect.Amaz.VertexAttribType.USER_DEFINE0,buffer,0,this.array.length/this.itemSize);sizeAttribute._needsUpdate=rotationAttribute._needsUpdate=false}return}else if(this._name=="lifetime"||this._name=="startLifetime"||this._name=="startFrame"){const lifetimeAttribute=this._amgGeometry.getAttribute("lifetime");const startLifetimeAttribute=this._amgGeometry.getAttribute("startLifetime");const startFrameAttribute=this._amgGeometry.getAttribute("startFrame");if(lifetimeAttribute&&startLifetimeAttribute&&startFrameAttribute&&lifetimeAttribute._needsUpdate&&startLifetimeAttribute._needsUpdate&&startFrameAttribute._needsUpdate){const buffer=new effect.Amaz.FloatVector;for(let i=0;i<this.array.length;i++){buffer.pushBack(lifetimeAttribute.array[i]);buffer.pushBack(startLifetimeAttribute.array[i]);buffer.pushBack(startFrameAttribute.array[i])}amgObj.setAttributeData(effect.Amaz.VertexAttribType.USER_DEFINE1,buffer,0,this.array.length/this.itemSize);lifetimeAttribute._needsUpdate=startLifetimeAttribute._needsUpdate=startFrameAttribute._needsUpdate=false}return}else if(this.itemSize==3&&this._name=="targetPosition"){const buffer=new effect.Amaz.FloatVector;for(let i=0;i<this.array.length;i++)buffer.pushBack(this.array[i]);amgObj.setAttributeData(effect.Amaz.VertexAttribType.POSITION_OFFSET,buffer,0,this.array.length/this.itemSize);this._needsUpdate=false;return}else if(this.itemSize==2&&this._name=="targetUV"){const buffer=new effect.Amaz.FloatVector;for(let i=0;i<this.array.length;i++)buffer.pushBack(this.array[i]);amgObj.setAttributeData(effect.Amaz.VertexAttribType.TEXCOORD1,buffer,0,this.array.length/this.itemSize);this._needsUpdate=false;return}}catch(error){console.error("BufferAttribute: 更新AMG对象时发生错误:",error)}}getX(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getX: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return 0}return this.array[index*this.itemSize]}getY(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return 0}return this.array[index*this.itemSize+1]}getZ(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return 0}return this.array[index*this.itemSize+2]}setX(index,value){if(index<0||index>=this.count){console.warn(`BufferAttribute.setX: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}this.array[index*this.itemSize]=value;this.needsUpdate=true}setY(index,value){if(index<0||index>=this.count){console.warn(`BufferAttribute.setY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}this.array[index*this.itemSize+1]=value;this.needsUpdate=true}setZ(index,value){if(index<0||index>=this.count){console.warn(`BufferAttribute.setZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}this.array[index*this.itemSize+2]=value;this.needsUpdate=true}setXY(index,x,y){if(index<0||index>=this.count){console.warn(`BufferAttribute.setXY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}const offset=index*this.itemSize;this.array[offset]=x;this.array[offset+1]=y;this.needsUpdate=true}setXYZ(index,x,y,z){if(index<0||index>=this.count){console.warn(`BufferAttribute.setXYZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}const offset=index*this.itemSize;this.array[offset]=x;this.array[offset+1]=y;this.array[offset+2]=z;this.needsUpdate=true}getXY(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getXY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return{x:0,y:0}}const offset=index*this.itemSize;return{x:this.array[offset],y:this.array[offset+1]}}getXYZ(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getXYZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return{x:0,y:0,z:0}}const offset=index*this.itemSize;return{x:this.array[offset],y:this.array[offset+1],z:this.array[offset+2]}}}exports.BufferAttribute=BufferAttribute;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const{getCurrentScene}=require("./runtime");const{BufferAttribute}=require("./BufferAttribute");const{Vector3}=require("./Vector3");const{Box3}=require("./Box3");class BufferGeometry{constructor(){this.userData={};this.attributes={};this.index=null;this.translateValue=new Vector3(0,0,0);const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Quad.mesh").clone()}else{console.warn("PlaneGeometry: 无法加载Quad.mesh,scene未创建")}{var vertexAttribs=this._amgObject.vertexAttribs;var attribDesc0=new effect.Amaz.VertexAttribDesc;attribDesc0.semantic=effect.Amaz.VertexAttribType.POSITION_OFFSET;attribDesc0.bindingIndex=0;attribDesc0.offset=36;attribDesc0.componentCount=3;vertexAttribs.pushBack(attribDesc0);var attribDesc1=new effect.Amaz.VertexAttribDesc;attribDesc1.semantic=effect.Amaz.VertexAttribType.TEXCOORD1;attribDesc1.bindingIndex=0;attribDesc1.offset=48;attribDesc1.componentCount=2;vertexAttribs.pushBack(attribDesc1);this._amgObject.vertexAttribs=vertexAttribs;const submesh=this._amgObject.submeshes.get(0);if(submesh){submesh.primitive=effect.Amaz.Primitive.TRIANGLES}}let vertexData=this._amgObject.getVertexArray();let uvData=this._amgObject.getUvArray();let vertices=new Float32Array(vertexData.size()*3);let uvs=new Float32Array(uvData.size()*2);for(let i=0;i<vertexData.size();i++){vertices[i*3]=vertexData.get(i).x;vertices[i*3+1]=vertexData.get(i).y;vertices[i*3+2]=vertexData.get(i).z;uvs[i*2]=uvData.get(i).x;uvs[i*2+1]=uvData.get(i).y}this.initAttribute("position",new BufferAttribute(vertices,3));this.initAttribute("uv",new BufferAttribute(uvs,2))}copy(source){if(!source)return this;try{this.userData=source.userData?JSON.parse(JSON.stringify(source.userData)):{}}catch(e){this.userData=source.userData?Object.assign({},source.userData):{}}if(source.translateValue&&this.translateValue&&typeof this.translateValue.copy==="function"){this.translateValue.copy(source.translateValue)}if(source._amgObject&&typeof source._amgObject.clone==="function"){this._amgObject=source._amgObject.clone()}this.attributes={};if(source.attributes){for(const name in source.attributes){const srcAttr=source.attributes[name];if(!srcAttr)continue;const srcArray=srcAttr.array;const itemSize=srcAttr.itemSize;const normalized=srcAttr.normalized;let clonedArray=null;if(srcArray&&typeof srcArray.length==="number"){if(srcArray.constructor&&srcArray.constructor.BYTES_PER_ELEMENT){clonedArray=new srcArray.constructor(srcArray)}else{clonedArray=srcArray.slice?srcArray.slice():Array.from(srcArray)}}else{clonedArray=srcArray}const newAttr=new BufferAttribute(clonedArray,itemSize,normalized);this.initAttribute(name,newAttr)}}if(source.index){let newIndex=null;if(Array.isArray(source.index)){newIndex=source.index.slice()}else if(source.index&&source.index.constructor&&source.index.constructor.BYTES_PER_ELEMENT){newIndex=new source.index.constructor(source.index)}if(newIndex)this.setIndex(newIndex);else this.index=source.index}else{this.index=null}if(source.groups){this.groups=Array.isArray(source.groups)?source.groups.map(g=>Object.assign({},g)):source.groups}if(source.boundingBox)this.boundingBox=source.boundingBox;if(source.boundingSphere)this.boundingSphere=source.boundingSphere;if(source.drawRange)this.drawRange=Object.assign({},source.drawRange);return this}initAttribute(name,attribute){this.attributes[name]=attribute;attribute.setNameAndGeometry(name,this);return this}setAttribute(name,attribute){this.attributes[name]=attribute;attribute.setNameAndGeometry(name,this);attribute.forceUpdateToAMG();return this}getAttribute(name){return this.attributes[name]}computeVertexNormals(){}computeBoundingBox(){}setIndex(index){this.index=index;if(this._amgObject&&this._amgObject.submeshes.get(0)){this._amgObject.submeshes.get(0).indices16=index;this._amgObject.submeshes.get(0).indicesCount=index.length}return this}setFromPoints(points){if(!Array.isArray(points)){console.warn("setFromPoints: points must be an array");return this}const positions=[];for(let i=0;i<points.length;i++){const point=points[i];if(point&&typeof point.x==="number"&&typeof point.y==="number"&&typeof point.z==="number"){positions.push(point.x,point.y,point.z)}else{console.warn(`setFromPoints: point at index ${i} is not a valid Vector3`);positions.push(0,0,0)}}const positionAttribute=new BufferAttribute(new Float32Array(positions),3);this.initAttribute("position",positionAttribute);if(this._amgObject&&this._amgObject.submeshes.get(0)){this._amgObject.submeshes.get(0).primitive=effect.Amaz.Primitive.Points;let list=new effect.Amaz.UInt16Vector;for(let i=0;i<points.length;i++)list.pushBack(i);this._amgObject.submeshes.get(0).indices16=list;this._amgObject.submeshes.get(0).indicesCount=points.length}return this}scale(x,y,z){const positionAttribute=this.attributes.position;if(!positionAttribute)return this;const positions=positionAttribute.array;for(let i=0;i<positions.length;i+=3){positions[i]*=x;positions[i+1]*=y;positions[i+2]*=z}if(this._amgObject){const vertexCount=positions.length/3;const buffer=new effect.Amaz.FloatVector;for(let i=0;i<vertexCount;i++){buffer.pushBack(positions[i*3]);buffer.pushBack(positions[i*3+1]);buffer.pushBack(positions[i*3+2])}this._amgObject.setAttributeData(effect.Amaz.VertexAttribType.POSITION,buffer,0,vertexCount)}return this}computeBoundingBox(){const positionAttribute=this.attributes.position;if(!positionAttribute){this.boundingBox=new Box3(new Vector3(0,0,0),new Vector3(0,0,0));return}const positions=positionAttribute.array;const min=new Vector3(Infinity,Infinity,Infinity);const max=new Vector3(-Infinity,-Infinity,-Infinity);for(let i=0;i<positions.length;i+=3){min.x=Math.min(min.x,positions[i]);min.y=Math.min(min.y,positions[i+1]);min.z=Math.min(min.z,positions[i+2]);max.x=Math.max(max.x,positions[i]);max.y=Math.max(max.y,positions[i+1]);max.z=Math.max(max.z,positions[i+2])}this.boundingBox=new Box3(min,max);return this}dispose(){for(const key in this.attributes){if(this.attributes[key]&&typeof this.attributes[key].dispose==="function"){this.attributes[key].dispose()}}this.attributes={};if(this.index){if(Array.isArray(this.index)){this.index.length=0}this.index=null}if(this._amgObject){if(this._amgObject.submeshes){try{const submeshCount=this._amgObject.submeshes.size();for(let i=0;i<submeshCount;i++){const submesh=this._amgObject.submeshes.get(i);if(submesh){if(submesh.indices16){if(typeof submesh.indices16.clear==="function"){submesh.indices16.clear()}submesh.indices16=null}submesh.indicesCount=0}}if(typeof this._amgObject.submeshes.clear==="function"){this._amgObject.submeshes.clear()}}catch(e){console.warn("BufferGeometry.dispose: 清理 submeshes 失败",e)}}if(this._amgObject.vertexAttribs){try{if(typeof this._amgObject.vertexAttribs.clear==="function"){this._amgObject.vertexAttribs.clear()}this._amgObject.vertexAttribs=null}catch(e){console.warn("BufferGeometry.dispose: 清理 vertexAttribs 失败",e)}}try{if(typeof this._amgObject.destroy==="function"){this._amgObject.destroy()}else if(typeof this._amgObject.release==="function"){this._amgObject.release()}}catch(e){console.warn("BufferGeometry.dispose: 清理 AMG 对象失败",e)}this._amgObject=null}this.translateValue=null;this.boundingBox=null;this.boundingSphere=null}clone(){const clone=new BufferGeometry;clone.copy(this);return clone}translate(x,y,z){this.translateValue.set(x,y,z)}}exports.BufferGeometry=BufferGeometry;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/CapsuleGeometry.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");class CapsuleGeometry extends BufferGeometry{constructor(radius=.5,height=1,radiusSegments=16,heightSegments=1){super();const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Capsule.mesh")}this.radius=radius;this.width=radius/.5;this.height=height;this.depth=radius/.5;this.radiusSegments=radiusSegments;this.heightSegments=heightSegments;this.scale(this.width,this.height,this.depth)}}exports.CapsuleGeometry=CapsuleGeometry;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Color.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const Vector3=require("./Vector3").Vector3;class Color{constructor(r=1,g=1,b=1){if(typeof r==="string"){this.setHexString(r)}else if(typeof r==="number"&&arguments.length===1){this.setHex(r)}else{this.r=r>1?r/255:r;this.g=g>1?g/255:g;this.b=b>1?b/255:b}}set(r,g,b){if(typeof r==="number"&&typeof g==="number"&&typeof b==="number"){this.r=r;this.g=g;this.b=b}else if(r instanceof Vector3){this.r=r.x;this.g=r.y;this.b=r.z}else if(r instanceof Color){this.r=r.r;this.g=r.g;this.b=r.b}else if(Array.isArray(r)&&r.length>=3){this.r=r[0];this.g=r[1];this.b=r[2]}else{console.warn("set: Unsupported color format",r,g,b)}return this}setHex(hex){hex=Math.floor(hex);this.r=(hex>>16&255)/255;this.g=(hex>>8&255)/255;this.b=(hex&255)/255;return this}setHexString(hexString){hexString=hexString.replace(/^#/,"");if(hexString.length===3){hexString=hexString.split("").map(char=>char+char).join("")}const hex=parseInt(hexString,16);if(isNaN(hex)){console.warn(`Invalid hex color string: ${hexString}, using white`);this.setRGB(1,1,1);return this}this.r=(hex>>16&255)/255;this.g=(hex>>8&255)/255;this.b=(hex&255)/255;return this}setRGB(r,g,b){this.r=r;this.g=g;this.b=b;return this}setHSL(h,s,l){let r,g,b;if(s===0){r=g=b=l}else{const hue2rgb=function(p,q,t){if(t<0)t+=1;if(t>1)t-=1;if(t<1/6)return p+(q-p)*6*t;if(t<1/2)return q;if(t<2/3)return p+(q-p)*(2/3-t)*6;return p};const q=l<.5?l*(1+s):l+s-l*s;const p=2*l-q;r=hue2rgb(p,q,h+1/3);g=hue2rgb(p,q,h);b=hue2rgb(p,q,h-1/3)}this.r=r;this.g=g;this.b=b;return this}toAMGColor(){const color=new Amaz.Vector4f;color.x=this.r;color.y=this.g;color.z=this.b;color.w=1;return color}}exports.Color=Color;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Constants.js ADDED
@@ -0,0 +1 @@
 
 
1
+ exports.FrontSide=0;exports.BackSide=1;exports.DoubleSide=2;exports.NoBlending=0;exports.NormalBlending=1;exports.AdditiveBlending=2;exports.SubtractiveBlending=3;exports.MultiplyBlending=4;exports.CustomBlending=5;exports.RepeatWrapping=1e3;exports.ClampToEdgeWrapping=1001;exports.MirroredRepeatWrapping=1002;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const{Vector2}=require("./Vector2");class CurvePath{constructor(){this.type="CurvePath";this.curves=[];this.autoClose=false;this.cacheLengths=null;this.cacheDivisions=null}add(curve){this.curves.push(curve);this.cacheLengths=null}closePath(){if(this.curves.length>0){const firstPoint=this.curves[0].getPoint(0);const lastCurve=this.curves[this.curves.length-1];const lastPoint=lastCurve.getPoint(1);if(!lastPoint.equals(firstPoint)){this.add(new LineCurve(lastPoint,firstPoint))}}this.autoClose=true}getPoints(divisions=12){const points=[];const epsilon=1e-10;for(let i=0;i<this.curves.length;i++){const curve=this.curves[i];const pts=curve.getPoints?curve.getPoints(divisions):[curve.getPoint(0),curve.getPoint(1)];for(let j=0;j<pts.length;j++){const point=pts[j];if(i===0||j>0||points.length===0||!point.equals(points[points.length-1],epsilon)){points.push(point)}}}if(this.autoClose&&points.length>1&&!points[points.length-1].equals(points[0],epsilon)){points.push(points[0].clone())}return points}getLengths(divisions=40){if(this.cacheLengths&&this.cacheDivisions===divisions){return this.cacheLengths}const lengths=[];let sum=0;for(let i=0;i<this.curves.length;i++){const curve=this.curves[i];let last=curve.getPoint(0);for(let j=1;j<=divisions;j++){const current=curve.getPoint(j/divisions);const dx=current.x-last.x;const dy=current.y-last.y;sum+=Math.sqrt(dx*dx+dy*dy);lengths.push(sum);last=current}}this.cacheLengths=lengths;this.cacheDivisions=divisions;return lengths}getLength(){const lengths=this.getLengths();return lengths.length>0?lengths[lengths.length-1]:0}getPointAt(u){const t=this.getUtoTmapping(u);return this.getPoint(t)}getUtoTmapping(u){const divisions=this.cacheDivisions||40;const lengths=this.getLengths(divisions);if(u===0)return 0;if(u===1)return 1;if(lengths.length===0)return 0;const targetLength=u*lengths[lengths.length-1];let low=0;let high=lengths.length-1;let comparison;while(low<=high){const i=Math.floor(low+(high-low)/2);comparison=lengths[i]-targetLength;if(comparison<0){low=i+1}else if(comparison>0){high=i-1}else{high=i;break}}let i=high;if(i<0)i=0;if(i>=lengths.length)i=lengths.length-1;const lengthBefore=i>0?lengths[i-1]:0;const lengthAfter=lengths[i];const segmentLength=lengthAfter-lengthBefore;const segmentFraction=segmentLength===0?0:(targetLength-lengthBefore)/segmentLength;const t=(i+segmentFraction)/(this.curves.length*divisions);return t}getPoint(t){const divisions=this.cacheDivisions||40;const d=t*this.curves.length*divisions;const segmentIndex=Math.floor(d);const segmentT=d-segmentIndex;const curveIndex=Math.floor(segmentIndex/divisions);const divisionIndex=segmentIndex%divisions;const curveT=(divisionIndex+segmentT)/divisions;if(curveIndex<0||this.curves.length===0){return this.curves.length>0?this.curves[0].getPoint(0):new Vector2}if(curveIndex>=this.curves.length){return this.curves[this.curves.length-1].getPoint(1)}return this.curves[curveIndex].getPoint(curveT)}getSpacedPoints(divisions=5){const points=[];if(this.curves.length===0){return points}for(let i=0;i<=divisions;i++){points.push(this.getPointAt(i/divisions))}return points}getTangent(t){const delta=1e-4;let t1=t-delta;let t2=t+delta;if(t1<0)t1=0;if(t2>1)t2=1;const pt1=this.getPoint(t1);const pt2=this.getPoint(t2);const tangent=(new Vector2).subVectors(pt2,pt1);return tangent.normalize()}getTangentAt(u){const t=this.getUtoTmapping(u);return this.getTangent(t)}getBounds(){const points=this.getPoints();let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;i<points.length;i++){const p=points[i];if(p.x<minX)minX=p.x;if(p.x>maxX)maxX=p.x;if(p.y<minY)minY=p.y;if(p.y>maxY)maxY=p.y}return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}}class LineCurve{constructor(v1,v2){this.type="LineCurve";this.v1=v1;this.v2=v2}getPoint(t){if(t===1){return this.v2.clone()}else{const x=this.v1.x+t*(this.v2.x-this.v1.x);const y=this.v1.y+t*(this.v2.y-this.v1.y);return new Vector2(x,y)}}getPoints(divisions=1){const points=[];for(let i=0;i<=divisions;i++){points.push(this.getPoint(i/divisions))}return points}getTangent(t){const tangent=(new Vector2).subVectors(this.v2,this.v1);return tangent.normalize()}getLength(){return this.v1.distanceTo(this.v2)}translate(x,y){this.v1.x+=x;this.v1.y+=y;this.v2.x+=x;this.v2.y+=y;return this}scale(x,y){this.v1.x*=x;this.v1.y*=y;this.v2.x*=x;this.v2.y*=y;return this}rotate(cos,sin){let x=this.v1.x,y=this.v1.y;this.v1.x=x*cos-y*sin;this.v1.y=x*sin+y*cos;x=this.v2.x;y=this.v2.y;this.v2.x=x*cos-y*sin;this.v2.y=x*sin+y*cos;return this}clone(){return new LineCurve(this.v1.clone(),this.v2.clone())}copy(source){this.v1.copy(source.v1);this.v2.copy(source.v2);return this}}exports.CurvePath=CurvePath;exports.LineCurve=LineCurve;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");class CylinderGeometry extends BufferGeometry{constructor(radiusTop=.5,radiusBottom=.5,height=1,radiusSegments=16,heightSegments=1){super();const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Cylinder.mesh")}this.radiusTop=radiusTop;this.radiusBottom=radiusBottom;this.width=radiusTop/.5;this.height=height;this.depth=radiusTop/.5;this.radiusSegments=radiusSegments;this.heightSegments=heightSegments;this.scale(this.width,this.height,this.depth)}}exports.CylinderGeometry=CylinderGeometry;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Earcut.js ADDED
@@ -0,0 +1 @@
 
 
1
+ function earcut(data,holeIndices,dim){dim=dim||2;const hasHoles=holeIndices&&holeIndices.length;const outerLen=hasHoles?holeIndices[0]*dim:data.length;let outerNode=linkedList(data,0,outerLen,dim,true);const triangles=[];if(!outerNode||outerNode.next===outerNode.prev)return triangles;if(hasHoles)outerNode=eliminateHoles(data,holeIndices,outerNode,dim);let minX,minY,maxX,maxY,x,y,invSize;if(data.length>80*dim){minX=maxX=data[0];minY=maxY=data[1];for(let i=dim;i<outerLen;i+=dim){x=data[i];y=data[i+1];if(x<minX)minX=x;if(y<minY)minY=y;if(x>maxX)maxX=x;if(y>maxY)maxY=y}invSize=Math.max(maxX-minX,maxY-minY);invSize=invSize!==0?1/invSize:0}earcutLinked(outerNode,triangles,dim,minX,minY,invSize);return triangles}function linkedList(data,start,end,dim,clockwise){let i,last;if(clockwise===signedArea(data,start,end,dim)>0){for(i=start;i<end;i+=dim)last=insertNode(i/dim,data[i],data[i+1],last)}else{for(i=end-dim;i>=start;i-=dim)last=insertNode(i/dim,data[i],data[i+1],last)}if(last&&equals(last,last.next)){removeNode(last);last=last.next}return last}function eliminateHoles(data,holeIndices,outerNode,dim){const queue=[];let i,len,start,end,list;for(i=0,len=holeIndices.length;i<len;i++){start=holeIndices[i]*dim;end=i<len-1?holeIndices[i+1]*dim:data.length;list=linkedList(data,start,end,dim,false);if(list===list.next)list.steiner=true;queue.push(getLeftmost(list))}queue.sort(compareX);for(i=0;i<queue.length;i++){eliminateHole(queue[i],outerNode);outerNode=filterPoints(outerNode,outerNode.next)}return outerNode}function compareX(a,b){return a.x-b.x}function eliminateHole(hole,outerNode){outerNode=findHoleBridge(hole,outerNode);if(outerNode){const b=splitPolygon(outerNode,hole);filterPoints(filterPoints(b,b.next),b.next)}}function findHoleBridge(hole,outerNode){let p=outerNode;const hx=hole.x;const hy=hole.y;let qx=-Infinity,m;do{if(hy<=p.y&&hy>=p.next.y&&p.next.y!==p.y){const x=p.x+(hy-p.y)*(p.next.x-p.x)/(p.next.y-p.y);if(x<=hx&&x>qx){qx=x;if(x===hx){if(hy===p.y)return p;if(hy===p.next.y)return p.next}m=p.x<p.next.x?p:p.next}}p=p.next}while(p!==outerNode);if(!m)return null;if(hx===qx)return m;const stop=m;const mx=m.x;const my=m.y;let tanMin=Infinity,tan;p=m;do{if(hx>=p.x&&p.x>=mx&&hx!==p.x&&pointInTriangle(hy<my?hx:qx,hy,mx,my,hy<my?qx:hx,hy,p.x,p.y)){tan=Math.abs(hy-p.y)/(hx-p.x);if(locallyInside(p,hole)&&(tan<tanMin||tan===tanMin&&(p.x>m.x||p.x===m.x&&sectorContainsSector(m,p)))){m=p;tanMin=tan}}p=p.next}while(p!==stop);return m}function sectorContainsSector(m,p){return area(m.prev,m,p.prev)<0&&area(p.next,m,m.next)<0}function earcutLinked(ear,triangles,dim,minX,minY,invSize,pass){if(!ear)return;if(!pass&&invSize)indexCurve(ear,minX,minY,invSize);let stop=ear,prev,next;while(ear.prev!==ear.next){prev=ear.prev;next=ear.next;if(invSize?isEarHashed(ear,minX,minY,invSize):isEar(ear)){triangles.push(prev.i,ear.i,next.i);removeNode(ear);ear=next.next;stop=next.next;continue}ear=next;if(ear===stop){if(!pass){earcutLinked(filterPoints(ear),triangles,dim,minX,minY,invSize,1)}else if(pass===1){ear=cureLocalIntersections(filterPoints(ear),triangles,dim);earcutLinked(ear,triangles,dim,minX,minY,invSize,2)}else if(pass===2){splitEarcut(ear,triangles,dim,minX,minY,invSize)}break}}}function isEar(ear){const a=ear.prev;const b=ear;const c=ear.next;if(area(a,b,c)>=0)return false;let p=ear.next.next;while(p!==ear.prev){if(pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0){return false}p=p.next}return true}function isEarHashed(ear,minX,minY,invSize){const a=ear.prev;const b=ear;const c=ear.next;if(area(a,b,c)>=0)return false;const minTX=a.x<b.x?a.x<c.x?a.x:c.x:b.x<c.x?b.x:c.x;const minTY=a.y<b.y?a.y<c.y?a.y:c.y:b.y<c.y?b.y:c.y;const maxTX=a.x>b.x?a.x>c.x?a.x:c.x:b.x>c.x?b.x:c.x;const maxTY=a.y>b.y?a.y>c.y?a.y:c.y:b.y>c.y?b.y:c.y;const minZ=zOrder(minTX,minTY,minX,minY,invSize);const maxZ=zOrder(maxTX,maxTY,minX,minY,invSize);let p=ear.prevZ;let n=ear.nextZ;while(p&&p.z>=minZ&&n&&n.z<=maxZ){if(p!==ear.prev&&p!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0)return false;p=p.prevZ;if(n!==ear.prev&&n!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,n.x,n.y)&&area(n.prev,n,n.next)>=0)return false;n=n.nextZ}while(p&&p.z>=minZ){if(p!==ear.prev&&p!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0)return false;p=p.prevZ}while(n&&n.z<=maxZ){if(n!==ear.prev&&n!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,n.x,n.y)&&area(n.prev,n,n.next)>=0)return false;n=n.nextZ}return true}function cureLocalIntersections(start,triangles,dim){let p=start;do{const a=p.prev;const b=p.next.next;if(!equals(a,b)&&intersects(a,p,p.next,b)&&locallyInside(a,b)&&locallyInside(b,a)){triangles.push(a.i,p.i,b.i);removeNode(p);removeNode(p.next);p=start=b}p=p.next}while(p!==start);return filterPoints(p)}function splitEarcut(start,triangles,dim,minX,minY,invSize){let a=start;do{let b=a.next.next;while(b!==a.prev){if(a.i!==b.i&&isValidDiagonal(a,b)){let c=splitPolygon(a,b);a=filterPoints(a,a.next);c=filterPoints(c,c.next);earcutLinked(a,triangles,dim,minX,minY,invSize);earcutLinked(c,triangles,dim,minX,minY,invSize);return}b=b.next}a=a.next}while(a!==start)}function indexCurve(start,minX,minY,invSize){let p=start;do{if(p.z===null)p.z=zOrder(p.x,p.y,minX,minY,invSize);p.prevZ=p.prev;p.nextZ=p.next;p=p.next}while(p!==start);p.prevZ.nextZ=null;p.prevZ=null;sortLinked(p)}function sortLinked(list){let i,p,q,e,tail,numMerges,pSize,qSize,inSize=1;do{p=list;list=null;tail=null;numMerges=0;while(p){numMerges++;q=p;pSize=0;for(i=0;i<inSize;i++){pSize++;q=q.nextZ;if(!q)break}qSize=inSize;while(pSize>0||qSize>0&&q){if(pSize!==0&&(qSize===0||!q||p.z<=q.z)){e=p;p=p.nextZ;pSize--}else{e=q;q=q.nextZ;qSize--}if(tail)tail.nextZ=e;else list=e;e.prevZ=tail;tail=e}p=q}tail.nextZ=null;inSize*=2}while(numMerges>1);return list}function zOrder(x,y,minX,minY,invSize){x=32767*(x-minX)*invSize;y=32767*(y-minY)*invSize;x=(x|x<<8)&16711935;x=(x|x<<4)&252645135;x=(x|x<<2)&858993459;x=(x|x<<1)&1431655765;y=(y|y<<8)&16711935;y=(y|y<<4)&252645135;y=(y|y<<2)&858993459;y=(y|y<<1)&1431655765;return x|y<<1}function getLeftmost(start){let p=start;let leftmost=start;do{if(p.x<leftmost.x||p.x===leftmost.x&&p.y<leftmost.y)leftmost=p;p=p.next}while(p!==start);return leftmost}function pointInTriangle(ax,ay,bx,by,cx,cy,px,py){return(cx-px)*(ay-py)-(ax-px)*(cy-py)>=0&&(ax-px)*(by-py)-(bx-px)*(ay-py)>=0&&(bx-px)*(cy-py)-(cx-px)*(by-py)>=0}function isValidDiagonal(a,b){return a.next.i!==b.i&&a.prev.i!==b.i&&!intersectsPolygon(a,b)&&(locallyInside(a,b)&&locallyInside(b,a)&&middleInside(a,b)&&(area(a.prev,a,b.prev)||area(a,b.prev,b))||equals(a,b)&&area(a.prev,a,a.next)>0&&area(b.prev,b,b.next)>0)}function area(p,q,r){return(q.y-p.y)*(r.x-q.x)-(q.x-p.x)*(r.y-q.y)}function equals(p1,p2){return p1.x===p2.x&&p1.y===p2.y}function intersects(p1,q1,p2,q2){const o1=sign(area(p1,q1,p2));const o2=sign(area(p1,q1,q2));const o3=sign(area(p2,q2,p1));const o4=sign(area(p2,q2,q1));if(o1!==o2&&o3!==o4)return true;if(o1===0&&onSegment(p1,p2,q1))return true;if(o2===0&&onSegment(p1,q2,q1))return true;if(o3===0&&onSegment(p2,p1,q2))return true;if(o4===0&&onSegment(p2,q1,q2))return true;return false}function onSegment(p,q,r){return q.x<=Math.max(p.x,r.x)&&q.x>=Math.min(p.x,r.x)&&q.y<=Math.max(p.y,r.y)&&q.y>=Math.min(p.y,r.y)}function sign(num){return num>0?1:num<0?-1:0}function intersectsPolygon(a,b){let p=a;do{if(p.i!==a.i&&p.next.i!==a.i&&p.i!==b.i&&p.next.i!==b.i&&intersects(p,p.next,a,b))return true;p=p.next}while(p!==a);return false}function locallyInside(a,b){return area(a.prev,a,a.next)<0?area(a,b,a.next)>=0&&area(a,a.prev,b)>=0:area(a,b,a.prev)<0||area(a,a.next,b)<0}function middleInside(p,q){let a=p;let inside=false;const px=(p.x+q.x)/2;const py=(p.y+q.y)/2;do{const sx=a.x;const sy=a.y;const ex=a.next.x;const ey=a.next.y;if(sy>py!==ey>py&&px<(ex-sx)*(py-sy)/(ey-sy)+sx)inside=!inside;a=a.next}while(a!==p);return inside}function splitPolygon(a,b){const a2=new Node(a.i,a.x,a.y);const b2=new Node(b.i,b.x,b.y);const an=a.next;const bp=b.prev;a.next=b;b.prev=a;a2.next=an;an.prev=a2;b2.next=a2;a2.prev=b2;bp.next=b2;b2.prev=bp;return b2}function insertNode(i,x,y,last){const p=new Node(i,x,y);if(!last){p.prev=p;p.next=p}else{p.next=last.next;p.prev=last;last.next.prev=p;last.next=p}return p}function removeNode(p){p.next.prev=p.prev;p.prev.next=p.next;if(p.prevZ)p.prevZ.nextZ=p.nextZ;if(p.nextZ)p.nextZ.prevZ=p.prevZ}function Node(i,x,y){this.i=i;this.x=x;this.y=y;this.prev=null;this.next=null;this.z=null;this.prevZ=null;this.nextZ=null;this.steiner=false}function signedArea(data,start,end,dim){let sum=0;for(let i=start,j=end-dim;i<end;i+=dim){sum+=(data[j]-data[i])*(data[i+1]+data[j+1]);j=i}return sum}function filterPoints(start,end){if(!start)return start;if(!end)end=start;let p=start,again;do{again=false;if(!p.steiner&&(equals(p,p.next)||area(p.prev,p,p.next)===0)){removeNode(p);p=end=p.prev;if(p===p.next)break;again=true}else{p=p.next}}while(again||p!==end);return end}exports.earcut=earcut;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Euler.js ADDED
@@ -0,0 +1 @@
 
 
1
+ class Euler{constructor(x=0,y=0,z=0,order="XYZ"){this.x=x;this.y=y;this.z=z;this.order=order}set(x,y,z,order){this.x=x;this.y=y;this.z=z;this.order=order||this.order;return this}setFromUnitVectors(vFrom,vTo){const from=vFrom.clone().normalize();const to=vTo.clone().normalize();const pitch=Math.asin(to.y);const yaw=Math.atan2(to.x,to.z);const roll=0;this.x=pitch;this.y=-yaw;this.z=roll;return this}setFromQuaternion(q,order){this.x=q.x;this.y=q.y;this.z=q.z;this.order=order||this.order;return this}clone(){return new Euler(this.x,this.y,this.z,this.order)}}exports.Euler=Euler;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/ExtrudeGeometry.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");const{earcut}=require("./Earcut");const{Vector2}=require("./Vector2");const{Vector3}=require("./Vector3");const{Box3}=require("./Box3");class ExtrudeGeometry extends BufferGeometry{constructor(shapes,options={}){super();this.type="ExtrudeGeometry";const shapesArray=Array.isArray(shapes)?shapes:[shapes];this.parameters={shapes:shapes,options:options};const depth=options.depth!==undefined?options.depth:1;const steps=options.steps!==undefined?options.steps:1;const bevelEnabled=options.bevelEnabled!==undefined?options.bevelEnabled:true;const bevelThickness=options.bevelThickness!==undefined?options.bevelThickness:.2;const bevelSize=options.bevelSize!==undefined?options.bevelSize:bevelThickness-.1;const bevelOffset=options.bevelOffset!==undefined?options.bevelOffset:0;const bevelSegments=options.bevelSegments!==undefined?options.bevelSegments:3;const curveSegments=options.curveSegments!==undefined?options.curveSegments:12;const extrudePath=options.extrudePath;const UVGenerator=options.UVGenerator;this.depth=depth;this.steps=steps;this.bevelEnabled=bevelEnabled;this.bevelThickness=bevelThickness;this.bevelSize=bevelSize;this.bevelOffset=bevelOffset;this.bevelSegments=bevelSegments;this.curveSegments=curveSegments;const vertices=[];const indices=[];const uvs=[];const groups=[];for(let s=0;s<shapesArray.length;s++){const shape=shapesArray[s];const{shape:shapePoints,holes:holePoints}=shape.extractPoints(curveSegments);if(!shapePoints||shapePoints.length<3){console.warn("ExtrudeGeometry: 形状点数量不足");continue}this.addShape(shape,shapePoints,holePoints,vertices,indices,uvs,groups,s)}if(vertices.length>0){this.setAttribute("position",new BufferAttribute(new Float32Array(vertices),3));this.setAttribute("uv",new BufferAttribute(new Float32Array(uvs),2));if(indices.length>0){this.setIndex(indices)}this.updateAMGObject(vertices,indices,uvs)}this.groups=groups}addShape(shape,shapePoints,holePoints,vertices,indices,uvs,groups,materialIndex){const vertexOffset=vertices.length/3;const groupStart=indices.length;const triangulationData=this.prepareTriangulationData(shapePoints,holePoints);if(!triangulationData)return;const{flatVertices,holeIndices,vertexCount}=triangulationData;const triangleIndices=earcut(flatVertices,holeIndices,2);if(!triangleIndices||triangleIndices.length===0){console.warn("ExtrudeGeometry: 三角化失败");return}const bounds=this.calculateBounds(flatVertices);const contour=shapePoints;const holes=holePoints||[];if(this.bevelEnabled){this.buildWithBevel(contour,holes,flatVertices,triangleIndices,bounds,vertices,indices,uvs,vertexOffset)}else{this.buildWithoutBevel(contour,holes,flatVertices,triangleIndices,bounds,vertices,indices,uvs,vertexOffset)}const groupCount=indices.length-groupStart;if(groupCount>0){groups.push({start:groupStart,count:groupCount,materialIndex:materialIndex})}}buildWithoutBevel(contour,holes,flatVertices,triangleIndices,bounds,vertices,indices,uvs,vertexOffset){const depth=this.depth;const steps=this.steps;const allContours=[contour].concat(holes);let currentVertexOffset=vertexOffset;for(let i=0;i<flatVertices.length/2;i++){const x=flatVertices[i*2];const y=flatVertices[i*2+1];vertices.push(x,y,0);const u=(x-bounds.minX)/(bounds.maxX-bounds.minX);const v=(y-bounds.minY)/(bounds.maxY-bounds.minY);uvs.push(u,v)}for(let i=0;i<triangleIndices.length;i+=3){indices.push(currentVertexOffset+triangleIndices[i],currentVertexOffset+triangleIndices[i+1],currentVertexOffset+triangleIndices[i+2])}currentVertexOffset+=flatVertices.length/2;for(let i=0;i<flatVertices.length/2;i++){const x=flatVertices[i*2];const y=flatVertices[i*2+1];vertices.push(x,y,depth);const u=(x-bounds.minX)/(bounds.maxX-bounds.minX);const v=(y-bounds.minY)/(bounds.maxY-bounds.minY);uvs.push(u,v)}const backFaceOffset=currentVertexOffset;for(let i=0;i<triangleIndices.length;i+=3){indices.push(backFaceOffset+triangleIndices[i+2],backFaceOffset+triangleIndices[i+1],backFaceOffset+triangleIndices[i])}currentVertexOffset+=flatVertices.length/2;for(let c=0;c<allContours.length;c++){const pts=allContours[c];this.buildSideFaces(pts,depth,steps,vertices,indices,uvs,currentVertexOffset);currentVertexOffset+=pts.length*(steps+1)}}buildWithBevel(contour,holes,flatVertices,triangleIndices,bounds,vertices,indices,uvs,vertexOffset){const depth=this.depth;const steps=this.steps;const bevelThickness=this.bevelThickness;const bevelSize=this.bevelSize;const bevelSegments=this.bevelSegments;const allContours=[contour].concat(holes);let currentVertexOffset=vertexOffset;const shapeWidth=bounds.maxX-bounds.minX;const shapeHeight=bounds.maxY-bounds.minY;const shapeSize=Math.max(shapeWidth,shapeHeight);const normalizedBevelSize=bevelSize/shapeSize;const verticesPerLayer=flatVertices.length/2;const contourVertCount=contour.length;const frontBevelStartOffset=currentVertexOffset;for(let b=0;b<=bevelSegments;b++){const t=b/bevelSegments;const z=-bevelThickness*(1-t);const smoothT=this.smoothBevelCurve(t);const scale=1+normalizedBevelSize*smoothT;this.buildBevelLayer(flatVertices,bounds,z,scale,vertices,uvs)}for(let i=0;i<triangleIndices.length;i+=3){indices.push(frontBevelStartOffset+triangleIndices[i],frontBevelStartOffset+triangleIndices[i+1],frontBevelStartOffset+triangleIndices[i+2])}currentVertexOffset+=(bevelSegments+1)*verticesPerLayer;const mainBodyStartOffset=currentVertexOffset;const centerX=(bounds.minX+bounds.maxX)/2;const centerY=(bounds.minY+bounds.maxY)/2;const mainBodyScale=1+normalizedBevelSize;for(let step=0;step<=steps;step++){const t=step/steps;const z=t*depth;for(let i=0;i<verticesPerLayer;i++){const x=flatVertices[i*2];const y=flatVertices[i*2+1];const scaledX=centerX+(x-centerX)*mainBodyScale;const scaledY=centerY+(y-centerY)*mainBodyScale;vertices.push(scaledX,scaledY,z);const u=(x-bounds.minX)/shapeWidth;const v=(y-bounds.minY)/shapeHeight;uvs.push(u,v)}}currentVertexOffset+=(steps+1)*verticesPerLayer;const backBevelStartOffset=currentVertexOffset;for(let b=0;b<=bevelSegments;b++){const t=b/bevelSegments;const z=depth+bevelThickness*t;const smoothT=this.smoothBevelCurve(t);const scale=1+normalizedBevelSize*(1-smoothT);this.buildBevelLayer(flatVertices,bounds,z,scale,vertices,uvs)}for(let i=0;i<triangleIndices.length;i+=3){const layerOffset=backBevelStartOffset+bevelSegments*verticesPerLayer;indices.push(layerOffset+triangleIndices[i+2],layerOffset+triangleIndices[i+1],layerOffset+triangleIndices[i])}currentVertexOffset+=(bevelSegments+1)*verticesPerLayer;const allLayerInfo=[];for(let b=0;b<=bevelSegments;b++){const t=b/bevelSegments;const z=-bevelThickness*(1-t);allLayerInfo.push({z:z,type:"frontBevel",index:b})}for(let step=0;step<=steps;step++){const t=step/steps;const z=t*depth;allLayerInfo.push({z:z,type:"main",index:step})}for(let b=0;b<=bevelSegments;b++){const t=b/bevelSegments;const z=depth+bevelThickness*t;allLayerInfo.push({z:z,type:"backBevel",index:b})}const totalDepth=depth+2*bevelThickness;this.buildBevelSideFaces(contour,allLayerInfo,totalDepth,vertices,indices,uvs,currentVertexOffset);currentVertexOffset+=contour.length*allLayerInfo.length}smoothBevelCurve(t){return t*t*(3-2*t)}buildBevelSideFaces(contour,layerInfo,totalDepth,vertices,indices,uvs,startVertexOffset){const contourLength=this.calculateContourLength(contour);let minX=Infinity,maxX=-Infinity;let minY=Infinity,maxY=-Infinity;for(let i=0;i<contour.length;i++){if(contour[i].x<minX)minX=contour[i].x;if(contour[i].x>maxX)maxX=contour[i].x;if(contour[i].y<minY)minY=contour[i].y;if(contour[i].y>maxY)maxY=contour[i].y}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const shapeWidth=maxX-minX;const shapeHeight=maxY-minY;const shapeSize=Math.max(shapeWidth,shapeHeight);const normalizedBevelSize=this.bevelSize/shapeSize;for(let layerIdx=0;layerIdx<layerInfo.length;layerIdx++){const layer=layerInfo[layerIdx];const z=layer.z;const vCoord=(z+this.bevelThickness)/totalDepth;let scale=1+normalizedBevelSize;if(layer.type==="frontBevel"){const t=layer.index/this.bevelSegments;const smoothT=this.smoothBevelCurve(t);scale=1+normalizedBevelSize*smoothT}else if(layer.type==="backBevel"){const t=layer.index/this.bevelSegments;const smoothT=this.smoothBevelCurve(t);scale=1+normalizedBevelSize*(1-smoothT)}let accumulatedLength=0;for(let i=0;i<contour.length;i++){const pt=contour[i];const scaledX=centerX+(pt.x-centerX)*scale;const scaledY=centerY+(pt.y-centerY)*scale;vertices.push(scaledX,scaledY,z);const uCoord=accumulatedLength/contourLength;uvs.push(uCoord,vCoord);if(i<contour.length-1){const nextPt=contour[i+1];const dx=nextPt.x-pt.x;const dy=nextPt.y-pt.y;accumulatedLength+=Math.sqrt(dx*dx+dy*dy)}}}const contourVertCount=contour.length;for(let layerIdx=0;layerIdx<layerInfo.length-1;layerIdx++){for(let i=0;i<contourVertCount;i++){const current=startVertexOffset+layerIdx*contourVertCount+i;const next=startVertexOffset+layerIdx*contourVertCount+(i+1)%contourVertCount;const currentNext=startVertexOffset+(layerIdx+1)*contourVertCount+i;const nextNext=startVertexOffset+(layerIdx+1)*contourVertCount+(i+1)%contourVertCount;indices.push(current,next,currentNext);indices.push(next,nextNext,currentNext)}}}buildLayerSideFaces(contourVertCount,layer1Offset,layer2Offset,indices){for(let i=0;i<contourVertCount;i++){const i1=i;const i2=(i+1)%contourVertCount;const v1=layer1Offset+i1;const v2=layer1Offset+i2;const v3=layer2Offset+i1;const v4=layer2Offset+i2;indices.push(v1,v2,v3);indices.push(v2,v4,v3)}}buildBevelLayer(flatVertices,bounds,z,scale,vertices,uvs){const centerX=(bounds.minX+bounds.maxX)/2;const centerY=(bounds.minY+bounds.maxY)/2;const shapeWidth=bounds.maxX-bounds.minX;const shapeHeight=bounds.maxY-bounds.minY;for(let i=0;i<flatVertices.length/2;i++){const x=flatVertices[i*2];const y=flatVertices[i*2+1];const scaledX=centerX+(x-centerX)*scale;const scaledY=centerY+(y-centerY)*scale;vertices.push(scaledX,scaledY,z);const u=(x-bounds.minX)/shapeWidth;const v=(y-bounds.minY)/shapeHeight;uvs.push(u,v)}}buildSideFaces(contour,depth,steps,vertices,indices,uvs,startVertexOffset){const contourLength=this.calculateContourLength(contour);let accumulatedLength=0;for(let step=0;step<=steps;step++){const z=step/steps*depth;accumulatedLength=0;for(let i=0;i<contour.length;i++){const pt=contour[i];vertices.push(pt.x,pt.y,z);const u=accumulatedLength/contourLength;const v=step/steps;uvs.push(u,v);if(i<contour.length-1){const nextPt=contour[i+1];const dx=nextPt.x-pt.x;const dy=nextPt.y-pt.y;accumulatedLength+=Math.sqrt(dx*dx+dy*dy)}}}for(let step=0;step<steps;step++){for(let i=0;i<contour.length;i++){const current=startVertexOffset+step*contour.length+i;const next=startVertexOffset+step*contour.length+(i+1)%contour.length;const currentNext=startVertexOffset+(step+1)*contour.length+i;const nextNext=startVertexOffset+(step+1)*contour.length+(i+1)%contour.length;indices.push(current,next,currentNext);indices.push(next,nextNext,currentNext)}}}calculateContourLength(contour){let length=0;for(let i=0;i<contour.length-1;i++){const dx=contour[i+1].x-contour[i].x;const dy=contour[i+1].y-contour[i].y;length+=Math.sqrt(dx*dx+dy*dy)}const dx=contour[0].x-contour[contour.length-1].x;const dy=contour[0].y-contour[contour.length-1].y;length+=Math.sqrt(dx*dx+dy*dy);return length}calculateContourNormals(contour){const normals=[];const n=contour.length;for(let i=0;i<n;i++){const prev=contour[(i-1+n)%n];const curr=contour[i];const next=contour[(i+1)%n];const dx1=curr.x-prev.x;const dy1=curr.y-prev.y;const dx2=next.x-curr.x;const dy2=next.y-curr.y;const len1=Math.sqrt(dx1*dx1+dy1*dy1);const len2=Math.sqrt(dx2*dx2+dy2*dy2);const nx1=len1>0?-dy1/len1:0;const ny1=len1>0?dx1/len1:0;const nx2=len2>0?-dy2/len2:0;const ny2=len2>0?dx2/len2:0;const nx=(nx1+nx2)/2;const ny=(ny1+ny2)/2;const nlen=Math.sqrt(nx*nx+ny*ny);normals.push({x:nlen>0?nx/nlen:0,y:nlen>0?ny/nlen:0})}return normals}prepareTriangulationData(shapePoints,holePoints){if(!shapePoints||shapePoints.length<3){return null}const flatVertices=[];const holeIndices=[];for(let i=0;i<shapePoints.length;i++){flatVertices.push(shapePoints[i].x,shapePoints[i].y)}let vertexCount=shapePoints.length;if(holePoints&&holePoints.length>0){for(let i=0;i<holePoints.length;i++){const hole=holePoints[i];if(hole&&hole.length>0){holeIndices.push(vertexCount);for(let j=0;j<hole.length;j++){flatVertices.push(hole[j].x,hole[j].y);vertexCount++}}}}return{flatVertices:flatVertices,holeIndices:holeIndices.length>0?holeIndices:null,vertexCount:vertexCount}}calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;i<vertices.length;i+=2){const x=vertices[i];const y=vertices[i+1];if(x<minX)minX=x;if(x>maxX)maxX=x;if(y<minY)minY=y;if(y>maxY)maxY=y}if(maxX===minX)maxX=minX+1;if(maxY===minY)maxY=minY+1;return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}updateAMGObject(vertices,indices,uvs){if(!this._amgObject||!this._amgObject.submeshes)return;try{const submesh=this._amgObject.submeshes.get(0);if(!submesh)return;submesh.primitive=effect.Amaz.Primitive.TRIANGLES;const vertexCount=vertices.length/3;const buffer=new effect.Amaz.FloatVector;for(let i=0;i<vertexCount;i++){buffer.pushBack(vertices[i*3]);buffer.pushBack(vertices[i*3+1]);buffer.pushBack(vertices[i*3+2])}this._amgObject.setAttributeData(effect.Amaz.VertexAttribType.POSITION,buffer,0,vertexCount);const uvArray=new effect.Amaz.Vec2Vector;for(let i=0;i<vertexCount;i++){const uv=new effect.Amaz.Vector2f(uvs[i*2],uvs[i*2+1]);uvArray.pushBack(uv)}this._amgObject.setUvArray(0,uvArray);if(indices.length>0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;i<indices.length;i++){indexArray.pushBack(indices[i])}submesh.indices16=indexArray;submesh.indicesCount=indices.length}}catch(e){console.warn("ExtrudeGeometry: 更新 AMG 对象失败",e)}}center(){const positionAttribute=this.attributes.position;if(!positionAttribute)return this;const positions=positionAttribute.array;let minX=Infinity,minY=Infinity,minZ=Infinity;let maxX=-Infinity,maxY=-Infinity,maxZ=-Infinity;for(let i=0;i<positions.length;i+=3){const x=positions[i];const y=positions[i+1];const z=positions[i+2];if(x<minX)minX=x;if(x>maxX)maxX=x;if(y<minY)minY=y;if(y>maxY)maxY=y;if(z<minZ)minZ=z;if(z>maxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;i<positions.length;i+=3){positions[i]-=centerX;positions[i+1]-=centerY;positions[i+2]-=centerZ}if(this._amgObject){const vertexCount=positions.length/3;const buffer=new effect.Amaz.FloatVector;for(let i=0;i<vertexCount;i++){buffer.pushBack(positions[i*3]);buffer.pushBack(positions[i*3+1]);buffer.pushBack(positions[i*3+2])}this._amgObject.setAttributeData(effect.Amaz.VertexAttribType.POSITION,buffer,0,vertexCount)}return this}computeBoundingBox(){const positionAttribute=this.attributes.position;if(!positionAttribute){this.boundingBox=new Box3(new Vector3(0,0,0),new Vector3(0,0,0));return}const positions=positionAttribute.array;let minX=Infinity,minY=Infinity,minZ=Infinity;let maxX=-Infinity,maxY=-Infinity,maxZ=-Infinity;for(let i=0;i<positions.length;i+=3){const x=positions[i];const y=positions[i+1];const z=positions[i+2];if(x<minX)minX=x;if(x>maxX)maxX=x;if(y<minY)minY=y;if(y>maxY)maxY=y;if(z<minZ)minZ=z;if(z>maxZ)maxZ=z}this.boundingBox=new Box3(new Vector3(minX,minY,minZ),new Vector3(maxX,maxY,maxZ))}computeBoundingSphere(){const positionAttribute=this.attributes.position;if(!positionAttribute){this.boundingSphere={center:new Vector3(0,0,0),radius:0};return}const positions=positionAttribute.array;let minX=Infinity,minY=Infinity,minZ=Infinity;let maxX=-Infinity,maxY=-Infinity,maxZ=-Infinity;for(let i=0;i<positions.length;i+=3){const x=positions[i];const y=positions[i+1];const z=positions[i+2];if(x<minX)minX=x;if(x>maxX)maxX=x;if(y<minY)minY=y;if(y>maxY)maxY=y;if(z<minZ)minZ=z;if(z>maxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;i<positions.length;i+=3){const dx=positions[i]-centerX;const dy=positions[i+1]-centerY;const dz=positions[i+2]-centerZ;const distSq=dx*dx+dy*dy+dz*dz;if(distSq>maxRadiusSq)maxRadiusSq=distSq}this.boundingSphere={center:new Vector3(centerX,centerY,centerZ),radius:Math.sqrt(maxRadiusSq)}}dispose(){if(this.groups){this.groups.length=0;this.groups=null}this.parameters=null;this.depth=null;this.steps=null;this.bevelEnabled=null;this.bevelThickness=null;this.bevelSize=null;this.bevelOffset=null;this.bevelSegments=null;this.curveSegments=null;super.dispose()}}exports.ExtrudeGeometry=ExtrudeGeometry;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Group.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const{Object3D}=require("./Object3D");class Group extends Object3D{constructor(name="Group_w"){super(name)}dispose(){super.dispose()}}exports.Group=Group;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Material.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const __THREE_CONSTS=require("./Constants");class Material{constructor(){this.transparent=false;this._opacity=1;this.side=__THREE_CONSTS.FrontSide;this.visible=true;this.userData={};Object.defineProperty(this,"opacity",{get:()=>this._opacity,set:value=>{this._opacity=value;this._syncOpacityToAMG()},enumerable:true,configurable:true});this._blending=__THREE_CONSTS.NormalBlending;Object.defineProperty(this,"blending",{get:()=>this._blending,set:value=>{this._blending=value;this._syncBlendingToAMG()},enumerable:true,configurable:true});this._depthTest=true;this._depthWrite=true;Object.defineProperty(this,"depthTest",{get:()=>this._depthTest,set:value=>{this._depthTest=value;this._syncDepthToAMG()},enumerable:true,configurable:true});Object.defineProperty(this,"depthWrite",{get:()=>this._depthWrite,set:value=>{this._depthWrite=value;this._syncDepthToAMG()},enumerable:true,configurable:true})}_syncOpacityToAMG(){if(this._amgObject&&typeof this._amgObject.setFloat==="function"){try{this._amgObject.setFloat("u_Opacity",this._opacity);if(this._amgObject.setFloat&&typeof this._amgObject.setFloat==="function"){this._amgObject.setFloat("u_Alpha",this._opacity)}}catch(error){console.warn("Material: 同步透明度到AMG材质失败:",error)}}}_syncDepthToAMG(){if(this._amgObject!==undefined&&this._amgObject.xshader!==undefined){const depthStencilState=this._amgObject.xshader.passes.get(0).renderState.depthstencil;depthStencilState.depthTestEnable=this._depthTest;depthStencilState.depthWriteEnable=this._depthWrite}}_applyDepthDefaults(transparent,explicitDepthTest,explicitDepthWrite){if(transparent&&this._opacity<1){this._depthTest=explicitDepthTest!==undefined?explicitDepthTest:true;this._depthWrite=explicitDepthWrite!==undefined?explicitDepthWrite:false}else{this._depthTest=explicitDepthTest!==undefined?explicitDepthTest:true;this._depthWrite=explicitDepthWrite!==undefined?explicitDepthWrite:true}this._syncDepthToAMG()}_syncBlendingToAMG(){if(this._amgObject!==undefined&&this._amgObject.xshader!==undefined){const colorBlendState=this._amgObject.xshader.passes.get(0).renderState.colorBlend.attachments.get(0);const setBlendState=function(state,srcColor,dstColor,srcAlpha,dstAlpha){state.srcColorBlendFactor=srcColor;state.dstColorBlendFactor=dstColor;state.srcAlphaBlendFactor=srcAlpha;state.dstAlphaBlendFactor=dstAlpha};if(this._blending==__THREE_CONSTS.NoBlending){colorBlendState.blendEnable=false;setBlendState(colorBlendState,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA)}else if(this._blending==__THREE_CONSTS.NormalBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.SRC_ALPHA,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA,Amaz.BlendFactor.SRC_ALPHA,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA)}else if(this._blending==__THREE_CONSTS.AdditiveBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE)}else if(this._blending==__THREE_CONSTS.SubtractiveBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.ZERO,Amaz.BlendFactor.ONE_MINUS_SRC_COLOR,Amaz.BlendFactor.ZERO,Amaz.BlendFactor.ONE)}else if(this._blending==__THREE_CONSTS.MultiplyBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.DST_COLOR,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA,Amaz.BlendFactor.ZERO,Amaz.BlendFactor.ONE)}else{Amaz.LOGE("three-amg-wrapper","混合模式未实现:"+this._blending)}}}setOpacity(opacity){this.opacity=opacity;return this}clone(){return this}dispose(){this._amgObject=null}}exports.Material=Material;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const MathUtils={lerp:(a,b,t)=>a+(b-a)*t,degToRad:degrees=>degrees*Math.PI/180,radToDeg:radians=>radians*180/Math.PI,randFloat:(min,max)=>Math.random()*(max-min)+min,clamp:(value,min,max)=>Math.min(Math.max(value,min),max),euclideanModulo:(n,m)=>(n%m+m)%m,randFloatSpread:range=>Math.random()*range-range*.5};exports.MathUtils=MathUtils;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const Vector3=require("./Vector3").Vector3;class Matrix4{constructor(){this.elements=new Float32Array(16);this.identity()}identity(){const te=this.elements;te[0]=1;te[4]=0;te[8]=0;te[12]=0;te[1]=0;te[5]=1;te[9]=0;te[13]=0;te[2]=0;te[6]=0;te[10]=1;te[14]=0;te[3]=0;te[7]=0;te[11]=0;te[15]=1;return this}fromAMGMatrix4f(m){const te=this.elements;te[0]=m.get(0,0);te[4]=m.get(0,1);te[8]=m.get(0,2);te[12]=m.get(0,3);te[1]=m.get(1,0);te[5]=m.get(1,1);te[9]=m.get(1,2);te[13]=m.get(1,3);te[2]=m.get(2,0);te[6]=m.get(2,1);te[10]=m.get(2,2);te[14]=m.get(2,3);te[3]=m.get(3,0);te[7]=m.get(3,1);te[11]=m.get(3,2);te[15]=m.get(3,3);return this}copy(m){const te=this.elements;const me=m.elements;te[0]=me[0];te[1]=me[1];te[2]=me[2];te[3]=me[3];te[4]=me[4];te[5]=me[5];te[6]=me[6];te[7]=me[7];te[8]=me[8];te[9]=me[9];te[10]=me[10];te[11]=me[11];te[12]=me[12];te[13]=me[13];te[14]=me[14];te[15]=me[15];return this}multiplyMatrices(a,b){const ae=a.elements;const be=b.elements;const te=this.elements;const a11=ae[0],a12=ae[4],a13=ae[8],a14=ae[12];const a21=ae[1],a22=ae[5],a23=ae[9],a24=ae[13];const a31=ae[2],a32=ae[6],a33=ae[10],a34=ae[14];const a41=ae[3],a42=ae[7],a43=ae[11],a44=ae[15];const b11=be[0],b12=be[4],b13=be[8],b14=be[12];const b21=be[1],b22=be[5],b23=be[9],b24=be[13];const b31=be[2],b32=be[6],b33=be[10],b34=be[14];const b41=be[3],b42=be[7],b43=be[11],b44=be[15];te[0]=a11*b11+a12*b21+a13*b31+a14*b41;te[4]=a11*b12+a12*b22+a13*b32+a14*b42;te[8]=a11*b13+a12*b23+a13*b33+a14*b43;te[12]=a11*b14+a12*b24+a13*b34+a14*b44;te[1]=a21*b11+a22*b21+a23*b31+a24*b41;te[5]=a21*b12+a22*b22+a23*b32+a24*b42;te[9]=a21*b13+a22*b23+a23*b33+a24*b43;te[13]=a21*b14+a22*b24+a23*b34+a24*b44;te[2]=a31*b11+a32*b21+a33*b31+a34*b41;te[6]=a31*b12+a32*b22+a33*b32+a34*b42;te[10]=a31*b13+a32*b23+a33*b33+a34*b43;te[14]=a31*b14+a32*b24+a33*b34+a34*b44;te[3]=a41*b11+a42*b21+a43*b31+a44*b41;te[7]=a41*b12+a42*b22+a43*b32+a44*b42;te[11]=a41*b13+a42*b23+a43*b33+a44*b43;te[15]=a41*b14+a42*b24+a43*b34+a44*b44;return this}makeRotationZ(angle){const c=Math.cos(angle);const s=Math.sin(angle);this.identity();this.elements[0]=c;this.elements[4]=-s;this.elements[1]=s;this.elements[5]=c;return this}lookAt(eye,target,up){this.identity();const z=(new Vector3).subVectors(eye,target);if(z.length()===0){z.z=1}else{z.normalize()}const x=new Vector3;up.cross(z,x);if(x.lengthSq()===0){if(Math.abs(up.z)===1){z.x+=1e-4}else{z.z+=1e-4}z.normalize();up.cross(z,x)}x.normalize();const y=(new Vector3).cross(z,x).normalize();const te=this.elements;te[0]=x.x;te[1]=x.y;te[2]=x.z;te[3]=0;te[4]=y.x;te[5]=y.y;te[6]=y.z;te[7]=0;te[8]=z.x;te[9]=z.y;te[10]=z.z;te[11]=0;te[12]=0;te[13]=0;te[14]=0;te[15]=1;return this}compose(position,quaternion,scale){const te=this.elements;const x=quaternion.x,y=quaternion.y,z=quaternion.z,w=quaternion.w;const x2=x+x,y2=y+y,z2=z+z;const xx=x*x2,xy=x*y2,xz=x*z2;const yy=y*y2,yz=y*z2,zz=z*z2;const wx=w*x2,wy=w*y2,wz=w*z2;const sx=scale.x,sy=scale.y,sz=scale.z;te[0]=(1-(yy+zz))*sx;te[1]=(xy+wz)*sx;te[2]=(xz-wy)*sx;te[3]=0;te[4]=(xy-wz)*sy;te[5]=(1-(xx+zz))*sy;te[6]=(yz+wx)*sy;te[7]=0;te[8]=(xz+wy)*sz;te[9]=(yz-wx)*sz;te[10]=(1-(xx+yy))*sz;te[11]=0;te[12]=position.x;te[13]=position.y;te[14]=position.z;te[15]=1;return this}decompose(position,quaternion,scale){position.set(0,0,0);quaternion.set(0,0,0,1);scale.set(1,1,1)}}exports.Matrix4=Matrix4;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Mesh.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const getCurrentScene=require("./runtime").getCurrentScene;const{Object3D}=require("./Object3D");const{MeshBasicMaterial}=require("./MeshBasicMaterial");const{ShaderMaterial}=require("./ShaderMaterial");const{VideoTexture}=require("./Texture");class MeshWrapper extends Object3D{constructor(geometry,material){super("Mesh_w");this._amgEntity.scene=getCurrentScene()._amgScene;this._amgRenderEntity=new Amaz.Entity;this._amgRenderEntity.name="Render_w";this._amgRenderEntity.scene=getCurrentScene()._amgScene;this._amgRendertransform=this._amgRenderEntity.addComponent("Transform");this._transform.addTransform(this._amgRendertransform);this._amgRendertransform.localPosition=new effect.Amaz.Vector3f(geometry.translateValue.x||0,geometry.translateValue.y||0,geometry.translateValue.z||0);this._amgMeshRenderer=this._amgRenderEntity.addComponent("MeshRenderer");this._amgMeshRenderer.mesh=geometry._amgObject;if(material!=null){if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;i<material.length;i++)materials.pushBack(material[i]._amgObject);this._amgMeshRenderer.materials=materials}else{this._amgMeshRenderer.sharedMaterial=material._amgObject}}this.geometry=geometry;this.material=material;Object.defineProperty(this,"material",{get:()=>material,set:value=>{material=value;if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;i<value.length;i++){materials.pushBack(value[i]._amgObject)}this._amgMeshRenderer.materials=materials}else{this._amgMeshRenderer.sharedMaterial=value._amgObject}},enumerable:true,configurable:true})}update(){}getWorldPosition(target){return super.getWorldPosition(target||null)}getWorldQuaternion(target){return super.getWorldQuaternion(target||null)}seekToTime(time){if(this.material!==undefined&&this.material instanceof MeshBasicMaterial){if(this.material.map!==undefined&&this.material.map instanceof VideoTexture){const videoTexture=this.material.map;const renderer=videoTexture._amgSprite2DRenderer;if(renderer.materials.size()==1){const texture=renderer.materials.get(0).getTex("_MainTex");videoTexture.setImage(texture);this.material._updateMaterialParams();videoTexture._amgVideoAnimSeq.seekToTime(time/1e3)}}}else if(this.material!==undefined&&this.material instanceof ShaderMaterial){const uniforms=this.material.uniforms;if(uniforms!==undefined){for(const[key,uniform]of Object.entries(uniforms)){if(uniform.value!==undefined&&uniform.value instanceof VideoTexture){const videoTexture=uniform.value;const renderer=videoTexture._amgSprite2DRenderer;if(renderer.materials.size()==1){const texture=renderer.materials.get(0).getTex("_MainTex");videoTexture.setImage(texture);this.material._syncUniformToAMG(key,videoTexture);videoTexture._amgVideoAnimSeq.seekToTime(time/1e3)}}}}}}dispose(){const currentScene=getCurrentScene();if(this._amgEntity){if(currentScene&&currentScene._amgScene)currentScene._amgScene.removeEntity(this._amgEntity);if(this._amgMeshRenderer){this._amgEntity.removeComponent(this._amgMeshRenderer);this._amgMeshRenderer=null}if(this._transform){this._amgEntity.removeComponent(this._transform);this._transform=null}this._amgEntity=null}if(this.geometry&&this.geometry.dispose)this.geometry.dispose();if(this.material){if(Array.isArray(this.material))this.material.forEach(m=>m.dispose&&m.dispose());else if(this.material.dispose)this.material.dispose()}}}exports.MeshWrapper=MeshWrapper;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const Material=require("./Material").Material;const __THREE_CONSTS=require("./Constants");const Color=require("./Color").Color;const getCurrentScene=require("./runtime").getCurrentScene;class MeshBasicMaterial extends Material{constructor(parameters={}){super();this.scene=getCurrentScene();this._amgObject=this.scene._amgScene.assetMgr.SyncLoad("material/Unlit/Unlit.material").clone();this._color=parameters.color!==undefined?parameters.color instanceof Color?parameters.color:(new Color).setHex(parameters.color):new Color(1,1,1);this._map=null;this.wireframe=parameters.wireframe||false;this.transparent=parameters.transparent||false;this.opacity=parameters.opacity!==undefined?parameters.opacity:1;this._applyDepthDefaults(this.transparent,parameters.depthTest,parameters.depthWrite);this.blending=parameters.blending!==undefined?parameters.blending:__THREE_CONSTS.NormalBlending;this._amgObject.setVec4("u_AlbedoColor",this._color.toAMGColor());if(parameters.map){this.map=parameters.map}Object.defineProperty(this,"color",{get:()=>this._color,set:value=>{this._color=value;this._amgObject.setVec4("u_AlbedoColor",this._color.toAMGColor())}});const originalSetRGB=this._color.setRGB;const material=this;this.color.setRGB=function(r,g,b){originalSetRGB.call(this,r,g,b);if(material._amgObject){material._amgObject.setVec4("u_AlbedoColor",material._color.toAMGColor())}}}get map(){return this._map}set map(value){if(this._map){this._map._removeMaterial(this)}this._map=value;if(this._map&&this._map._amgObject){this._map._addMaterial(this);this._updateMaterialParams()}}_updateMaterialParams(){if(this._map&&this._map._amgObject){this._amgObject.setTex("u_AlbedoTexture",this._map._amgObject);this._amgObject.setVec2("u_Repeat",new effect.Amaz.Vector2f(this._map.repeat.x,this._map.repeat.y));this._amgObject.setVec2("u_Offset",new effect.Amaz.Vector2f(this._map.offset.x,this._map.offset.y))}}_updateTextureParams(){if(this._map&&this._map._amgObject){this._amgObject.setVec2("u_Repeat",new effect.Amaz.Vector2f(this._map.repeat.x,this._map.repeat.y));this._amgObject.setVec2("u_Offset",new effect.Amaz.Vector2f(this._map.offset.x,this._map.offset.y))}}clone(){const clonedColor=this._color instanceof Color?new Color(this._color.r,this._color.g,this._color.b):this._color;return new MeshBasicMaterial({color:clonedColor,map:this._map?this._map.clone():null,wireframe:this.wireframe,transparent:this.transparent,opacity:this.opacity,blending:this.blending})}dispose(){if(this._map){this._map._removeMaterial(this)}super.dispose()}}exports.MeshBasicMaterial=MeshBasicMaterial;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Object3D.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const getCurrentScene=require("./runtime").getCurrentScene;const Vector3=require("./Vector3").Vector3;const Euler=require("./Euler").Euler;const Matrix4=require("./Matrix4").Matrix4;const Quaternion=require("./Quaternion").Quaternion;const MathUtils=require("./MathUtils").MathUtils;class Object3D{constructor(name="Object3D_w"){this._amgEntity=new Amaz.Entity;this._amgEntity.name=name;this._transform=this._amgEntity.addComponent("Transform");this.children=[];this.userData={};this.visible=true;this.isCamera=false;this.up=new Vector3(0,1,0);this.matrix=new Matrix4;this.matrixAutoUpdate=true;Object.defineProperty(this,"matrixWorld",{get:()=>{return(new Matrix4).fromAMGMatrix4f(this._transform.getWorldMatrix())},set:value=>{this._transform.worldMatrix=new effect.Amaz.Matrix4f(value.elements[0],value.elements[1],value.elements[2],value.elements[3],value.elements[4],value.elements[5],value.elements[6],value.elements[7],value.elements[8],value.elements[9],value.elements[10],value.elements[11],value.elements[12],value.elements[13],value.elements[14],value.elements[15])},enumerable:true,configurable:true});Object.defineProperty(this,"name",{get:()=>this._amgEntity.name,set:value=>{this._amgEntity.name=value}});let _visible=this.visible;Object.defineProperty(this,"visible",{get:()=>_visible,set:value=>{_visible=value;this._amgEntity.visible=value},enumerable:true,configurable:true});this.position=new Vector3;let _posX=this.position.x,_posY=this.position.y,_posZ=this.position.z;const updateTransform=()=>{if(this._transform){this._transform.localPosition=new effect.Amaz.Vector3f(_posX,_posY,_posZ)}};Object.defineProperty(this.position,"x",{get:()=>_posX,set:v=>{_posX=v;updateTransform()},enumerable:true,configurable:true});Object.defineProperty(this.position,"y",{get:()=>_posY,set:v=>{_posY=v;updateTransform()},enumerable:true,configurable:true});Object.defineProperty(this.position,"z",{get:()=>_posZ,set:v=>{_posZ=v;updateTransform()},enumerable:true,configurable:true});this.position.set=(x,y,z)=>{_posX=x;_posY=y;_posZ=z;updateTransform();return this.position};this.position.copy=v=>{_posX=v.x;_posY=v.y;_posZ=v.z;updateTransform();return this.position};this.position.setX=x=>{_posX=x;updateTransform();return this.position};this.position.setY=y=>{_posY=y;updateTransform();return this.position};this.position.setZ=z=>{_posZ=z;updateTransform();return this.position};this.rotation=new Euler;let _rotX=this.rotation.x,_rotY=this.rotation.y,_rotZ=this.rotation.z;let _syncing=false;const updateRotation=()=>{if(_syncing)return;_syncing=true;try{const e=new Euler(_rotX,_rotY,_rotZ,this.rotation.order);const q=(new Quaternion).setFromEuler(e);if(this._transform){this._transform.localOrientation=new effect.Amaz.Quaternionf(q.x,q.y,q.z,q.w);this._transform.localEulerAngle=new effect.Amaz.Vector3f(_rotX/Math.PI*180,_rotY/Math.PI*180,_rotZ/Math.PI*180)}_qx=q.x;_qy=q.y;_qz=q.z;_qw=q.w;this.quaternion.x=q.x;this.quaternion.y=q.y;this.quaternion.z=q.z;this.quaternion.w=q.w}catch(_){}_syncing=false};Object.defineProperty(this.rotation,"x",{get:()=>_rotX,set:v=>{_rotX=v;updateRotation()},enumerable:true,configurable:true});Object.defineProperty(this.rotation,"y",{get:()=>_rotY,set:v=>{_rotY=v;updateRotation()},enumerable:true,configurable:true});Object.defineProperty(this.rotation,"z",{get:()=>_rotZ,set:v=>{_rotZ=v;updateRotation()},enumerable:true,configurable:true});this.rotation.set=(x,y,z,order)=>{if(order===undefined||order===null){this.rotation.x=x;this.rotation.y=y;this.rotation.z=z;return this.rotation}this.rotation.order=order;this.quaternion=new Quaternion;for(let i=0;i<order.length;i++){const ch=order[i];let q=new Quaternion;if(ch==="X")q.setFromAxisAngle(new Vector3(1,0,0),x);else if(ch==="Y")q.setFromAxisAngle(new Vector3(0,1,0),y);else if(ch==="Z")q.setFromAxisAngle(new Vector3(0,0,1),z);this.quaternion.multiply(q)}const amgQuat=new effect.Amaz.Quaternionf(this.quaternion.x,this.quaternion.y,this.quaternion.z,this.quaternion.w);const euler=amgQuat.quaternionToEuler();this.rotation.x=euler.x;this.rotation.y=euler.y;this.rotation.z=euler.z;this.rotation.order=order;return this.rotation};this.rotation.copy=v=>{this.rotation.x=v.x;this.rotation.y=v.y;this.rotation.z=v.z;this.rotation.order=v.order;return this.rotation};this.quaternion=new Quaternion;let _qx=this.quaternion.x,_qy=this.quaternion.y,_qz=this.quaternion.z,_qw=this.quaternion.w;const updateQuaternion=()=>{if(_syncing)return;_syncing=true;try{if(this._transform){const amgQuat=new effect.Amaz.Quaternionf(_qx,_qy,_qz,_qw);this._transform.localOrientation=amgQuat;const euler=amgQuat.quaternionToEuler();_rotX=euler.x;_rotY=euler.y;_rotZ=euler.z;this._transform.localEulerAngle=new effect.Amaz.Vector3f(_rotX/Math.PI*180,_rotY/Math.PI*180,_rotZ/Math.PI*180)}_rotX=_rotX;_rotY=_rotY;_rotZ=_rotZ}catch(_){}_syncing=false};Object.defineProperty(this.quaternion,"x",{get:()=>_qx,set:v=>{_qx=v;updateQuaternion()},enumerable:true,configurable:true});Object.defineProperty(this.quaternion,"y",{get:()=>_qy,set:v=>{_qy=v;updateQuaternion()},enumerable:true,configurable:true});Object.defineProperty(this.quaternion,"z",{get:()=>_qz,set:v=>{_qz=v;updateQuaternion()},enumerable:true,configurable:true});Object.defineProperty(this.quaternion,"w",{get:()=>_qw,set:v=>{_qw=v;updateQuaternion()},enumerable:true,configurable:true});this.quaternion.set=function(x,y,z,w){_qx=x;_qy=y;_qz=z;_qw=w;updateQuaternion();return this};this.quaternion.copy=function(q){_qx=q.x;_qy=q.y;_qz=q.z;_qw=q.w;updateQuaternion();return this};const originalSetFromAxisAngle=this.quaternion.setFromAxisAngle.bind(this.quaternion);this.quaternion.setFromAxisAngle=function(axis,angle){const r=originalSetFromAxisAngle(axis,angle);_qx=this.x;_qy=this.y;_qz=this.z;_qw=this.w;updateQuaternion();return r};this.scale=new Vector3(1,1,1);let _sx=this.scale.x,_sy=this.scale.y,_sz=this.scale.z;const updateScale=()=>{if(this._transform)this._transform.localScale=new effect.Amaz.Vector3f(_sx,_sy,_sz)};Object.defineProperty(this.scale,"x",{get:()=>_sx,set:v=>{_sx=v;updateScale()},enumerable:true,configurable:true});Object.defineProperty(this.scale,"y",{get:()=>_sy,set:v=>{_sy=v;updateScale()},enumerable:true,configurable:true});Object.defineProperty(this.scale,"z",{get:()=>_sz,set:v=>{_sz=v;updateScale()},enumerable:true,configurable:true});this.scale.set=(x,y,z)=>{_sx=x;_sy=y;_sz=z;updateScale();return this.scale};this.scale.setScalar=v=>{_sx=v;_sy=v;_sz=v;updateScale()};this.scale.setX=x=>{_sx=x;updateScale();return this.scale};this.scale.setY=y=>{_sy=y;updateScale();return this.scale};this.scale.setZ=z=>{_sz=z;updateScale();return this.scale};this.scale.copy=v=>{_sx=v.x;_sy=v.y;_sz=v.z;updateScale();return this.scale}}clone(recursive=true){const cloned=new Object3D(this.name+"_clone");cloned.visible=this.visible;cloned.isCamera=this.isCamera;cloned.up.copy(this.up);cloned.userData={...this.userData};cloned.position.copy(this.position);cloned.rotation.copy(this.rotation);cloned.quaternion.copy(this.quaternion);cloned.scale.copy(this.scale);if(recursive){for(const child of this.children){const clonedChild=child.clone(recursive);cloned.add(clonedChild)}}return cloned}traverse(callback){callback(this);if(this.children&&this.children.length>0){this.children.forEach(child=>{if(child.traverse)child.traverse(callback);else callback(child)})}}getWorldPosition(target){if(!target)target=new Vector3;if(this._transform&&this._transform.worldPosition){target.set(this._transform.worldPosition.x,this._transform.worldPosition.y,this._transform.worldPosition.z)}else{target.copy(this.position)}return target}getWorldQuaternion(target){if(!target)target=new Quaternion;if(this._transform&&this._transform.worldOrientation)target.fromAMGQuaternion(this._transform.worldOrientation);else target.copy(this.quaternion);return target}add(object){if(object===this){console.warn("Object3D.add: 不能将对象添加到自身");return this}if(object.parent!==undefined){object.parent.remove(object)}object.parent=this;this.children.push(object);if(object._transform)this._transform.addTransform(object._transform);return this}remove(object){const index=this.children.indexOf(object);if(index!==-1){object.parent=undefined;this.children.splice(index,1);const currentScene=getCurrentScene();if(currentScene&&currentScene._amgScene)currentScene._amgScene.removeEntity(object._amgEntity)}return this}attach(child){if(!child||!child._transform){console.warn("attach error: invalid child or missing _transform component");return}this.children.push(child);this._transform.addTransform(child._transform);child._transform.worldPosition=child._transform.localPosition;child._transform.worldRotation=child._transform.localRotation;child._transform.worldScale=child._transform.localScale;return this}rotateX(angle){this.rotation.x+=angle;return this}rotateY(angle){this.rotation.y+=angle;return this}rotateZ(angle){this.rotation.z+=angle;return this}rotateOnAxis(vec3,rad){const axis=vec3.clone().normalize();const q=(new Quaternion).setFromAxisAngle(axis,rad);const currentQuat=this.quaternion.clone();currentQuat.multiply(q);this.quaternion.set(currentQuat.x,currentQuat.y,currentQuat.z,currentQuat.w);if(this._transform){const amgQuat=new effect.Amaz.Quaternionf(this.quaternion.x,this.quaternion.y,this.quaternion.z,this.quaternion.w);const euler=amgQuat.quaternionToEuler();this.rotation.set(euler.x,euler.y,euler.z)}return this}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale)}updateMatrixWorld(flag){}lookAt(x,y,z){if(x instanceof Vector3){this.lookAt(x.x,x.y,x.z);return this}const pos=new Vector3(this._transform.worldPosition.x,this._transform.worldPosition.y,this._transform.worldPosition.z);const tarOri=new Vector3(x,y,z);const Tar3=new Vector3(2*pos.x-tarOri.x,2*pos.y-tarOri.y,2*pos.z-tarOri.z);if(!this.isCamera){Tar3.copy(tarOri)}const normal=Tar3.clone().normalize();const angle=new Vector3(0-normal.x,1-normal.y,0-normal.z);if(angle.length()<.001)return this;const tar=new effect.Amaz.Vector3f(Tar3.x,Tar3.y,Tar3.z);const up=new effect.Amaz.Vector3f(0,1,0);this._transform.lookAt(tar,up);this.quaternion.set(this._transform.localOrientation.x,this._transform.localOrientation.y,this._transform.localOrientation.z,this._transform.localOrientation.w);return this}worldToLocal(worldPos){const localPos=new Vector3;if(!this._transform||!worldPos)return localPos;const thisWorldPos=this._transform.worldPosition;localPos.set(worldPos.x-thisWorldPos.x,worldPos.y-thisWorldPos.y,worldPos.z-thisWorldPos.z);try{if(this._transform.worldOrientation){const worldQ=(new Quaternion).fromAMGQuaternion(this._transform.worldOrientation).normalize();const invQ=new Quaternion(-worldQ.x,-worldQ.y,-worldQ.z,worldQ.w).normalize();localPos.applyQuaternion(invQ)}else if(this._transform.worldRotation){const ex=this._transform.worldRotation.x/180*Math.PI;const ey=this._transform.worldRotation.y/180*Math.PI;const ez=this._transform.worldRotation.z/180*Math.PI;const worldEuler=new Euler(ex,ey,ez);const worldQ=(new Quaternion).setFromEuler(worldEuler).normalize();const invQ=new Quaternion(-worldQ.x,-worldQ.y,-worldQ.z,worldQ.w).normalize();localPos.applyQuaternion(invQ)}}catch(_){}if(this._transform.worldScale){const ws=this._transform.worldScale;const sx=ws.x||1,sy=ws.y||1,sz=ws.z||1;if(sx!==0)localPos.x/=sx;if(sy!==0)localPos.y/=sy;if(sz!==0)localPos.z/=sz}return localPos}updateWorldMatrix(force=false,updateParents=false){}dispose(){while(this.children.length>0){const child=this.children[0];this.remove(child);if(child.dispose&&typeof child.dispose==="function")child.dispose()}const currentScene=getCurrentScene();if(currentScene&&currentScene._amgScene)currentScene._amgScene.removeEntity(this._amgEntity);if(this._transform){this._amgEntity.removeComponent(this._transform);this._transform=null}this._amgEntity=null;this.children=[]}}exports.Object3D=Object3D;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const{Object3D}=require("./Object3D");const{getCurrentScene}=require("./runtime");class PerspectiveCamera extends Object3D{constructor(fov=75,aspect=1,near=.1,far=1e3){super("PerspectiveCamera_w");this._amgEntity.scene=getCurrentScene()._amgScene;this.isCamera=true;this._amgObject=this._amgEntity.addComponent("Camera");this._amgObject.type=effect.Amaz.CameraType.PERSPECTIVE;this._amgObject.clearType=effect.Amaz.CameraClearType.COLOR_DEPTH;this._amgObject.clearColor=new effect.Amaz.Color(0,0,0,0);this._amgObject.layerVisibleMask=new effect.Amaz.DynamicBitset(1,1);this._amgObject.renderOrder=0;const renderTexture=getCurrentScene()._amgScene.assetMgr.SyncLoad("rt/RT_0.rt");this._amgObject.renderTexture=renderTexture;this._fov=fov;this.fovy=fov;this.aspect=aspect;this.near=near;this.far=far;this.updateProjectionMatrix()}set fov(value){this._fov=value;this.fovy=value;this.updateProjectionMatrix()}updateProjectionMatrix(){this._amgObject.fovy=this.fovy;this._amgObject.aspect=this.aspect;this._amgObject.zNear=this.near;this._amgObject.zFar=this.far}update(){}dispose(){const currentScene=getCurrentScene();if(this._amgEntity){if(currentScene&&currentScene._amgScene)currentScene._amgScene.removeEntity(this._amgEntity);if(this._amgObject.renderTexture){this._amgObject.renderTexture=null}if(this._amgObject){this._amgEntity.removeComponent(this._amgObject);this._amgObject=null}if(this._transform){this._amgEntity.removeComponent(this._transform);this._transform=null}this._amgEntity=null}}}exports.PerspectiveCamera=PerspectiveCamera;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");class PlaneGeometry extends BufferGeometry{constructor(width=1,height=1,widthSegments=1,heightSegments=1){super();this.width=width;this.height=height;this.widthSegments=widthSegments;this.heightSegments=heightSegments;const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Quad.mesh").clone()}else{console.warn("PlaneGeometry: 无法加载Quad.mesh,scerne未创建")}{var vertexAttribs=this._amgObject.vertexAttribs;var attribDesc0=new effect.Amaz.VertexAttribDesc;attribDesc0.semantic=effect.Amaz.VertexAttribType.POSITION_OFFSET;attribDesc0.bindingIndex=0;attribDesc0.offset=36;attribDesc0.componentCount=3;vertexAttribs.pushBack(attribDesc0);var attribDesc1=new effect.Amaz.VertexAttribDesc;attribDesc1.semantic=effect.Amaz.VertexAttribType.TEXCOORD1;attribDesc1.bindingIndex=0;attribDesc1.offset=48;attribDesc1.componentCount=2;vertexAttribs.pushBack(attribDesc1);this._amgObject.vertexAttribs=vertexAttribs;const submesh=this._amgObject.submeshes.get(0);if(submesh){submesh.primitive=effect.Amaz.Primitive.TRIANGLES}}const gridX=widthSegments;const gridY=heightSegments;const gridX1=gridX+1;const gridY1=gridY+1;const segmentWidth=width/gridX;const segmentHeight=height/gridY;const vertices=[];const uvs=[];const indices=[];for(let iy=0;iy<gridY1;iy++){const y=iy*segmentHeight-height/2;for(let ix=0;ix<gridX1;ix++){const x=ix*segmentWidth-width/2;vertices.push(x,-y,0);uvs.push(ix/gridX,1-iy/gridY)}}for(let iy=0;iy<gridY;iy++){for(let ix=0;ix<gridX;ix++){const a=iy*gridX1+ix;const b=iy*gridX1+ix+1;const c=(iy+1)*gridX1+ix+1;const d=(iy+1)*gridX1+ix;indices.push(a,b,c,a,c,d)}}this.setAttribute("position",new BufferAttribute(new Float32Array(vertices),3));this.setAttribute("uv",new BufferAttribute(new Float32Array(uvs),2));this.setIndex(indices)}}exports.PlaneGeometry=PlaneGeometry;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Quaternion.js ADDED
@@ -0,0 +1 @@
 
 
1
+ class Quaternion{constructor(x=0,y=0,z=0,w=1){this.x=x;this.y=y;this.z=z;this.w=w}set(x,y,z,w){this.x=x;this.y=y;this.z=z;this.w=w;return this}copy(q){this.x=q.x;this.y=q.y;this.z=q.z;this.w=q.w;return this}clone(){return new Quaternion(this.x,this.y,this.z,this.w)}normalize(){const len=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(len>0){const invLen=1/len;this.x*=invLen;this.y*=invLen;this.z*=invLen;this.w*=invLen}return this}identity(){this.x=0;this.y=0;this.z=0;this.w=1;return this}multiply(q){const x=this.x,y=this.y,z=this.z,w=this.w;const qx=q.x,qy=q.y,qz=q.z,qw=q.w;this.x=w*qx+x*qw+y*qz-z*qy;this.y=w*qy-x*qz+y*qw+z*qx;this.z=w*qz+x*qy-y*qx+z*qw;this.w=w*qw-x*qx-y*qy-z*qz;return this}setFromAxisAngle(axis,angle){const halfAngle=angle/2;const s=Math.sin(halfAngle);this.x=axis.x*s;this.y=axis.y*s;this.z=axis.z*s;this.w=Math.cos(halfAngle);return this}setFromEuler(euler){const x=euler.x/2;const y=euler.y/2;const z=euler.z/2;const cx=Math.cos(x);const sx=Math.sin(x);const cy=Math.cos(y);const sy=Math.sin(y);const cz=Math.cos(z);const sz=Math.sin(z);this.x=sx*cy*cz+cx*sy*sz;this.y=cx*sy*cz-sx*cy*sz;this.z=cx*cy*sz+sx*sy*cz;this.w=cx*cy*cz-sx*sy*sz;return this}slerp(q,t){const dot=this.x*q.x+this.y*q.y+this.z*q.z+this.w*q.w;let qx=q.x,qy=q.y,qz=q.z,qw=q.w;let dotValue=dot;if(dot<0){qx=-qx;qy=-qy;qz=-qz;qw=-qw;dotValue=-dotValue}const dotClamped=Math.max(-1,Math.min(1,dotValue));const theta=Math.acos(dotClamped);if(theta<.001){this.x=this.x+(qx-this.x)*t;this.y=this.y+(qy-this.y)*t;this.z=this.z+(qz-this.z)*t;this.w=this.w+(qw-this.w)*t}else{const sinTheta=Math.sin(theta);const sinThetaT=Math.sin(theta*t);const sinTheta1T=Math.sin(theta*(1-t));this.x=(this.x*sinTheta1T+qx*sinThetaT)/sinTheta;this.y=(this.y*sinTheta1T+qy*sinThetaT)/sinTheta;this.z=(this.z*sinTheta1T+qz*sinThetaT)/sinTheta;this.w=(this.w*sinTheta1T+qw*sinThetaT)/sinTheta}this.normalize();return this}setFromRotationMatrix(matrix){const te=matrix.elements;const m11=te[0],m12=te[4],m13=te[8];const m21=te[1],m22=te[5],m23=te[9];const m31=te[2],m32=te[6],m33=te[10];const trace=m11+m22+m33;let s;if(trace>0){s=Math.sqrt(trace+1)*2;this.w=.25*s;this.x=(m32-m23)/s;this.y=(m13-m31)/s;this.z=(m21-m12)/s}else if(m11>m22&&m11>m33){s=Math.sqrt(1+m11-m22-m33)*2;this.w=(m32-m23)/s;this.x=.25*s;this.y=(m12+m21)/s;this.z=(m13+m31)/s}else if(m22>m33){s=Math.sqrt(1+m22-m11-m33)*2;this.w=(m13-m31)/s;this.x=(m12+m21)/s;this.y=.25*s;this.z=(m23+m32)/s}else{s=Math.sqrt(1+m33-m11-m22)*2;this.w=(m21-m12)/s;this.x=(m13+m31)/s;this.y=(m23+m32)/s;this.z=.25*s}this.normalize();if(this.w<0){this.x=-this.x;this.y=-this.y;this.z=-this.z;this.w=-this.w}return this}slerpQuaternions(q1,q2,t){this.copy(q1);return this.slerp(q2,t)}toArray(){return[this.x,this.y,this.z,this.w]}toString(){return`Quaternion(${this.x}, ${this.y}, ${this.z}, ${this.w})`}toAMGQuaternion(){return new effect.Amaz.Quaternionf(this.x,this.y,this.z,this.w)}fromAMGQuaternion(q){this.x=q.x;this.y=q.y;this.z=q.z;this.w=q.w;return this}}exports.Quaternion=Quaternion;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const Material=require("./Material").Material;const __THREE_CONSTS=require("./Constants");const getCurrentScene=require("./runtime").getCurrentScene;const Vector2=require("./Vector2").Vector2;const Vector3=require("./Vector3").Vector3;const Vector4=require("./Vector4").Vector4;const Color=require("./Color").Color;const Texture=require("./Texture").Texture;const ARRAY_PROXY_FLAG=Symbol("ShaderMaterialArrayProxy");const MUTATING_ARRAY_METHODS=new Set(["push","pop","shift","unshift","splice","sort","reverse","fill","copyWithin","copy","set"]);const __uniformBindingMap=new WeakMap;function __registerUniformBinding(uniform,material,key){let list=__uniformBindingMap.get(uniform);if(!list){list=[];__uniformBindingMap.set(uniform,list)}if(!list.some(b=>b.material===material&&b.key===key)){list.push({material:material,key:key})}}function __notifyUniformBindings(uniform,value){const list=__uniformBindingMap.get(uniform);if(!list)return;for(const b of list){if(b&&b.material&&typeof b.material._syncUniformToAMG==="function"){b.material._syncUniformToAMG(b.key,value)}}}class ShaderMaterial extends Material{constructor(parameters={}){super();this.originalVertexShader=parameters.vertexShader;this.originalFragmentShader=parameters.fragmentShader;this.scene=getCurrentScene();this._amgObject=this.scene._amgScene.assetMgr.SyncLoad("material/Unlit/Unlit.material").clone();this.transparent=parameters.transparent||false;this.opacity=parameters.opacity!==undefined?parameters.opacity:1;this._applyDepthDefaults(this.transparent,parameters.depthTest,parameters.depthWrite);if(this.transparent==true){this.blending=parameters.blending!==undefined?parameters.blending:__THREE_CONSTS.NormalBlending}else{this.blending=parameters.blending!==undefined?parameters.blending:__THREE_CONSTS.NoBlending}this._originalUniforms=parameters.uniforms||{};this._uniforms=this._createUniformsProxy(this._originalUniforms);this._hookUniforms(this._originalUniforms);if(parameters.uniforms){for(const[key,value]of Object.entries(parameters.uniforms)){this._syncUniformToAMG(key,value.value)}}let key="";if(parameters.vertexShader&&parameters.fragmentShader){let vertLength=parameters.vertexShader.length;let fragLength=parameters.fragmentShader.length;if(vertLength>0&&fragLength>0){key="c_"+vertLength+"_"+fragLength}}let xshader=this._amgObject.xshader.clone();let passes=xshader.passes;let pass=passes.get(0);let shaders=pass.shaders;let gles2=shaders.get("gles2");let glesShader1=gles2.get(0);let glesShader2=gles2.get(1);if(parameters.vertexShader){let shader=parameters.vertexShader;shader=shader.replace(/\buv\b/g,"attTexcoord0");shader=shader.replace(/\bnormal\b/g,"attNormal");shader=shader.replace(/\bposition\b/g,"attPosition");shader=shader.replace(/\bnormalMatrix\b/g,"mat3(u_MV)");shader=shader.replace(/\bmodelMatrix\b/g,"u_Model");shader=shader.replace(/\bviewMatrix\b/g,"u_View");shader=shader.replace(/\bmodelViewMatrix\b/g,"u_MV");shader=shader.replace(/\bprojectionMatrix\b/g,"u_Projection");shader=shader.replace(/\bmodelViewProjectionMatrix\b/g,"u_MVP");shader=shader.replace(/\bu_Projection \* u_View \* u_Model\b/g,"u_MVP");shader=shader.replace(/\bu_Projection \* u_MV\b/g,"u_MVP");parameters.vertexShader="precision highp float; attribute vec3 attPosition; attribute vec2 attTexcoord0; attribute vec3 attNormal; uniform mat4 u_MVP; uniform mat4 u_MV; uniform mat4 u_Projection; uniform mat4 u_Model; uniform mat4 u_View; "+shader;glesShader1.source=parameters.vertexShader;glesShader1.sourcePath=""}if(parameters.fragmentShader){parameters.fragmentShader="precision highp float;"+parameters.fragmentShader;glesShader2.source=parameters.fragmentShader;glesShader2.sourcePath=""}var rootDir=this.scene._amgScene.assetMgr.rootDir;var vertMetalPath=rootDir+"xshader/"+key+".vert.metal";var fragMetalPath=rootDir+"xshader/"+key+".frag.metal";var metalFileExist=false;var swingTemplateUtils=null;if(effect.Amaz.SwingTemplateUtils){swingTemplateUtils=new effect.Amaz.SwingTemplateUtils}if(swingTemplateUtils&&swingTemplateUtils.isFileExist(vertMetalPath)&&swingTemplateUtils.isFileExist(fragMetalPath)){metalFileExist=true}if(metalFileExist==false){let metal=shaders.get("metal");if(metal){shaders.remove("metal")}}else{let metal=shaders.get("metal");let metalShader1=metal.get(0);let metalShader2=metal.get(1);metalShader1.source="";metalShader1.sourcePath="xshader/"+key+".vert.metal";metalShader2.source="";metalShader2.sourcePath="xshader/"+key+".frag.metal"}this._amgObject.xshader=xshader}_createUniformsProxy(originalUniforms){const uniformsProxy={};for(const[key,uniform]of Object.entries(originalUniforms)){uniformsProxy[key]={get value(){return uniform.value},set value(newValue){uniform.value=newValue}}}return uniformsProxy}_cloneUniforms(sourceUniforms){if(!sourceUniforms)return{};const cloned={};for(const[key,uniform]of Object.entries(sourceUniforms)){if(!uniform||typeof uniform!=="object")continue;cloned[key]={value:this._cloneUniformValue(uniform.value)}}return cloned}_cloneUniformValue(value){if(value instanceof Texture){return value}if(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4){return typeof value.clone==="function"?value.clone():value}if(value instanceof Color){return new Color(value.r,value.g,value.b)}if(Array.isArray(value)){return value.map(v=>this._cloneUniformValue(v))}if(value&&typeof value==="object"){return{...value}}return value}_hookUniforms(originalUniforms){if(!originalUniforms)return;for(const[key,uniform]of Object.entries(originalUniforms)){this._hookSingleUniform(key,uniform)}}_hookSingleUniform(key,uniform){if(!uniform||typeof uniform!=="object")return;this._normalizeUniformValue(uniform);__registerUniformBinding(uniform,this,key);this._attachUniformVectorObserver(uniform);this._attachUniformArrayObserver(uniform,key);if(uniform._amgUniformHooked)return;try{let _val=uniform.value;Object.defineProperty(uniform,"value",{get:()=>_val,set:v=>{_val=this._convertUniformValue(v);this._attachUniformVectorObserver(uniform,_val);const proxied=this._attachUniformArrayObserver(uniform,key,_val);if(proxied){_val=proxied}__notifyUniformBindings(uniform,_val)},enumerable:true,configurable:true});const proxied=this._attachUniformArrayObserver(uniform,key,_val);if(proxied){_val=proxied}Object.defineProperty(uniform,"_amgUniformHooked",{value:true,enumerable:false,configurable:true})}catch(e){}}_looksLikeVector(obj,components){if(!obj||typeof obj!=="object")return false;return components.every(c=>typeof obj[c]==="number")}_normalizeUniformValue(uniform){if(!uniform||typeof uniform!=="object"||!("value"in uniform))return;const converted=this._convertUniformValue(uniform.value);if(converted===uniform.value)return;const descriptor=Object.getOwnPropertyDescriptor(uniform,"value");if(descriptor&&typeof descriptor.set==="function"&&typeof descriptor.get==="function"){descriptor.set.call(uniform,converted)}else{uniform.value=converted}}_convertUniformValue(value){if(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4){return value}if(value instanceof Color){return new Vector3(value.r,value.g,value.b)}if(Array.isArray(value)){const nums=value;if(nums.length===2&&nums.every(v=>typeof v==="number")){return new Vector2(nums[0],nums[1])}else if(nums.length===3&&nums.every(v=>typeof v==="number")){return new Vector3(nums[0],nums[1],nums[2])}else if(nums.length===4&&nums.every(v=>typeof v==="number")){return new Vector4(nums[0],nums[1],nums[2],nums[3])}return value}if(this._looksLikeVector(value,["x","y","z","w"])){return new Vector4(value.x,value.y,value.z,value.w)}else if(this._looksLikeVector(value,["x","y","z"])){return new Vector3(value.x,value.y,value.z)}else if(this._looksLikeVector(value,["x","y"])){return new Vector2(value.x,value.y)}return value}_attachUniformVectorObserver(uniform,valueOverride){if(!uniform||typeof uniform!=="object"||!("value"in uniform))return;const value=valueOverride||uniform.value;if(!(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4||value instanceof Color)){return}if(value.__amgUniformVectorHooked)return;const wrapMethod=methodName=>{if(typeof value[methodName]!=="function")return;const original=value[methodName].bind(value);value[methodName]=(...args)=>{const result=original(...args);__notifyUniformBindings(uniform,value);return result}};wrapMethod("set");wrapMethod("copy");if(value instanceof Color){wrapMethod("setRGB");wrapMethod("setHex");wrapMethod("setHexString");wrapMethod("setHSL")}Object.defineProperty(value,"__amgUniformVectorHooked",{value:true,enumerable:false,configurable:true})}_attachUniformArrayObserver(uniform,key,valueOverride){if(!uniform||typeof uniform!=="object")return null;const value=valueOverride||uniform.value;const isTyped=this._isTypedArray(value);if(!Array.isArray(value)&&!isTyped)return null;if(value&&value[ARRAY_PROXY_FLAG])return value;const notifyArrayChange=()=>{try{__notifyUniformBindings(uniform,proxy)}catch(e){try{this._syncUniformToAMG(key,{value:proxy})}catch(err){}}};const proxy=this._getArrayProxy(value,notifyArrayChange);if(Array.isArray(value)){for(let i=0;i<value.length;i++){const element=value[i];if(element instanceof Vector2||element instanceof Vector3||element instanceof Vector4){if(!element.__amgArrayElementHooked){const wrapElementMethod=methodName=>{if(typeof element[methodName]!=="function")return;const original=element[methodName].bind(element);element[methodName]=(...args)=>{const result=original(...args);notifyArrayChange();return result}};wrapElementMethod("set");wrapElementMethod("copy");Object.defineProperty(element,"__amgArrayElementHooked",{value:true,enumerable:false,configurable:true})}}}}return proxy}_getArrayProxy(arrayTarget,onChange){if(!this._arrayProxyMap){this._arrayProxyMap=new WeakMap}if(this._arrayProxyMap.has(arrayTarget)){return this._arrayProxyMap.get(arrayTarget)}const notifyChange=()=>{try{onChange()}catch(e){}};const handler={get(target,prop,receiver){const value=Reflect.get(target,prop,receiver);if(typeof value==="function"&&MUTATING_ARRAY_METHODS.has(prop)){return function(){const result=value.apply(target,arguments);notifyChange();return result}}if(typeof prop==="string"&&/^\d+$/.test(prop)&&(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4)){if(!value.__amgArrayElementHooked){const wrapElementMethod=methodName=>{if(typeof value[methodName]!=="function")return;const original=value[methodName].bind(value);value[methodName]=(...args)=>{const result=original(...args);notifyChange();return result}};wrapElementMethod("set");wrapElementMethod("copy");Object.defineProperty(value,"__amgArrayElementHooked",{value:true,enumerable:false,configurable:true})}}return value},set(target,prop,value,receiver){const result=Reflect.set(target,prop,value,receiver);if(typeof prop==="string"&&/^\d+$/.test(prop)&&(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4)){if(!value.__amgArrayElementHooked){const wrapElementMethod=methodName=>{if(typeof value[methodName]!=="function")return;const original=value[methodName].bind(value);value[methodName]=(...args)=>{const result=original(...args);notifyChange();return result}};wrapElementMethod("set");wrapElementMethod("copy");Object.defineProperty(value,"__amgArrayElementHooked",{value:true,enumerable:false,configurable:true})}}notifyChange();return result}};const proxy=new Proxy(arrayTarget,handler);Object.defineProperty(proxy,ARRAY_PROXY_FLAG,{value:true,enumerable:false,configurable:false});this._arrayProxyMap.set(arrayTarget,proxy);return proxy}_isTypedArray(value){return typeof ArrayBuffer!=="undefined"&&typeof ArrayBuffer.isView==="function"&&ArrayBuffer.isView(value)}_resolveUniformValueAndType(key,valueOrObject){let resolvedValue=valueOrObject;let resolvedType=undefined;if(valueOrObject&&typeof valueOrObject==="object"&&valueOrObject!==null&&"value"in valueOrObject){resolvedValue=valueOrObject.value;resolvedType=valueOrObject.type}if(!resolvedType&&this._originalUniforms&&this._originalUniforms[key]&&typeof this._originalUniforms[key]==="object"){resolvedType=this._originalUniforms[key].type}return{value:resolvedValue,type:resolvedType}}_syncUniformToAMG(key,valueOrObject){if(!this._amgObject)return;const{value,type}=this._resolveUniformValueAndType(key,valueOrObject);if(value===undefined||value===null)return;const convertedValue=Array.isArray(value)||this._isTypedArray(value)?value:this._convertUniformValue(value);let yModified=undefined;if(convertedValue instanceof Vector2||convertedValue instanceof Vector3){if(key==="videoTextureRepeat")yModified=-convertedValue.y;else if(key==="videoTextureOffset")yModified=-convertedValue.y+1;else yModified=convertedValue.y}const toVec2=(x,y)=>new effect.Amaz.Vector2f(x,y);const toVec3=(x,y,z)=>new effect.Amaz.Vector3f(x,y,z);const toVec4=(x,y,z,w)=>new effect.Amaz.Vector4f(x,y,z,w);const numbersOnly=arr=>Array.isArray(arr)&&arr.every(item=>typeof item==="number");try{if(convertedValue instanceof Texture){this._amgObject.setTex(key,convertedValue._amgObject);return}if(convertedValue instanceof Vector2){const y=typeof yModified==="number"?yModified:convertedValue.y;this._amgObject.setVec2(key,toVec2(convertedValue.x,y));return}if(convertedValue instanceof Vector3){this._amgObject.setVec3(key,toVec3(convertedValue.x,convertedValue.y,convertedValue.z));return}if(convertedValue instanceof Vector4){this._amgObject.setVec4(key,toVec4(convertedValue.x,convertedValue.y,convertedValue.z,convertedValue.w));return}if(typeof convertedValue==="number"){if(type&&type==="i"){this._amgObject.setInt(key,convertedValue)}else{this._amgObject.setFloat(key,convertedValue)}return}if(typeof convertedValue==="boolean"){this._amgObject.setFloat(key,convertedValue?1:0);return}if(Array.isArray(convertedValue)||this._isTypedArray(convertedValue)){let arr=Array.isArray(convertedValue)?convertedValue.slice():Array.from(convertedValue);if(Array.isArray(arr[0])){arr=arr.flat()}const allNums=numbersOnly(arr);if(!type||type==="vec2"||type==="vec3"||type==="vec4"){if(arr.length===2&&allNums&&(!type||type==="vec2")){this._amgObject.setVec2(key,toVec2(arr[0],arr[1]));return}if(arr.length===3&&allNums&&(!type||type==="vec3")){this._amgObject.setVec3(key,toVec3(arr[0],arr[1],arr[2]));return}if(arr.length===4&&allNums&&(!type||type==="vec4")){this._amgObject.setVec4(key,toVec4(arr[0],arr[1],arr[2],arr[3]));return}}const setVec2Array=list=>{const vecs=new effect.Amaz.Vec2Vector;if(numbersOnly(list)){if(list.length%2!==0){console.warn(`Expected vec2[] for ${key}, got length ${list.length}`)}for(let i=0;i<list.length;i+=2){const x=list[i];const y=list[i+1]!==undefined?list[i+1]:0;vecs.pushBack(toVec2(x,y))}}else{for(const item of list){if(this._looksLikeVector(item,["x","y"])){vecs.pushBack(toVec2(item.x,item.y))}else if(Array.isArray(item)&&item.length>=2){vecs.pushBack(toVec2(item[0],item[1]))}}}this._amgObject.setVec2Vector(key,vecs)};const setVec3Array=list=>{const vecs=new effect.Amaz.Vec3Vector;if(numbersOnly(list)){if(list.length%3!==0){console.warn(`Expected vec3[] for ${key}, got length ${list.length}`)}for(let i=0;i<list.length;i+=3){vecs.pushBack(toVec3(list[i],list[i+1]??0,list[i+2]??0))}}else{for(const item of list){if(item instanceof Color){vecs.pushBack(toVec3(item.r,item.g,item.b))}else if(this._looksLikeVector(item,["x","y","z"])){vecs.pushBack(toVec3(item.x,item.y,item.z))}else if(Array.isArray(item)&&item.length>=3){vecs.pushBack(toVec3(item[0],item[1],item[2]))}}}this._amgObject.setVec3Vector(key,vecs)};const setVec4Array=list=>{const vecs=new effect.Amaz.Vec4Vector;if(numbersOnly(list)){if(list.length%4!==0){console.warn(`Expected vec4[] for ${key}, got length ${list.length}`)}for(let i=0;i<list.length;i+=4){vecs.pushBack(toVec4(list[i],list[i+1]??0,list[i+2]??0,list[i+3]??0))}}else{for(const item of list){if(this._looksLikeVector(item,["x","y","z","w"])){vecs.pushBack(toVec4(item.x,item.y,item.z,item.w))}else if(Array.isArray(item)&&item.length>=4){vecs.pushBack(toVec4(item[0],item[1],item[2],item[3]))}}}this._amgObject.setVec4Vector(key,vecs)};const setFloatArray=list=>{const floats=new effect.Amaz.FloatVector;for(const num of list){if(typeof num==="number"){floats.pushBack(num)}}this._amgObject.setFloatVector(key,floats)};if(type==="vec2[]"){setVec2Array(arr);return}if(type==="vec3[]"){setVec3Array(arr);return}if(type==="vec4[]"){setVec4Array(arr);return}if(type==="float[]"){setFloatArray(arr);return}console.warn(`Unsupported array uniform type for ${key}:`,type||typeof convertedValue);return}console.warn(`Unsupported uniform type for ${key}:`,convertedValue)}catch(error){console.error(`Failed to sync uniform ${key} to AMG:`,error)}}get uniforms(){return this._uniforms}set uniforms(newUniforms){this._originalUniforms=newUniforms||{};this._uniforms=this._createUniformsProxy(this._originalUniforms);this._hookUniforms(this._originalUniforms);for(const[key,uniform]of Object.entries(this._originalUniforms)){if(uniform&&"value"in uniform){this._syncUniformToAMG(key,uniform.value)}}}clone(){const clonedUniforms=this._cloneUniforms(this._originalUniforms);return new ShaderMaterial({uniforms:clonedUniforms,vertexShader:this.originalVertexShader,fragmentShader:this.originalFragmentShader,transparent:this.transparent,blending:this.blending,depthTest:this.depthTest,depthWrite:this.depthWrite,opacity:this.opacity})}dispose(){this._amgObject=null;this._originalUniforms=null;this._uniforms=null;this._arrayProxyMap=null;this._originalVertexShader=null;this._originalFragmentShader=null;this.scene=null}}exports.ShaderMaterial=ShaderMaterial;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Shape.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const{Vector2}=require("./Vector2");class Shape{constructor(points){this.type="Shape";this.uuid=generateUUID();this.currentPoint=new Vector2;this.curves=[];this.holes=[];if(points!==undefined){this.moveTo(points[0].x,points[0].y);for(let i=1;i<points.length;i++){this.lineTo(points[i].x,points[i].y)}}}moveTo(x,y){this.currentPoint.set(x,y);return this}lineTo(x,y){const line=new LineCurve(this.currentPoint.clone(),new Vector2(x,y));this.curves.push(line);this.currentPoint.set(x,y);return this}quadraticCurveTo(cpX,cpY,x,y){const curve=new QuadraticBezierCurve(this.currentPoint.clone(),new Vector2(cpX,cpY),new Vector2(x,y));this.curves.push(curve);this.currentPoint.set(x,y);return this}bezierCurveTo(cp1X,cp1Y,cp2X,cp2Y,x,y){const curve=new CubicBezierCurve(this.currentPoint.clone(),new Vector2(cp1X,cp1Y),new Vector2(cp2X,cp2Y),new Vector2(x,y));this.curves.push(curve);this.currentPoint.set(x,y);return this}splineThru(points){const npts=[this.currentPoint.clone()].concat(points);const curve=new SplineCurve(npts);this.curves.push(curve);this.currentPoint.copy(points[points.length-1]);return this}arc(aX,aY,aRadius,aStartAngle,aEndAngle,aClockwise){const x0=this.currentPoint.x;const y0=this.currentPoint.y;this.absarc(aX+x0,aY+y0,aRadius,aStartAngle,aEndAngle,aClockwise);return this}absarc(aX,aY,aRadius,aStartAngle,aEndAngle,aClockwise){this.absellipse(aX,aY,aRadius,aRadius,aStartAngle,aEndAngle,aClockwise,0);return this}ellipse(aX,aY,xRadius,yRadius,aStartAngle,aEndAngle,aClockwise,aRotation){const x0=this.currentPoint.x;const y0=this.currentPoint.y;this.absellipse(aX+x0,aY+y0,xRadius,yRadius,aStartAngle,aEndAngle,aClockwise,aRotation);return this}absellipse(aX,aY,xRadius,yRadius,aStartAngle,aEndAngle,aClockwise,aRotation){const curve=new EllipseCurve(aX,aY,xRadius,yRadius,aStartAngle,aEndAngle,aClockwise,aRotation);if(this.curves.length>0){const firstPoint=curve.getPoint(0);if(!firstPoint.equals(this.currentPoint)){this.lineTo(firstPoint.x,firstPoint.y)}}this.curves.push(curve);const lastPoint=curve.getPoint(1);this.currentPoint.copy(lastPoint);return this}closePath(){if(this.curves.length>0){const firstPoint=this.curves[0].getPoint(0);if(!this.currentPoint.equals(firstPoint)){this.lineTo(firstPoint.x,firstPoint.y)}}return this}getPoints(divisions=12){const points=[];const epsilon=1e-10;for(let i=0;i<this.curves.length;i++){const curve=this.curves[i];const pts=curve.getPoints(divisions);for(let j=0;j<pts.length;j++){const point=pts[j];if(i===0||j>0||(points.length===0||!point.equals(points[points.length-1],epsilon))){points.push(point)}}}return points}extractPoints(divisions){return{shape:this.getPoints(divisions),holes:this.holes.map(hole=>hole.getPoints(divisions))}}translate(x,y){for(let i=0;i<this.curves.length;i++){this.curves[i].translate(x,y)}return this}scale(x,y){for(let i=0;i<this.curves.length;i++){this.curves[i].scale(x,y)}return this}rotate(angle){const cos=Math.cos(angle);const sin=Math.sin(angle);for(let i=0;i<this.curves.length;i++){this.curves[i].rotate(cos,sin)}return this}getBounds(){const points=this.getPoints();let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;i<points.length;i++){const p=points[i];if(p.x<minX)minX=p.x;if(p.x>maxX)maxX=p.x;if(p.y<minY)minY=p.y;if(p.y>maxY)maxY=p.y}return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}getLengths(divisions=40){if(!this.cacheLengths||this.cacheDivisions!==divisions){const lengths=[];let sum=0;for(let i=0;i<this.curves.length;i++){const curve=this.curves[i];if(curve&&typeof curve.getPoint==="function"){let last=curve.getPoint(0);for(let j=1;j<=divisions;j++){const current=curve.getPoint(j/divisions);const dx=current.x-last.x;const dy=current.y-last.y;sum+=Math.sqrt(dx*dx+dy*dy);lengths.push(sum);last=current}}}this.cacheLengths=lengths;this.cacheDivisions=divisions}return this.cacheLengths}getLength(){const lengths=this.getLengths();return lengths.length>0?lengths[lengths.length-1]:0}getPointAt(u){const t=this.getUtoTmapping(u);return this.getPoint(t)}getUtoTmapping(u){const divisions=this.cacheDivisions||40;const lengths=this.getLengths(divisions);if(u===0)return 0;if(u===1)return 1;const targetLength=u*lengths[lengths.length-1];let low=0;let high=lengths.length-1;let comparison;while(low<=high){const i=Math.floor(low+(high-low)/2);comparison=lengths[i]-targetLength;if(comparison<0){low=i+1}else if(comparison>0){high=i-1}else{high=i;break}}let i=high;if(i<0)i=0;if(i>=lengths.length)i=lengths.length-1;const lengthBefore=i>0?lengths[i-1]:0;const lengthAfter=lengths[i];const segmentLength=lengthAfter-lengthBefore;const segmentFraction=segmentLength===0?0:(targetLength-lengthBefore)/segmentLength;const t=(i+segmentFraction)/(this.curves.length*divisions);return t}getPoint(t){const divisions=this.cacheDivisions||40;const d=t*this.curves.length*divisions;const segmentIndex=Math.floor(d);const segmentT=d-segmentIndex;const curveIndex=Math.floor(segmentIndex/divisions);const divisionIndex=segmentIndex%divisions;const curveT=(divisionIndex+segmentT)/divisions;if(curveIndex<0){return this.curves[0].getPoint(0)}if(curveIndex>=this.curves.length){return this.curves[this.curves.length-1].getPoint(1)}return this.curves[curveIndex].getPoint(curveT)}getSpacedPoints(divisions=5){const points=[];if(this.curves.length===0){return points}for(let i=0;i<=divisions;i++){points.push(this.getPointAt(i/divisions))}return points}dispose(){if(this.curves){for(let i=0;i<this.curves.length;i++){if(this.curves[i]&&typeof this.curves[i].dispose==="function"){this.curves[i].dispose()}this.curves[i]=null}this.curves.length=0;this.curves=null}if(this.holes){for(let i=0;i<this.holes.length;i++){if(this.holes[i]&&typeof this.holes[i].dispose==="function"){this.holes[i].dispose()}this.holes[i]=null}this.holes.length=0;this.holes=null}if(this.cacheLengths){this.cacheLengths.length=0;this.cacheLengths=null}this.cacheDivisions=null;this.currentPoint=null;this.type=null;this.uuid=null}}class LineCurve{constructor(v1,v2){this.v1=v1;this.v2=v2}getPoint(t){const x=this.v1.x+t*(this.v2.x-this.v1.x);const y=this.v1.y+t*(this.v2.y-this.v1.y);return new Vector2(x,y)}getPoints(divisions=1){const points=[];for(let i=0;i<=divisions;i++){points.push(this.getPoint(i/divisions))}return points}translate(x,y){this.v1.x+=x;this.v1.y+=y;this.v2.x+=x;this.v2.y+=y}scale(x,y){this.v1.x*=x;this.v1.y*=y;this.v2.x*=x;this.v2.y*=y}rotate(cos,sin){let x=this.v1.x,y=this.v1.y;this.v1.x=x*cos-y*sin;this.v1.y=x*sin+y*cos;x=this.v2.x;y=this.v2.y;this.v2.x=x*cos-y*sin;this.v2.y=x*sin+y*cos}getLength(){const dx=this.v2.x-this.v1.x;const dy=this.v2.y-this.v1.y;return Math.sqrt(dx*dx+dy*dy)}}class QuadraticBezierCurve{constructor(v0,v1,v2){this.v0=v0;this.v1=v1;this.v2=v2}getPoint(t){const u=1-t;const tt=t*t;const uu=u*u;const ut2=2*u*t;const x=uu*this.v0.x+ut2*this.v1.x+tt*this.v2.x;const y=uu*this.v0.y+ut2*this.v1.y+tt*this.v2.y;return new Vector2(x,y)}getPoints(divisions=12){const points=[];for(let i=0;i<=divisions;i++){points.push(this.getPoint(i/divisions))}return points}translate(x,y){this.v0.x+=x;this.v0.y+=y;this.v1.x+=x;this.v1.y+=y;this.v2.x+=x;this.v2.y+=y}scale(x,y){this.v0.x*=x;this.v0.y*=y;this.v1.x*=x;this.v1.y*=y;this.v2.x*=x;this.v2.y*=y}rotate(cos,sin){let x=this.v0.x,y=this.v0.y;this.v0.x=x*cos-y*sin;this.v0.y=x*sin+y*cos;x=this.v1.x;y=this.v1.y;this.v1.x=x*cos-y*sin;this.v1.y=x*sin+y*cos;x=this.v2.x;y=this.v2.y;this.v2.x=x*cos-y*sin;this.v2.y=x*sin+y*cos}getLength(){const divisions=200;let length=0;let lastPoint=this.getPoint(0);for(let i=1;i<=divisions;i++){const point=this.getPoint(i/divisions);const dx=point.x-lastPoint.x;const dy=point.y-lastPoint.y;length+=Math.sqrt(dx*dx+dy*dy);lastPoint=point}return length}}class CubicBezierCurve{constructor(v0,v1,v2,v3){this.v0=v0;this.v1=v1;this.v2=v2;this.v3=v3}getPoint(t){const u=1-t;const tt=t*t;const uu=u*u;const uuu=uu*u;const ttt=tt*t;const x=uuu*this.v0.x+3*uu*t*this.v1.x+3*u*tt*this.v2.x+ttt*this.v3.x;const y=uuu*this.v0.y+3*uu*t*this.v1.y+3*u*tt*this.v2.y+ttt*this.v3.y;return new Vector2(x,y)}getPoints(divisions=12){const points=[];for(let i=0;i<=divisions;i++){points.push(this.getPoint(i/divisions))}return points}translate(x,y){this.v0.x+=x;this.v0.y+=y;this.v1.x+=x;this.v1.y+=y;this.v2.x+=x;this.v2.y+=y;this.v3.x+=x;this.v3.y+=y}scale(x,y){this.v0.x*=x;this.v0.y*=y;this.v1.x*=x;this.v1.y*=y;this.v2.x*=x;this.v2.y*=y;this.v3.x*=x;this.v3.y*=y}rotate(cos,sin){let x=this.v0.x,y=this.v0.y;this.v0.x=x*cos-y*sin;this.v0.y=x*sin+y*cos;x=this.v1.x;y=this.v1.y;this.v1.x=x*cos-y*sin;this.v1.y=x*sin+y*cos;x=this.v2.x;y=this.v2.y;this.v2.x=x*cos-y*sin;this.v2.y=x*sin+y*cos;x=this.v3.x;y=this.v3.y;this.v3.x=x*cos-y*sin;this.v3.y=x*sin+y*cos}getLength(){const divisions=200;let length=0;let lastPoint=this.getPoint(0);for(let i=1;i<=divisions;i++){const point=this.getPoint(i/divisions);const dx=point.x-lastPoint.x;const dy=point.y-lastPoint.y;length+=Math.sqrt(dx*dx+dy*dy);lastPoint=point}return length}}class SplineCurve{constructor(points){this.points=points}getPoint(t){const points=this.points;const point=(points.length-1)*t;const intPoint=Math.floor(point);const weight=point-intPoint;const p0=points[intPoint===0?intPoint:intPoint-1];const p1=points[intPoint];const p2=points[intPoint>points.length-2?points.length-1:intPoint+1];const p3=points[intPoint>points.length-3?points.length-1:intPoint+2];const x=catmullRom(weight,p0.x,p1.x,p2.x,p3.x);const y=catmullRom(weight,p0.y,p1.y,p2.y,p3.y);return new Vector2(x,y)}getPoints(divisions=12){const points=[];for(let i=0;i<=divisions;i++){points.push(this.getPoint(i/divisions))}return points}translate(x,y){for(let i=0;i<this.points.length;i++){this.points[i].x+=x;this.points[i].y+=y}}scale(x,y){for(let i=0;i<this.points.length;i++){this.points[i].x*=x;this.points[i].y*=y}}rotate(cos,sin){for(let i=0;i<this.points.length;i++){const x=this.points[i].x;const y=this.points[i].y;this.points[i].x=x*cos-y*sin;this.points[i].y=x*sin+y*cos}}getLength(){const divisions=200;let length=0;let lastPoint=this.getPoint(0);for(let i=1;i<=divisions;i++){const point=this.getPoint(i/divisions);const dx=point.x-lastPoint.x;const dy=point.y-lastPoint.y;length+=Math.sqrt(dx*dx+dy*dy);lastPoint=point}return length}}class EllipseCurve{constructor(aX,aY,xRadius,yRadius,aStartAngle,aEndAngle,aClockwise,aRotation){this.aX=aX;this.aY=aY;this.xRadius=xRadius;this.yRadius=yRadius;this.aStartAngle=aStartAngle;this.aEndAngle=aEndAngle;this.aClockwise=aClockwise!==undefined?aClockwise:false;this.aRotation=aRotation!==undefined?aRotation:0}getPoint(t){const twoPi=Math.PI*2;let deltaAngle=this.aEndAngle-this.aStartAngle;const samePoints=Math.abs(deltaAngle)<Number.EPSILON;while(deltaAngle<0)deltaAngle+=twoPi;while(deltaAngle>twoPi)deltaAngle-=twoPi;if(deltaAngle<Number.EPSILON){if(samePoints){deltaAngle=0}else{deltaAngle=twoPi}}if(this.aClockwise===true&&!samePoints){if(deltaAngle===twoPi){deltaAngle=-twoPi}else{deltaAngle=deltaAngle-twoPi}}const angle=this.aStartAngle+t*deltaAngle;let x=this.aX+this.xRadius*Math.cos(angle);let y=this.aY+this.yRadius*Math.sin(angle);if(this.aRotation!==0){const cos=Math.cos(this.aRotation);const sin=Math.sin(this.aRotation);const tx=x-this.aX;const ty=y-this.aY;x=tx*cos-ty*sin+this.aX;y=tx*sin+ty*cos+this.aY}return new Vector2(x,y)}getPoints(divisions=12){const points=[];for(let i=0;i<=divisions;i++){points.push(this.getPoint(i/divisions))}return points}translate(x,y){this.aX+=x;this.aY+=y}scale(x,y){this.xRadius*=x;this.yRadius*=y;this.aX*=x;this.aY*=y}rotate(cos,sin){const x=this.aX;const y=this.aY;this.aX=x*cos-y*sin;this.aY=x*sin+y*cos;this.aRotation+=Math.atan2(sin,cos)}getLength(){const divisions=200;let length=0;let lastPoint=this.getPoint(0);for(let i=1;i<=divisions;i++){const point=this.getPoint(i/divisions);const dx=point.x-lastPoint.x;const dy=point.y-lastPoint.y;length+=Math.sqrt(dx*dx+dy*dy);lastPoint=point}return length}}function catmullRom(t,p0,p1,p2,p3){const v0=(p2-p0)*.5;const v1=(p3-p1)*.5;const t2=t*t;const t3=t*t2;return(2*p1-2*p2+v0+v1)*t3+(-3*p1+3*p2-2*v0-v1)*t2+v0*t+p1}function generateUUID(){const chars="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");const uuid=new Array(36);let rnd=0;for(let i=0;i<36;i++){if(i===8||i===13||i===18||i===23){uuid[i]="-"}else if(i===14){uuid[i]="4"}else{if(rnd<=2)rnd=33554432+Math.random()*16777216|0;const r=rnd&15;rnd=rnd>>4;uuid[i]=chars[i===19?r&3|8:r]}}return uuid.join("")}exports.Shape=Shape;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");const{earcut}=require("./Earcut");const{Vector2}=require("./Vector2");const{Vector3}=require("./Vector3");const{Box3}=require("./Box3");class ShapeGeometry extends BufferGeometry{constructor(shapes,curveSegments=12){super();this.type="ShapeGeometry";this.parameters={shapes:shapes,curveSegments:curveSegments};const shapesArray=Array.isArray(shapes)?shapes:[shapes];const vertices=[];const indices=[];const uvs=[];const groups=[];let groupStart=0;let groupCount=0;for(let i=0;i<shapesArray.length;i++){const shape=shapesArray[i];const{shape:shapePoints,holes:holePoints}=shape.extractPoints(curveSegments);const triangulationData=prepareTriangulationData(shapePoints,holePoints);if(triangulationData){const{flatVertices,holeIndices,vertexCount}=triangulationData;const triangleIndices=earcut(flatVertices,holeIndices,2);if(triangleIndices&&triangleIndices.length>0){const bounds=calculateBounds(flatVertices);const vertexOffset=vertices.length/3;for(let j=0;j<vertexCount;j++){const x=flatVertices[j*2];const y=flatVertices[j*2+1];vertices.push(x,y,0);const u=(x-bounds.minX)/(bounds.maxX-bounds.minX);const v=(y-bounds.minY)/(bounds.maxY-bounds.minY);uvs.push(u,v)}for(let j=0;j<triangleIndices.length;j++){indices.push(triangleIndices[j]+vertexOffset)}groupCount=triangleIndices.length;groups.push({start:groupStart,count:groupCount,materialIndex:i});groupStart+=groupCount}}}if(vertices.length>0){this.setAttribute("position",new BufferAttribute(new Float32Array(vertices),3));this.setAttribute("uv",new BufferAttribute(new Float32Array(uvs),2));if(indices.length>0){this.setIndex(indices)}this.updateAMGObject(vertices,indices,uvs)}this.groups=groups}updateAMGObject(vertices,indices,uvs){if(!this._amgObject||!this._amgObject.submeshes)return;try{const submesh=this._amgObject.submeshes.get(0);if(!submesh)return;submesh.primitive=effect.Amaz.Primitive.TRIANGLES;const vertexCount=vertices.length/3;const vertexArray=new effect.Amaz.Vec3Vector;for(let i=0;i<vertexCount;i++){const v=new effect.Amaz.Vector3f(vertices[i*3],vertices[i*3+1],vertices[i*3+2]);vertexArray.pushBack(v)}const buffer=new effect.Amaz.FloatVector;for(let i=0;i<vertexCount;i++){buffer.pushBack(vertices[i*3]);buffer.pushBack(vertices[i*3+1]);buffer.pushBack(vertices[i*3+2])}this._amgObject.setAttributeData(effect.Amaz.VertexAttribType.POSITION,buffer,0,vertexCount);const uvArray=new effect.Amaz.Vec2Vector;for(let i=0;i<vertexCount;i++){const uv=new effect.Amaz.Vector2f(uvs[i*2],uvs[i*2+1]);uvArray.pushBack(uv)}this._amgObject.setUvArray(0,uvArray);if(indices.length>0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;i<indices.length;i++){indexArray.pushBack(indices[i])}submesh.indices16=indexArray;submesh.indicesCount=indices.length;submesh.primitive=effect.Amaz.Primitive.TRIANGLES}}catch(e){console.warn("ShapeGeometry: 更新 AMG 对象失败",e)}}addShape(shape,curveSegments=1){console.warn("ShapeGeometry.addShape: 暂未实现动态添加形状功能")}center(){const positionAttribute=this.attributes.position;if(!positionAttribute)return this;const positions=positionAttribute.array;let minX=Infinity,minY=Infinity,minZ=Infinity;let maxX=-Infinity,maxY=-Infinity,maxZ=-Infinity;for(let i=0;i<positions.length;i+=3){const x=positions[i];const y=positions[i+1];const z=positions[i+2];if(x<minX)minX=x;if(x>maxX)maxX=x;if(y<minY)minY=y;if(y>maxY)maxY=y;if(z<minZ)minZ=z;if(z>maxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;i<positions.length;i+=3){positions[i]-=centerX;positions[i+1]-=centerY;positions[i+2]-=centerZ}if(this._amgObject){const vertexCount=positions.length/3;const buffer=new effect.Amaz.FloatVector;for(let i=0;i<vertexCount;i++){buffer.pushBack(positions[i*3]);buffer.pushBack(positions[i*3+1]);buffer.pushBack(positions[i*3+2])}this._amgObject.setAttributeData(effect.Amaz.VertexAttribType.POSITION,buffer,0,vertexCount)}return this}computeBoundingBox(){const positionAttribute=this.attributes.position;if(!positionAttribute){this.boundingBox=new Box3(new Vector3(0,0,0),new Vector3(0,0,0));return}const positions=positionAttribute.array;let minX=Infinity,minY=Infinity,minZ=Infinity;let maxX=-Infinity,maxY=-Infinity,maxZ=-Infinity;for(let i=0;i<positions.length;i+=3){const x=positions[i];const y=positions[i+1];const z=positions[i+2];if(x<minX)minX=x;if(x>maxX)maxX=x;if(y<minY)minY=y;if(y>maxY)maxY=y;if(z<minZ)minZ=z;if(z>maxZ)maxZ=z}this.boundingBox=new Box3(new Vector3(minX,minY,minZ),new Vector3(maxX,maxY,maxZ))}computeBoundingSphere(){const positionAttribute=this.attributes.position;if(!positionAttribute){this.boundingSphere={center:{x:0,y:0,z:0},radius:0};return}const positions=positionAttribute.array;let minX=Infinity,minY=Infinity,minZ=Infinity;let maxX=-Infinity,maxY=-Infinity,maxZ=-Infinity;for(let i=0;i<positions.length;i+=3){const x=positions[i];const y=positions[i+1];const z=positions[i+2];if(x<minX)minX=x;if(x>maxX)maxX=x;if(y<minY)minY=y;if(y>maxY)maxY=y;if(z<minZ)minZ=z;if(z>maxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;i<positions.length;i+=3){const dx=positions[i]-centerX;const dy=positions[i+1]-centerY;const dz=positions[i+2]-centerZ;const distSq=dx*dx+dy*dy+dz*dz;if(distSq>maxRadiusSq)maxRadiusSq=distSq}this.boundingSphere={center:{x:centerX,y:centerY,z:centerZ},radius:Math.sqrt(maxRadiusSq)}}dispose(){if(this.groups){this.groups.length=0;this.groups=null}this.parameters=null;super.dispose()}}function prepareTriangulationData(shapePoints,holePoints){if(!shapePoints||shapePoints.length<3){console.warn("ShapeGeometry: 形状点数量不足");return null}const flatVertices=[];const holeIndices=[];for(let i=0;i<shapePoints.length;i++){flatVertices.push(shapePoints[i].x,shapePoints[i].y)}let vertexCount=shapePoints.length;if(holePoints&&holePoints.length>0){for(let i=0;i<holePoints.length;i++){const hole=holePoints[i];if(hole&&hole.length>0){holeIndices.push(vertexCount);for(let j=0;j<hole.length;j++){flatVertices.push(hole[j].x,hole[j].y);vertexCount++}}}}return{flatVertices:flatVertices,holeIndices:holeIndices.length>0?holeIndices:null,vertexCount:vertexCount}}function calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;i<vertices.length;i+=2){const x=vertices[i];const y=vertices[i+1];if(x<minX)minX=x;if(x>maxX)maxX=x;if(y<minY)minY=y;if(y>maxY)maxY=y}if(maxX===minX)maxX=minX+1;if(maxY===minY)maxY=minY+1;return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}exports.ShapeGeometry=ShapeGeometry;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");class SphereGeometry extends BufferGeometry{constructor(radius=1,widthSegments=8,heightSegments=6){super();const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Sphere.mesh")}this.width=radius;this.height=radius;this.depth=radius;const vertexCount=(widthSegments+1)*(heightSegments+1);const vertices=new Float32Array(vertexCount*3);const uvs=new Float32Array(vertexCount*2);this.initAttribute("position",new BufferAttribute(vertices,3));this.initAttribute("uv",new BufferAttribute(uvs,2));this.scale(this.width,this.height,this.depth)}}exports.SphereGeometry=SphereGeometry;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Texture.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const{getCurrentScene}=require("./runtime");const Vector2=require("./Vector2").Vector2;const __THREE_CONSTS=require("./Constants");class Texture{constructor(){this._amgObject=null;this._materials=[];this.repeat=new Vector2(1,1);this.offset=new Vector2(0,0);this.center=new Vector2(.5,.5);this.rotation=0;this._setupListeners();this._wrapS=__THREE_CONSTS.ClampToEdgeWrapping;Object.defineProperty(this,"wrapS",{get:()=>this._wrapS,set:value=>{this._wrapS=value;if(this._amgObject!==undefined){if(value==__THREE_CONSTS.RepeatWrapping){this._amgObject.wrapModeS=Amaz.WrapMode.REPEAT}else if(value==__THREE_CONSTS.ClampToEdgeWrapping){this._amgObject.wrapModeS=Amaz.WrapMode.CLAMP}else if(value==__THREE_CONSTS.MirroredRepeatWrapping){this._amgObject.wrapModeS=Amaz.WrapMode.Mirror}}},enumerable:true,configurable:true});this._wrapT=__THREE_CONSTS.ClampToEdgeWrapping;Object.defineProperty(this,"wrapT",{get:()=>this._wrapT,set:value=>{this._wrapT=value;if(this._amgObject!==undefined){if(value==__THREE_CONSTS.RepeatWrapping){this._amgObject.wrapModeT=Amaz.WrapMode.REPEAT}else if(value==__THREE_CONSTS.ClampToEdgeWrapping){this._amgObject.wrapModeT=Amaz.WrapMode.CLAMP}else if(value==__THREE_CONSTS.MirroredRepeatWrapping){this._amgObject.wrapModeT=Amaz.WrapMode.Mirror}}},enumerable:true,configurable:true})}setImage(image){this._amgObject=image;this.image=image;this.wrapS=this._wrapS;this.wrapT=this._wrapT}clone(){const cloned=new Texture;cloned._amgObject=this._amgObject;cloned.repeat.set(this.repeat.x,this.repeat.y);cloned.offset.set(this.offset.x,this.offset.y);return cloned}dispose(){this._amgObject=null;this.image=null;this._materials=[]}_addMaterial(material){if(!this._materials.includes(material))this._materials.push(material)}_removeMaterial(material){const i=this._materials.indexOf(material);if(i>-1)this._materials.splice(i,1)}_setupListeners(){this.repeat=new Proxy(this.repeat,{set:(target,property,value)=>{target[property]=value;this._notifyMaterials();return true}});this.offset=new Proxy(this.offset,{set:(target,property,value)=>{target[property]=value;this._notifyMaterials();return true}});const originalRepeatSet=this.repeat.set.bind(this.repeat);this.repeat.set=(x,y)=>{const r=originalRepeatSet(x,y);this._notifyMaterials();return r};const originalOffsetSet=this.offset.set.bind(this.offset);this.offset.set=(x,y)=>{const r=originalOffsetSet(x,y);this._notifyMaterials();return r}}_notifyMaterials(){this._materials.forEach(m=>{if(m._updateTextureParams)m._updateTextureParams()})}}class VideoTexture extends Texture{constructor(path,loop,playbackRate){super();this.path=path;this.loop=loop;this.playbackRate=playbackRate}clone(){const cloned=new VideoTexture(this.path,this.loop,this.playbackRate);cloned._amgObject=this._amgObject;cloned.repeat.set(this.repeat.x,this.repeat.y);cloned.offset.set(this.offset.x,this.offset.y);return cloned}load(){const amgScene=getCurrentScene()._amgScene;this._amgEntity=new Amaz.Entity;this._amgEntity.name="VideoTextureEntity";this._amgEntity.scene=amgScene;this._transform=this._amgEntity.addComponent("Transform");this._amgVideoAnimSeq=this._amgEntity.addComponent("VideoAnimSeq");this._amgVideoAnimSeq.videoFilename=this.path;this._amgVideoAnimSeq.texName="_MainTex";this._amgVideoAnimSeq.playmode=this.loop?Amaz.PlayMode.loop:Amaz.PlayMode.once;this._amgVideoAnimSeq.speed=this.playbackRate;this._amgVideoAnimSeq.autoplay=true;this._amgVideoAnimSeq.enableAlphaBlend=false;this._amgVideoAnimSeq.enableFixedSeekMode=true;this._amgSprite2DRenderer=this._amgEntity.addComponent("Sprite2DRenderer");this._amgSprite2DRenderer.enabled=false;amgScene.addEntity(this._amgEntity)}dispose(){this._amgEntity=null;this._amgVideoAnimSeq=null;this._amgSprite2DRenderer=null}}class TextureLoader{constructor(){}load(url,onLoad,onProgress,onError){const texture=new Texture;const assetMgr=getCurrentScene()._amgScene.assetMgr;texture.setImage(assetMgr.SyncLoad(url));if(onLoad!==undefined)onLoad(texture);return texture}}exports.Texture=Texture;exports.VideoTexture=VideoTexture;exports.TextureLoader=TextureLoader;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Vector2.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;class Vector2{constructor(x=0,y=0){this.x=x;this.y=y}set(x,y){this.x=x;this.y=y;return this}toAMGVector2(){return new Amaz.Vector2f(this.x,this.y)}copy(v){this.x=v.x;this.y=v.y;return this}lerpVectors(vec1,vec2,t){this.x=vec1.x+(vec2.x-vec1.x)*t;this.y=vec1.y+(vec2.y-vec1.y)*t;return this}clone(){return new Vector2(this.x,this.y)}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}normalize(){const length=this.length();if(length>0){this.x/=length;this.y/=length}return this}subScalar(s){this.x-=s;this.y-=s;return this}addScalar(s){this.x+=s;this.y+=s;return this}multiplyScalar(s){this.x*=s;this.y*=s;return this}divideScalar(s){this.x/=s;this.y/=s;return this}distanceTo(v){const dx=this.x-v.x;const dy=this.y-v.y;return Math.sqrt(dx*dx+dy*dy)}equals(v,epsilon=Number.EPSILON){return Math.abs(this.x-v.x)<epsilon&&Math.abs(this.y-v.y)<epsilon}}exports.Vector2=Vector2;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Vector3.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const Quaternion=require("./Quaternion").Quaternion;class Vector3{constructor(x=0,y=0,z=0){this.x=x;this.y=y;this.z=z}set(x,y,z){this.x=x;this.y=y;this.z=z;return this}clone(){return new Vector3(this.x,this.y,this.z)}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}addScaledVector(v,s){this.x+=v.x*s;this.y+=v.y*s;this.z+=v.z*s;return this}divideScalar(scalar){this.x/=scalar;this.y/=scalar;this.z/=scalar;return this}normalize(){const length=this.length();if(length>0){this.x/=length;this.y/=length;this.z/=length}return this}multiplyScalar(scalar){this.x*=scalar;this.y*=scalar;this.z*=scalar;return this}add(v){this.x+=v.x;this.y+=v.y;this.z+=v.z;return this}dot(v){return this.x*v.x+this.y*v.y+this.z*v.z}cross(v,target){const ax=this.x,ay=this.y,az=this.z;const bx=v.x,by=v.y,bz=v.z;if(target){target.x=ay*bz-az*by;target.y=az*bx-ax*bz;target.z=ax*by-ay*bx;return target}else{this.x=ay*bz-az*by;this.y=az*bx-ax*bz;this.z=ax*by-ay*bx;return this}}sub(v){this.x-=v.x;this.y-=v.y;this.z-=v.z;return this}copy(v){this.x=v.x;this.y=v.y;this.z=v.z;return this}lerp(v,t){this.x=this.x+(v.x-this.x)*t;this.y=this.y+(v.y-this.y)*t;this.z=this.z+(v.z-this.z)*t;return this}lerpVectors(vec1,vec2,t){this.x=vec1.x+(vec2.x-vec1.x)*t;this.y=vec1.y+(vec2.y-vec1.y)*t;this.z=vec1.z+(vec2.z-vec1.z)*t;return this}applyQuaternion(quat){const qx=quat.x;const qy=quat.y;const qz=quat.z;const qw=quat.w;const vx=this.x;const vy=this.y;const vz=this.z;const x=(qw*qw+qx*qx-qy*qy-qz*qz)*vx+2*(qx*qy-qw*qz)*vy+2*(qx*qz+qw*qy)*vz;const y=2*(qx*qy+qw*qz)*vx+(qw*qw-qx*qx+qy*qy-qz*qz)*vy+2*(qy*qz-qw*qx)*vz;const z=2*(qx*qz-qw*qy)*vx+2*(qy*qz+qw*qx)*vy+(qw*qw-qx*qx-qy*qy+qz*qz)*vz;this.x=x;this.y=y;this.z=z;return this}applyMatrix4(matrix){const e=matrix.elements;const x=this.x,y=this.y,z=this.z;const w=e[3]*x+e[7]*y+e[11]*z+e[15];this.x=e[0]*x+e[4]*y+e[8]*z+e[12];this.y=e[1]*x+e[5]*y+e[9]*z+e[13];this.z=e[2]*x+e[6]*y+e[10]*z+e[14];if(w!==1&&w!==0){this.x/=w;this.y/=w;this.z/=w}return this}applyAxisAngle(vector,angle){const axis=vector.clone().normalize();const q=(new Quaternion).setFromAxisAngle(axis,angle);this.applyQuaternion(q);return this}applyEuler(euler){const q=(new Quaternion).setFromEuler(euler);this.applyQuaternion(q);return this}addVectors(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this}subVectors(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this}subScalar(s){this.x-=s;this.y-=s;this.z-=s;return this}addScalar(s){this.x+=s;this.y+=s;this.z+=s;return this}toAMGVector3(){return new Amaz.Vector3f(this.x,this.y,this.z)}multiplyScalar(s){this.x*=s;this.y*=s;this.z*=s;return this}divideScalar(s){this.x/=s;this.y/=s;this.z/=s;return this}min(v){this.x=Math.min(this.x,v.x);this.y=Math.min(this.y,v.y);this.z=Math.min(this.z,v.z);return this}max(v){this.x=Math.max(this.x,v.x);this.y=Math.max(this.y,v.y);this.z=Math.max(this.z,v.z);return this}distanceTo(v){const dx=this.x-v.x;const dy=this.y-v.y;const dz=this.z-v.z;return Math.sqrt(dx*dx+dy*dy+dz*dz)}equals(v,epsilon=Number.EPSILON){return Math.abs(this.x-v.x)<epsilon&&Math.abs(this.y-v.y)<epsilon&&Math.abs(this.z-v.z)<epsilon}}exports.Vector3=Vector3;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Vector4.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;class Vector4{constructor(x=0,y=0,z=0,w=0){this.x=x;this.y=y;this.z=z;this.w=w}set(x,y,z,w){this.x=x;this.y=y;this.z=z;this.w=w;return this}clone(){return new Vector4(this.x,this.y,this.z,this.w)}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}normalize(){const length=this.length();if(length>0){this.x/=length;this.y/=length;this.z/=length;this.w/=length}return this}multiplyScalar(scalar){this.x*=scalar;this.y*=scalar;this.z*=scalar;this.w*=scalar;return this}add(v){this.x+=v.x;this.y+=v.y;this.z+=v.z;this.w+=v.w;return this}dot(v){return this.x*v.x+this.y*v.y+this.z*v.z+this.w*v.w}sub(v){this.x-=v.x;this.y-=v.y;this.z-=v.z;this.w-=v.w;return this}copy(v){this.x=v.x;this.y=v.y;this.z=v.z;this.w=v.w;return this}subScalar(s){this.x-=s;this.y-=s;this.z-=s;this.w-=s;return this}addScalar(s){this.x+=s;this.y+=s;this.z+=s;this.w+=s;return this}multiplyScalar(s){this.x*=s;this.y*=s;this.z*=s;this.w*=s;return this}divideScalar(s){this.x/=s;this.y/=s;this.z/=s;this.w/=s;return this}equals(v,epsilon=Number.EPSILON){return Math.abs(this.x-v.x)<epsilon&&Math.abs(this.y-v.y)<epsilon&&Math.abs(this.z-v.z)<epsilon&&Math.abs(this.w-v.w)<epsilon}toAMGVector4(){return new Amaz.Vector4f(this.x,this.y,this.z,this.w)}}exports.Vector4=Vector4;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/WebGLRenderer.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const Color=require("./Color").Color;class WebGLRenderer{constructor(parameters={}){this.width=parameters.width||800;this.height=parameters.height||600;this.antialias=parameters.antialias||false;this.pixelRatio=1;this.domElement=document.createElement("div");this.domElement.style.width=this.width+"px";this.domElement.style.height=this.height+"px";console.log("AMG renderer initialized, size:",this.width,"x",this.height)}setAnimationLoop(callback){console.log("WebGLRenderer.setAnimationLoop: empty implementation")}setSize(width,height){this.width=width;this.height=height;this.domElement.style.width=width+"px";this.domElement.style.height=height+"px";effect.Amaz.AmazingManager.resize(width,height)}setPixelRatio(ratio){this.pixelRatio=ratio}render(scene,camera){const amgScene=scene._amgScene}setClearColor(color,alpha=1){const amgColor=color instanceof Color?color.toAMGColor():(new Color).setHex(color).toAMGColor();amgColor.w=alpha}dispose(){console.log("WebGLRenderer.dispose: empty implementation")}}exports.WebGLRenderer=WebGLRenderer;
scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/runtime.js ADDED
@@ -0,0 +1 @@
 
 
1
+ let currentScene=null;function getCurrentScene(){if(!currentScene){console.warn("Scene实例尚未创建")}return currentScene}function setCurrentScene(scene){currentScene=scene}function clearCurrentScene(){currentScene=null}exports.getCurrentScene=getCurrentScene;exports.setCurrentScene=setCurrentScene;exports.clearCurrentScene=clearCurrentScene;
scripts/7681304008023215368/AmazingFeature/xshader/Unlit.frag ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ precision highp float;
2
+ uniform sampler2D u_AlbedoTexture;
3
+ uniform vec4 u_AlbedoColor;
4
+ uniform vec2 u_Repeat;
5
+ uniform vec2 u_Offset;
6
+ uniform float u_Translucency;
7
+ uniform float u_Opacity;
8
+ varying vec2 g_vary_uv0;
9
+ void main ()
10
+ {
11
+ vec2 uv_1;
12
+ uv_1.x = g_vary_uv0.x;
13
+ uv_1.y = (g_vary_uv0.y);
14
+ lowp vec4 tmpvar_2;
15
+ tmpvar_2 = texture2D (u_AlbedoTexture, (uv_1 * u_Repeat + u_Offset));
16
+ lowp vec3 tmpvar_3;
17
+ tmpvar_3 = (tmpvar_2.xyz * u_AlbedoColor.xyz);
18
+ lowp float tmpvar_4;
19
+ tmpvar_4 = (tmpvar_2.w * u_Translucency);
20
+ mediump vec4 tmpvar_5;
21
+ tmpvar_5.xyz = tmpvar_3;
22
+ tmpvar_5.w = tmpvar_4;
23
+ gl_FragColor = vec4(tmpvar_5.xyz * u_Opacity, tmpvar_5.w * u_Opacity);
24
+ }
25
+
scripts/7681304008023215368/AmazingFeature/xshader/Unlit.vert ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ precision highp float;
2
+ attribute vec3 attPosition;
3
+ attribute vec2 attTexcoord0;
4
+
5
+ //#define AMAZING_USE_BONES
6
+
7
+ #ifdef AMAZING_USE_BONES
8
+ attribute vec4 attBoneIds;
9
+ attribute vec4 attWeights;
10
+ const int MAX_BONES = 50;
11
+ uniform mat4 u_Palatte[MAX_BONES];
12
+ #endif
13
+
14
+ uniform mat4 u_Model;
15
+ uniform mat4 u_MVP;
16
+ varying vec2 g_vary_uv0;
17
+
18
+
19
+
20
+ void main ()
21
+ {
22
+ vec3 modelPostiton = attPosition;
23
+ vec4 homogeneous_pos = vec4(attPosition, 1.0);
24
+ g_vary_uv0 = attTexcoord0;
25
+
26
+ #ifdef AMAZING_USE_BONES
27
+ mat4 boneTransform = u_Palatte[int(attBoneIds.x)] * attWeights.x;
28
+ boneTransform += u_Palatte[int(attBoneIds.y)] * attWeights.y;
29
+ boneTransform += u_Palatte[int(attBoneIds.z)] * attWeights.z;
30
+ boneTransform += u_Palatte[int(attBoneIds.w)] * attWeights.w;
31
+ gl_Position = u_MVP * boneTransform * homogeneous_pos;
32
+ #else
33
+ gl_Position = u_MVP * homogeneous_pos;
34
+ #endif
35
+ }
scripts/7681304008023215368/AmazingFeature/xshader/noface.frag ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ precision lowp float;
2
+ varying highp vec2 uv0;
3
+ uniform sampler2D u_albedo;
4
+ void main()
5
+ {
6
+ gl_FragColor = texture2D(u_albedo, uv0);
7
+ }
scripts/7681304008023215368/AmazingFeature/xshader/noface.vert ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ precision highp float;
2
+
3
+ attribute vec2 position;
4
+ attribute vec2 texcoord0;
5
+ varying vec2 uv0;
6
+ //uniform mat4 u_MVP;
7
+ void main()
8
+ {
9
+ //gl_Position = u_MVP * position;
10
+ gl_Position = sign(vec4(position.xy, 0.0, 1.0));
11
+ uv0 = texcoord0;
12
+ }
scripts/7681304008023215368/config.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "ae_tool": "AmazingEditor",
3
+ "bALG_BACH_CONFIG": false,
4
+ "effect": {
5
+ "Link": [
6
+ {
7
+ "path": "AmazingFeature/",
8
+ "type": "AmazingFeature",
9
+ "zorder": 8011
10
+ }
11
+ ]
12
+ },
13
+ "name": "AlgorithmGraph_7bdbHcdcscQkbEdcc9cIlcNdvTdtb",
14
+ "version": "13.4.0",
15
+ "item_source": "user_post_pc_lumi_ai"
16
+ }
scripts/7681304008023215368/extra.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "transition": {
3
+ "defaultDura": 2.0,
4
+ "isOverlap": true
5
+ },
6
+ "External_Producer": true,
7
+ "setting": {
8
+ "lumiai_material_properties": [
9
+ {
10
+ "effect_key": "progress",
11
+ "effect_key_cn": "progress",
12
+ "type": "float",
13
+ "default": 0,
14
+ "min": 0,
15
+ "max": 1
16
+ },
17
+ {
18
+ "effect_key": "shutterCount",
19
+ "effect_key_cn": "shutterCount",
20
+ "type": "float",
21
+ "default": 6,
22
+ "min": 3,
23
+ "max": 12
24
+ },
25
+ {
26
+ "effect_key": "feather",
27
+ "effect_key_cn": "feather",
28
+ "type": "float",
29
+ "default": 0.08,
30
+ "min": 0,
31
+ "max": 0.3
32
+ }
33
+ ]
34
+ }
35
+ }
scripts/7681318995261132040/AmazingFeature/content.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "ae_tool" : "AmazingEditor",
3
+ "content" : {},
4
+ "needblend" : false,
5
+ "tag" : "AMG_1515088281693380358513659446614427937212",
6
+ "version" : "1.0"
7
+ }
scripts/7681318995261132040/AmazingFeature/js/JSSys.js ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const effect_api = "undefined" != typeof effect ? effect : "undefined" != typeof tt ? tt : "undefined" != typeof lynx ? lynx : {};
2
+ const Amaz = effect_api.getAmaz();
3
+
4
+ const { ScriptScene } = require('./ThreeJS/scriptScene');
5
+ const THREE = require('./ThreeJS/three-amg-wrapper').THREE;
6
+
7
+ class JSSys {
8
+ constructor() {
9
+ this.name = "JSSys";
10
+ this.comps = {}
11
+ this.compsdirty = true
12
+ }
13
+
14
+ onComponentAdded(comp) {
15
+ // console.log("running:JSSys:onComponentAdded");
16
+ }
17
+ onComponentRemoved(comp) {
18
+ // console.log("running:JSSys:onComponentRemoved");
19
+ }
20
+
21
+ onStart() {
22
+ console.log("running:JSSys:onStart");
23
+
24
+ this.renderTexture = this.scene.assetMgr.SyncLoad('rt/outputTex.rt');
25
+
26
+ // 添加光源到场景
27
+ console.log('JSSys: 创建ScriptScene实例');
28
+ this.scriptScene = new ScriptScene(this.scene);
29
+
30
+ this.input = Amaz.AmazingManager.getSingleton("Input");
31
+ const builtinObject = Amaz.AmazingManager.getSingleton("BuiltinObject");
32
+
33
+ if (builtinObject.getUserTexture("#TransitionInput0") && builtinObject.getUserTexture("#TransitionInput1")) {
34
+ this.scriptScene.texture1 = new THREE.Texture();
35
+ this.scriptScene.texture1.setImage(builtinObject.getUserTexture("#TransitionInput0"));
36
+ this.scriptScene.texture2 = new THREE.Texture();
37
+ this.scriptScene.texture2.setImage(builtinObject.getUserTexture("#TransitionInput1"));
38
+ console.log("JSSys: 获取到纹理");
39
+ }
40
+ else
41
+ {
42
+ this.scriptScene.texture1 = new THREE.Texture();
43
+ this.scriptScene.texture1.setImage(this.scene.assetMgr.SyncLoad('image/Sample1.jpg'));
44
+ this.scriptScene.texture2 = new THREE.Texture();
45
+ this.scriptScene.texture2.setImage(this.scene.assetMgr.SyncLoad('image/Sample2.jpg'));
46
+ console.log("JSSys: 未获取到纹理,使用默认纹理");
47
+ }
48
+
49
+ this.scriptScene.setupScene();
50
+ // 初始化后处理效果
51
+ if (this.scriptScene.initPostProcessing != null) {
52
+ this.scriptScene.initPostProcessing();
53
+ }
54
+ }
55
+
56
+ onUpdate(deltaTime) {
57
+ this.time = this.input.getFrameTimestamp();
58
+ // this.time = this.time % 2;
59
+ // this.time = this.time / 2.0;
60
+ this.scriptScene.seekToTime(this.time * this.scriptScene.Duration);
61
+ // this.scriptScene.updateScene();
62
+ }
63
+ onLateUpdate(deltaTime) {
64
+ // console.log("running:JSSys:onLateUpdate");
65
+ this.scriptScene.scene.seekToTime(this.time * this.scriptScene.Duration);
66
+ }
67
+
68
+ onEvent(event) {
69
+ console.log("running:JSSys:onEvent");
70
+ if (event.type == Amaz.EventType.VIEWER) {
71
+ // console.log("JSSys: 窗口大小改变");
72
+ console.log("renderTexture.width",this.renderTexture.width);
73
+ console.log("renderTexture.height",this.renderTexture.height);
74
+
75
+ window.innerWidth = this.renderTexture.width;
76
+ window.innerHeight = this.renderTexture.height;
77
+ // console.log("JSSys: 窗口大小改变");
78
+ this.scriptScene.handleResize();
79
+ }
80
+ }
81
+
82
+ onDestroy() {
83
+ // console.log("running:JSSys:onDestroy");
84
+ this.scriptScene.destroy();
85
+ }
86
+ }
87
+
88
+ exports.JSSys = JSSys;
89
+
scripts/7681318995261132040/AmazingFeature/js/ThreeJS/EffectComposer.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const{ShaderPass}=require("./ShaderPass.js");const getCurrentScene=require("./three-amg-wrapper.js").getCurrentScene;const RenderPass=require("./RenderPass.js").RenderPass;const Texture=require("./wrapper/Texture").Texture;const effect_api="undefined"!=typeof effect?effect:"undefined"!=typeof tt?tt:"undefined"!=typeof lynx?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;class EffectComposer{constructor(renderer){this.renderer=renderer;this.passes=[];this.scene=getCurrentScene();this.rt_0=this.scene._amgScene.assetMgr.SyncLoad("rt/RT_0.rt");this.rt_prev_Texture=null;this.rt_next_Texture=null;this.sourceEntity=this.scene._amgScene.findEntityBy("PerspectiveCamera_w");this.sourceCamera=this.sourceEntity?this.sourceEntity.getComponent("Camera"):null;this.outputEntity=this.scene._amgScene.findEntityBy("Camera")||this.sourceEntity;this.outputCamera=this.outputEntity?this.outputEntity.getComponent("Camera"):null;this._outputIsPerspective=!!(this.outputEntity&&this.outputEntity.name==="PerspectiveCamera_w");this._initialInputTexture=this.rt_0;this._currentInputTexture=this._initialInputTexture;this._ppPassCount=0;this.finalPlaceHolder=this.scene._amgScene.findEntityBy("PlaceHolder");this.outputRT=this.scene._amgScene.assetMgr.SyncLoad("rt/outputTex.rt");if(this.sourceEntity){this.sourceEntity.layer=0;if(this.sourceCamera){this.sourceCamera.renderOrder=0;this.sourceCamera.renderTexture=this.rt_0}}}_getStartOrder(){let startOrder=0;for(let i=0;i<this.passes.length;i++){const p=this.passes[i];if(!p)continue;startOrder+=p.isMultiPass?p.getPassCount():1}return startOrder}_allocNextRT(){const idx=this._ppPassCount%10+1|0;return this.scene._amgScene.assetMgr.SyncLoad("rt/RT_"+idx+".rt")}_makeTextureWrapper(rt){const t=new Texture;t.setImage(rt);return t}_wireFinalOutput(rt,totalOrder){const videoEntity=this.scene&&this.scene._amgScene?this.scene._amgScene.findEntityBy("video"):null;if(videoEntity){const mr=videoEntity.getComponent("MeshRenderer");const mat=mr?mr.material:null;if(mat&&typeof mat.setTex==="function"){mat.setTex("u_videoTex",rt)}}if(this.outputCamera){this.outputCamera.inputTexture=rt;if(!this._outputIsPerspective){this.outputCamera.renderOrder=totalOrder+1;this.outputCamera.layerVisibleMask=new Amaz.DynamicBitset(totalOrder+2,Math.pow(2,totalOrder+1))}}if(this.finalPlaceHolder){this.finalPlaceHolder.layer=totalOrder+1}if(this.outputRT){this.outputRT.inputTexture=rt}}_wirePassIO(pass,prevRT,nextRT,startOrder){const rt_prev_Texture=this._makeTextureWrapper(prevRT);const rt_next_Texture=this._makeTextureWrapper(nextRT);pass.prevTexture=rt_prev_Texture;pass.nextTexture=rt_next_Texture;if(pass.isMultiPass){if(pass.setInputTexture)pass.setInputTexture(prevRT);if(pass.setOutputTexture)pass.setOutputTexture(nextRT);if(pass.setRenderOrder)pass.setRenderOrder(startOrder+1)}else if(pass&&pass._amgMaterialObject){if(typeof pass._amgMaterialObject.setTex==="function"){pass._amgMaterialObject.setTex("tDiffuse",prevRT)}const camEntity=pass.cameraWarpEntity||pass.cameraEntity;const meshEntity=pass.passWarpEntity||pass.meshEntity;if(camEntity&&typeof camEntity.getComponent==="function"){const cam=camEntity.getComponent("Camera");if(cam){cam.renderTexture=nextRT;cam.renderOrder=startOrder+1;cam.layerVisibleMask=new Amaz.DynamicBitset(startOrder+2,Math.pow(2,startOrder+1))}}if(camEntity){camEntity.layer=startOrder+1}if(meshEntity){meshEntity.layer=startOrder+1}}this.rt_prev_Texture=rt_prev_Texture;this.rt_next_Texture=rt_next_Texture}getOutputTexture(){if(this.outputRT&&this.outputRT.inputTexture)return this.outputRT.inputTexture;if(this._currentInputTexture)return this._currentInputTexture;if(this._initialInputTexture)return this._initialInputTexture;return this.rt_0}addPass(pass){if(pass&&pass.isMultiPass){const startOrder=this._getStartOrder();this.passes.push(pass);const prevRT=this._currentInputTexture||this._initialInputTexture||this.rt_0;const nextRT=this._allocNextRT();this._wirePassIO(pass,prevRT,nextRT,startOrder);const totalOrder=startOrder+pass.getPassCount();this._wireFinalOutput(nextRT,totalOrder);this._currentInputTexture=nextRT;this._ppPassCount+=1;return}if(pass&&typeof pass.render==="function"&&!pass.cameraEntity&&!pass.cameraWarpEntity){this.passes.push(pass);return}if(!(pass instanceof ShaderPass)){console.log("pass is not a ShaderPass",pass);return}const camEntity=pass.cameraWarpEntity||pass.cameraEntity;if(!camEntity){console.log("pass camera entity is null",pass.name);return}this.scene.add(pass);const startOrder=this._getStartOrder();this.passes.push(pass);const prevRT=this._currentInputTexture||this._initialInputTexture||this.rt_0;const nextRT=this._allocNextRT();this._wirePassIO(pass,prevRT,nextRT,startOrder);const totalOrder=startOrder+(pass.isMultiPass?pass.getPassCount():1);this._wireFinalOutput(nextRT,totalOrder);this._currentInputTexture=nextRT;this._ppPassCount+=1}setSize(width,height){const w=Math.max(1,Math.floor(width));const h=Math.max(1,Math.floor(height));for(let i=0;i<this.passes.length;i++){const pass=this.passes[i];if(pass&&typeof pass.setSize==="function"){pass.setSize(w,h)}}}dispose(){for(let i=0;i<this.passes.length;i++){const pass=this.passes[i];if(pass&&typeof pass.dispose==="function"){pass.dispose()}}if(this.rt_prev_Texture){this.rt_prev_Texture.dispose()}if(this.rt_next_Texture){this.rt_next_Texture.dispose()}this.rt_prev_Texture=null;this.rt_next_Texture=null;this.passes.length=0;this._currentInputTexture=this._initialInputTexture;this._ppPassCount=0;this.sourceCamera=null;this.outputCamera=null;this.finalPlaceHolder=null;this.sourceEntity=null;this.outputEntity=null}render(deltaTime){const dt=typeof deltaTime==="number"?deltaTime:0;for(let i=0;i<this.passes.length;i++){const pass=this.passes[i];if(!pass||typeof pass.render!=="function")continue;const prev=pass.prevTexture;const next=pass.nextTexture;const hasBuffers=prev&&next&&prev.image&&next.image&&prev.image.width&&next.image.width;if(!hasBuffers){pass.render(this.renderer,null,null,dt,true);continue}const readbuffer={width:prev.image.width,height:prev.image.height,texture:prev};const writebuffer={width:next.image.width,height:next.image.height,texture:next};pass.render(this.renderer,writebuffer,readbuffer,dt,true)}}}exports.EffectComposer=EffectComposer;
scripts/7681318995261132040/AmazingFeature/js/ThreeJS/RenderPass.js ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class RenderPass {
2
+ constructor(scene, camera) {
3
+ this.scene = scene;
4
+ this.camera = camera;
5
+
6
+ // EffectComposer 兼容字段
7
+ this.enabled = true;
8
+ this.needsSwap = false; // 直接渲染到目标或屏幕
9
+ this.clear = false;
10
+ this.renderToScreen = false;
11
+ }
12
+
13
+ setSize(width, height) {
14
+ // RenderPass 一般无需处理尺寸变化
15
+ }
16
+
17
+ render(renderer, writeBuffer, readBuffer, deltaTime, maskActive) {
18
+ if (!this.enabled || !renderer || !this.scene || !this.camera) return;
19
+
20
+ const target = (this.renderToScreen || !writeBuffer) ? null : writeBuffer;
21
+
22
+ if (typeof renderer.setRenderTarget === 'function') {
23
+ renderer.setRenderTarget(target);
24
+ }
25
+ if (this.clear && typeof renderer.clear === 'function') {
26
+ renderer.clear();
27
+ }
28
+ renderer.render(this.scene, this.camera);
29
+ }
30
+
31
+ dispose() {}
32
+ }
33
+
34
+ exports.RenderPass = RenderPass;
scripts/7681318995261132040/AmazingFeature/js/ThreeJS/ShaderPass.js ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // 获取AMG引擎API
2
+ const effect_api = "undefined" != typeof effect ? effect : "undefined" != typeof tt ? tt : "undefined" != typeof lynx ? lynx : {};
3
+ const Amaz = effect_api.getAmaz ? effect_api.getAmaz() : null;
4
+
5
+ const THREE = require('./three-amg-wrapper.js').THREE;
6
+ const getCurrentScene = require('./three-amg-wrapper.js').getCurrentScene;
7
+ const ShaderMaterial = require('./wrapper/ShaderMaterial').ShaderMaterial;
8
+ const VideoTexture = require('./wrapper/Texture').VideoTexture;
9
+
10
+ class ShaderPass {
11
+ constructor(parameters = {}) {
12
+
13
+ this.progress = 0.0;
14
+ this.prevTexture = null;
15
+ this.nextTexture = null;
16
+ // super();
17
+ console.log('getCurrentScene():');
18
+ this.scene = getCurrentScene();
19
+ console.log('getCurrentScene():', this.scene);
20
+
21
+ if (parameters.name && !parameters.isDynamic) {
22
+ // 创建postProcessPrefab
23
+ this.postProcessPrefab = this.scene._amgScene.assetMgr.SyncLoad('prefabs/postProcess.prefab');
24
+ this._amgEntity = new Amaz.Entity();
25
+ this._amgEntity.name = parameters.name;
26
+ this._amgEntity.scene = this.scene._amgScene;
27
+ this._transform = this._amgEntity.addComponent("Transform");
28
+ this.postProcessPrefab.instantiateToEntity(
29
+ this.scene._amgScene,
30
+ this._amgEntity,
31
+ );
32
+ this.meshEntity = this._amgEntity.searchEntity("PassWarp");
33
+ this.cameraEntity = this._amgEntity.searchEntity("CameraWarp");
34
+ } else {
35
+ const baseName =
36
+ parameters.name ||
37
+ "DynamicShaderPass_" + Math.random().toString(36).substr(2, 9);
38
+ this._amgEntity = new Amaz.Entity();
39
+ this._amgEntity.name = baseName + "Entity";
40
+ this._amgEntity.scene = this.scene._amgScene;
41
+ this._transform = this._amgEntity.addComponent("Transform");
42
+
43
+ this.meshEntity = new Amaz.Entity();
44
+ this.meshEntity.name = "Mesh" + baseName + "Pass";
45
+ this.meshEntity.scene = this.scene._amgScene;
46
+ this.meshEntity.selfvisible = true;
47
+ this.meshEntity.visible = true;
48
+ const meshTransform = this.meshEntity.addComponent("Transform");
49
+
50
+ const mr = this.meshEntity.addComponent("MeshRenderer");
51
+ if (!ShaderPass.quadMesh) {
52
+ ShaderPass.quadMesh =
53
+ this.scene._amgScene.assetMgr.SyncLoad("prefabs/Quad.mesh");
54
+ }
55
+ mr.mesh = ShaderPass.quadMesh;
56
+
57
+ this.cameraEntity = new Amaz.Entity();
58
+ this.cameraEntity.name = "Camera" + baseName + "Pass";
59
+ this.cameraEntity.scene = this.scene._amgScene;
60
+ this.cameraEntity.selfvisible = true;
61
+ this.cameraEntity.visible = true;
62
+ const cameraTransform = this.cameraEntity.addComponent("Transform");
63
+
64
+ this._transform.addTransform(cameraTransform);
65
+ cameraTransform.localPosition = new Amaz.Vector3f(0, 0, 20);
66
+ cameraTransform.addTransform(meshTransform);
67
+ meshTransform.localPosition = new Amaz.Vector3f(0, 0, -10);
68
+
69
+ const cam = this.cameraEntity.addComponent("Camera");
70
+ cam.type = Amaz && Amaz.CameraType ? Amaz.CameraType.ORTHO : 1;
71
+ cam.clearType =
72
+ Amaz && Amaz.CameraClearType
73
+ ? Amaz.CameraClearType.COLOR_DEPTH
74
+ : cam.clearType;
75
+ cam.clearColor =
76
+ Amaz && Amaz.Color ? new Amaz.Color(0, 0, 0, 0) : cam.clearColor;
77
+ cam.alwaysClear = false;
78
+ cam.isRootCamera = true;
79
+ cam.renderOrder = 1;
80
+ cam.layerVisibleMask =
81
+ Amaz && Amaz.DynamicBitset
82
+ ? new Amaz.DynamicBitset(3, 4)
83
+ : cam.layerVisibleMask;
84
+ cam.orthoScale = 1;
85
+
86
+ if (this.scene && this.scene._amgScene) {
87
+ this.scene._amgScene.addEntity(this.meshEntity);
88
+ this.scene._amgScene.addEntity(this.cameraEntity);
89
+ }
90
+ }
91
+ this.material = new ShaderMaterial(parameters);
92
+ this._amgMaterialObject = this.material._amgObject;
93
+ const meshRenderer = this.meshEntity
94
+ ? this.meshEntity.getComponent("MeshRenderer")
95
+ : null;
96
+ if (meshRenderer) {
97
+ meshRenderer.sharedMaterial = this._amgMaterialObject;
98
+ }
99
+ }
100
+ setParentTransform(parentTransform) {
101
+ if (!parentTransform || !this._transform) return;
102
+ if (this._transform.parent && typeof this._transform.parent.removeTransform === "function") {
103
+ this._transform.parent.removeTransform(this._transform);
104
+ }
105
+ if (typeof parentTransform.addTransform === "function") {
106
+ parentTransform.addTransform(this._transform);
107
+ }
108
+ }
109
+ seekToTime(time) {
110
+ if (!this.material || !this.material.uniforms) return;
111
+ for (const [key, uniform] of Object.entries(this.material.uniforms)) {
112
+ if (!uniform) continue;
113
+ const value = Object.prototype.hasOwnProperty.call(uniform, "value")
114
+ ? uniform.value
115
+ : uniform;
116
+ if (!(value instanceof VideoTexture)) continue;
117
+ const renderer = value._amgSprite2DRenderer;
118
+ if (!renderer || renderer.materials.size() !== 1) continue;
119
+ const texture = renderer.materials.get(0).getTex("_MainTex");
120
+ value.setImage(texture);
121
+ if (typeof this.material._syncUniformToAMG === "function") {
122
+ this.material._syncUniformToAMG(key, uniform);
123
+ }
124
+ if (value._amgVideoAnimSeq) {
125
+ value._amgVideoAnimSeq.seekToTime(time / 1e3);
126
+ }
127
+ }
128
+ }
129
+ get uniforms() {
130
+ return this.material ? this.material.uniforms : undefined;
131
+ }
132
+ render(renderer, writeBuffer, readBuffer, delta, maskActive) {
133
+ return;
134
+ }
135
+ dispose() {
136
+ if (this.scene && this.scene._amgScene) {
137
+ if (this.meshEntity) {
138
+ this.scene._amgScene.removeEntity(this.meshEntity);
139
+ }
140
+ if (this.cameraEntity) {
141
+ this.scene._amgScene.removeEntity(this.cameraEntity);
142
+ }
143
+ }
144
+ if (this.material && typeof this.material.dispose === "function") {
145
+ this.material.dispose();
146
+ }
147
+ this.postProcessPrefab = null;
148
+ this.material = null;
149
+ this._amgMaterialObject = null;
150
+ if (this.prevTexture) {
151
+ this.prevTexture.dispose();
152
+ }
153
+ if (this.nextTexture) {
154
+ this.nextTexture.dispose();
155
+ }
156
+ this.prevTexture = null;
157
+ this.nextTexture = null;
158
+ this.scene = null;
159
+ this.meshEntity = null;
160
+ this.cameraEntity = null;
161
+ }
162
+ }
163
+ ShaderPass.quadMesh = null;
164
+ ShaderPass.camType = undefined;
165
+ ShaderPass.camOrthoScale = undefined;
166
+ exports.ShaderPass = ShaderPass;
scripts/7681318995261132040/AmazingFeature/js/ThreeJS/customEasings.js ADDED
@@ -0,0 +1,1127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * 自定义缓动函数库
3
+ *
4
+ * 提供 Tween.js 官方未提供的缓动组合。
5
+ * LLM 产物只从此模块选取已命名曲线,不得自造任意 function(k){...}。
6
+ *
7
+ * ─── 顶层分组(按曲线形态) ───────────────────────────────────────────────
8
+ * OutIn.* —— 先释放再收束,Out/In 组合模式(独立保留)
9
+ * Progress.* —— 单调或衰减至 1 的曲线(A→B 过渡)
10
+ * Pulse.* —— 单次返零脉冲(f(0)=f(1)=0, 单主峰)
11
+ * Wave.* —— 周期多峰振荡(f(0)=f(1)=0, 多次反转)
12
+ * cubicBezier(name | x1,y1,x2,y2) —— 贝塞尔工厂(L2,受限)
13
+ *
14
+ * 二级键沿用主题语义(Physics/Motion/Step/Attention/Breath/Heart/Math/
15
+ * Explosion/Nature/Impact/Rhythm/UI/Magic/Animal),三级键为具体
16
+ * 曲线。业界库曲线已并入最贴近的主题:Physics.Spring、Step.Steps6、
17
+ * Heart.Beat。通用 UI 柔化请直接选用原生 Sinusoidal/Quadratic/Cubic(等);
18
+ * 需定制贝塞尔时使用 cubicBezier(x1,y1,x2,y2) 工厂。例:
19
+ * customEasings.Progress.Physics.Spring
20
+ * customEasings.Pulse.Explosion.Impulse
21
+ * customEasings.Wave.Breath.Normal
22
+ *
23
+ * 完整清单位于文件末尾 Progress / Pulse / Wave 的 Object.freeze 声明。
24
+ */
25
+
26
+ const TWEEN = require('./tween');
27
+
28
+ // ─── §1 OutIn 模式 ────────────────────────────────────────────────────────
29
+
30
+ /**
31
+ * 将 Out / In 曲线组合为 OutIn 模式。
32
+ * k ∈ [0, 0.5] 走 easingOut(2k) 的前半,映射到 [0, 0.5]
33
+ * k ∈ [0.5, 1] 走 easingIn(2k - 1) 的前半,映射到 [0.5, 1]
34
+ */
35
+ function makeOutIn(easingOut, easingIn) {
36
+ return function outIn(k) {
37
+ if (k < 0.5) return 0.5 * easingOut(k * 2);
38
+ return 0.5 * easingIn(k * 2 - 1) + 0.5;
39
+ };
40
+ }
41
+
42
+ const E = TWEEN.Easing;
43
+
44
+ const OutIn = Object.freeze({
45
+ Sinusoidal: makeOutIn(E.Sinusoidal.Out, E.Sinusoidal.In),
46
+ Exponential: makeOutIn(E.Exponential.Out, E.Exponential.In),
47
+ Circular: makeOutIn(E.Circular.Out, E.Circular.In),
48
+ Elastic: makeOutIn(E.Elastic.Out, E.Elastic.In),
49
+ Back: makeOutIn(E.Back.Out, E.Back.In),
50
+ Bounce: makeOutIn(E.Bounce.Out, E.Bounce.In),
51
+ Quadratic: makeOutIn(E.Quadratic.Out, E.Quadratic.In),
52
+ Cubic: makeOutIn(E.Cubic.Out, E.Cubic.In),
53
+ Quartic: makeOutIn(E.Quartic.Out, E.Quartic.In),
54
+ Quintic: makeOutIn(E.Quintic.Out, E.Quintic.In),
55
+ });
56
+
57
+ // ─── §2 Smooth(已整组移除:原生 Sinusoidal/Quadratic/Cubic 已覆盖通用 UI 柔化场景) ───
58
+
59
+ // ─── §3 Physics 物理系 ─────────────────────────────────────────────────────
60
+
61
+ // 欠阻尼弹簧(软):ζ≈0.3,约一次明显越界
62
+ const springSoft = (k) => {
63
+ if (k <= 0) return 0;
64
+ if (k >= 1) return 1;
65
+ return 1 - Math.exp(-6 * k) * Math.cos(12 * k);
66
+ };
67
+
68
+ // 欠阻尼弹簧(硬):更高频振荡、更慢收敛
69
+ const springStiff = (k) => {
70
+ if (k <= 0) return 0;
71
+ if (k >= 1) return 1;
72
+ return 1 - Math.exp(-5 * k) * Math.cos(18 * k);
73
+ };
74
+
75
+ // 阻尼振荡:sin 基波收尾抖动
76
+ const dampedOscillation = (k) => {
77
+ if (k <= 0) return 0;
78
+ if (k >= 1) return 1;
79
+ return 1 - Math.exp(-5 * k) * Math.cos(10 * k);
80
+ };
81
+
82
+ const Physics = Object.freeze({
83
+ SpringSoft: springSoft,
84
+ SpringStiff: springStiff,
85
+ DampedOscillation: dampedOscillation,
86
+ });
87
+
88
+ // ─── §4 Motion 动作设计系 ──────────────────────────────────────────────────
89
+
90
+ // 先回拉 10% 再冲向终点:蓄力动作
91
+ const anticipate = (k) => {
92
+ if (k <= 0) return 0;
93
+ if (k >= 1) return 1;
94
+ const pullback = 0.1;
95
+ if (k < 0.3) {
96
+ const p = k / 0.3;
97
+ return -pullback * p * (2 - p); // easeOutQuad 到 -pullback
98
+ }
99
+ const p = (k - 0.3) / 0.7;
100
+ return -pullback + (1 + pullback) * p * p * (3 - 2 * p); // smoothstep 到 1
101
+ };
102
+
103
+ // 冲到 peak 再回到 1 的工厂
104
+ const overshootFactory = (peak) => (k) => {
105
+ if (k <= 0) return 0;
106
+ if (k >= 1) return 1;
107
+ if (k < 0.6) {
108
+ const p = k / 0.6;
109
+ return peak * p * (2 - p); // easeOutQuad 到 peak
110
+ }
111
+ const p = (k - 0.6) / 0.4;
112
+ return peak + (1 - peak) * (1 - Math.pow(1 - p, 3)); // easeOutCubic 到 1
113
+ };
114
+
115
+ const overshoot110 = overshootFactory(1.10);
116
+ const overshoot125 = overshootFactory(1.25);
117
+
118
+ // 快速到位(前 60% 冲到 1.05),后 40% 回到 1:磁吸、卡扣
119
+ const snapBack = (k) => {
120
+ if (k <= 0) return 0;
121
+ if (k >= 1) return 1;
122
+ if (k < 0.6) {
123
+ const p = k / 0.6;
124
+ return 1.05 * (1 - Math.pow(1 - p, 3));
125
+ }
126
+ const p = (k - 0.6) / 0.4;
127
+ return 1.05 - 0.05 * p * p * (3 - 2 * p);
128
+ };
129
+
130
+ // 摆锤式:一次轻微过冲后收敛
131
+ const swing = (k) => {
132
+ if (k <= 0) return 0;
133
+ if (k >= 1) return 1;
134
+ return 1 - Math.cos(1.5 * Math.PI * k) * Math.exp(-2.5 * k);
135
+ };
136
+
137
+ const Motion = Object.freeze({
138
+ Anticipate: anticipate,
139
+ Overshoot110: overshoot110,
140
+ Overshoot125: overshoot125,
141
+ SnapBack: snapBack,
142
+ Swing: swing,
143
+ });
144
+
145
+ // ─── §5 Step 步进系 ────────────────────────────────────────────────────────
146
+
147
+ /**
148
+ * CSS steps() 等价工厂。
149
+ * @param {number} n 段数
150
+ * @param {'start' | 'end'} jumpTerm 跳变在每段的起始还是结束(默认 'end')
151
+ */
152
+ const makeStep = (n, jumpTerm = 'end') => (k) => {
153
+ if (k <= 0) return 0;
154
+ if (k >= 1) return 1;
155
+ if (jumpTerm === 'start') return Math.ceil(k * n) / n;
156
+ return Math.floor(k * n) / n;
157
+ };
158
+
159
+ const Step = Object.freeze({
160
+ Steps4End: makeStep(4, 'end'),
161
+ Steps8End: makeStep(8, 'end'),
162
+ Steps12End: makeStep(12, 'end'),
163
+ });
164
+
165
+ // ─── §6 Bezier 规范贝塞尔 ──────────────────────────────────────────────────
166
+
167
+ /**
168
+ * 给定两个控制点 (x1,y1) 与 (x2,y2),P0=(0,0) P3=(1,1)。
169
+ * 返回函数 f(t) -> y,其中 t 是输入时间(需先用牛顿法从 x 反解 s)。
170
+ */
171
+ function buildCubicBezier(x1, y1, x2, y2) {
172
+ const cx = 3 * x1, bx = 3 * (x2 - x1) - cx, ax = 1 - cx - bx;
173
+ const cy = 3 * y1, by = 3 * (y2 - y1) - cy, ay = 1 - cy - by;
174
+ const sampleX = (s) => ((ax * s + bx) * s + cx) * s;
175
+ const sampleY = (s) => ((ay * s + by) * s + cy) * s;
176
+ const sampleDX = (s) => (3 * ax * s + 2 * bx) * s + cx;
177
+
178
+ const solveS = (x) => {
179
+ let s = x;
180
+ for (let i = 0; i < 8; i++) {
181
+ const cur = sampleX(s) - x;
182
+ if (Math.abs(cur) < 1e-6) return s;
183
+ const d = sampleDX(s);
184
+ if (Math.abs(d) < 1e-6) break;
185
+ s -= cur / d;
186
+ if (s < 0) s = 0;
187
+ if (s > 1) s = 1;
188
+ }
189
+ // 兜底二分
190
+ let lo = 0, hi = 1;
191
+ for (let i = 0; i < 32 && hi - lo > 1e-6; i++) {
192
+ const mid = (lo + hi) / 2;
193
+ if (sampleX(mid) < x) lo = mid; else hi = mid;
194
+ }
195
+ return (lo + hi) / 2;
196
+ };
197
+
198
+ return (k) => {
199
+ if (k <= 0) return 0;
200
+ if (k >= 1) return 1;
201
+ return sampleY(solveS(k));
202
+ };
203
+ }
204
+
205
+ // 贝塞尔白名单:(x1, y1, x2, y2)
206
+ const BEZIER_PRESETS = Object.freeze({
207
+ 'Material.Standard': [0.4, 0, 0.2, 1],
208
+ 'Material.Accelerate': [0.4, 0, 1, 1],
209
+ 'Material.Decelerate': [0, 0, 0.2, 1],
210
+ 'CSS.Ease': [0.25, 0.1, 0.25, 1],
211
+ });
212
+
213
+ // 工厂 memoization(避免同参数重复构造)
214
+ const _bezierCache = new Map();
215
+ function _cachedBezier(x1, y1, x2, y2) {
216
+ const key = x1 + ',' + y1 + ',' + x2 + ',' + y2;
217
+ let fn = _bezierCache.get(key);
218
+ if (!fn) {
219
+ fn = buildCubicBezier(x1, y1, x2, y2);
220
+ _bezierCache.set(key, fn);
221
+ }
222
+ return fn;
223
+ }
224
+
225
+ /**
226
+ * cubicBezier('Material.Standard') | cubicBezier(x1, y1, x2, y2)
227
+ * 直写参数受控域:x1/x2 ∈ [0,1],y1/y2 ∈ [-0.5, 1.5]
228
+ */
229
+ function cubicBezier(a, b, c, d) {
230
+ if (typeof a === 'string') {
231
+ let preset = BEZIER_PRESETS[a];
232
+ if (!preset) {
233
+ console.warn('[customEasings.cubicBezier] unknown preset, falling back to Material.Standard:', a);
234
+ preset = BEZIER_PRESETS['Material.Standard'];
235
+ }
236
+ return _cachedBezier(preset[0], preset[1], preset[2], preset[3]);
237
+ }
238
+ // 数值入口:裁剪到允许域
239
+ const clamp = (v, lo, hi) => Math.max(lo, Math.min(hi, v));
240
+ const x1 = clamp(a, 0, 1);
241
+ const y1 = clamp(b, -0.5, 1.5);
242
+ const x2 = clamp(c, 0, 1);
243
+ const y2 = clamp(d, -0.5, 1.5);
244
+ return _cachedBezier(x1, y1, x2, y2);
245
+ }
246
+
247
+ // 命名贝塞尔实例已整组移除:Material/CSS 预设与原生 Sinusoidal/Quadratic/Cubic
248
+ // 数值上几乎等价,特殊场景请直接调用 cubicBezier('Material.Standard') 等工厂。
249
+
250
+ // ═══════════════════════════════════════════════════════════════════════════
251
+ // 扩展分组(与已有 6 组并列,不污染既有命名空间)
252
+ // ═══════════════════════════════════════════════════════════════════════════
253
+
254
+ // ─── §7 业界库扩展(已并入 Physics / Step / Heart) ─────────────────────────
255
+ // 以下工厂原本聚合在 Lib.* 命名空间下,现已按语义归入相应主题:
256
+ // Spring (Framer Motion) → Progress.Physics.Spring
257
+ // Steps (GSAP) → Progress.Step.Steps6
258
+ // HeartBeat → Wave.Heart.Beat
259
+ // 退役:Framer Motion 的 Anticipate / GSAP 的 Overshoot factory(由 Motion.*
260
+ // 覆盖);GSAP ExpoScale / Unity SmoothDamp(数值上与原生 Sinusoidal/Quadratic
261
+ // 等价,已整组移除)。
262
+
263
+ // Spring(Framer Motion 风格):参数化弹簧,离散积分
264
+ const libSpring = ({ stiffness = 180, damping = 12, mass = 1 } = {}) => {
265
+ const DT = 1 / 240;
266
+ const T = 1.5;
267
+ let x = 0, v = 0;
268
+ const samples = [];
269
+ for (let t = 0; t <= T; t += DT) {
270
+ const force = -stiffness * (x - 1) - damping * v;
271
+ v += (force / mass) * DT;
272
+ x += v * DT;
273
+ samples.push({ t, x });
274
+ }
275
+ let T_end = T;
276
+ for (let i = samples.length - 1; i >= 0; i--) {
277
+ if (Math.abs(samples[i].x - 1) > 0.01) { T_end = samples[i].t; break; }
278
+ }
279
+ return (k) => {
280
+ if (k <= 0) return 0;
281
+ if (k >= 1) return 1;
282
+ const t = k * T_end;
283
+ const idx = Math.min(samples.length - 1, Math.floor(t / DT));
284
+ return samples[idx].x;
285
+ };
286
+ };
287
+
288
+ // HeartBeat(简易版):两高斯峰的绝对值轨迹
289
+ const libHeartBeat = (peak = 0.3) => (k) => {
290
+ if (k <= 0 || k >= 1) return 0;
291
+ const bell = (t, c) => Math.exp(-((t - c) ** 2) / (2 * 0.07 * 0.07));
292
+ return peak * (bell(k, 0.2) + bell(k, 0.5));
293
+ };
294
+
295
+ // Steps(GSAP SteppedEase 风格 factory):离散 N 段阶梯(默认 n=6)
296
+ const libSteps = (n = 6) => (k) => {
297
+ if (k <= 0) return 0;
298
+ if (k >= 1) return 1;
299
+ return Math.floor(k * n) / n;
300
+ };
301
+
302
+ // ─── §8 Attention 注意力 / 抖振 ────────────────────────────────────────────
303
+
304
+ // Ping:单次衰减脉冲(雷达 ping),sin(π·k) × exp(-decay·k)
305
+ const attentionPing = (peak = 0.35, decay = 2) => (k) => {
306
+ if (k <= 0 || k >= 1) return 0;
307
+ return peak * Math.sin(Math.PI * k) * Math.exp(-decay * k);
308
+ };
309
+
310
+ // Wiggle:衰减正弦振荡(easing 值本身,非位置增量)
311
+ const attentionWiggle = (count = 4, amplitude = 0.25) => (k) => {
312
+ if (k <= 0 || k >= 1) return 0;
313
+ const env = 1 - k;
314
+ return amplitude * env * Math.sin(k * Math.PI * 2 * count);
315
+ };
316
+
317
+ // Strum:多峰衰减(吉他拨弦)
318
+ const attentionStrum = (notes = 4, peak = 0.4) => {
319
+ const centers = [];
320
+ for (let i = 0; i < notes; i++) {
321
+ centers.push({ c: 0.15 + i * (0.7 / Math.max(1, notes - 1)), a: Math.pow(0.72, i) });
322
+ }
323
+ return (k) => {
324
+ if (k <= 0 || k >= 1) return 0;
325
+ let sum = 0;
326
+ for (const { c, a } of centers) {
327
+ sum += a * Math.exp(-((k - c) ** 2) / (2 * 0.05 * 0.05));
328
+ }
329
+ return peak * sum;
330
+ };
331
+ };
332
+
333
+ const Attention = Object.freeze({
334
+ Ping: attentionPing(),
335
+ Wiggle: attentionWiggle(),
336
+ Strum: attentionStrum(),
337
+ });
338
+
339
+ // ─── §9 Breath 呼吸 ────────────────────────────────────────────────────────
340
+
341
+ // Normal:慢节奏正弦呼吸
342
+ const breathNormal = (cycles = 2, peak = 0.15) => (k) => {
343
+ if (k <= 0 || k >= 1) return 0;
344
+ return peak * Math.sin(k * Math.PI * 2 * cycles) * Math.sin(k * Math.PI);
345
+ };
346
+
347
+ // Deep:深呼吸——慢吸气 → hold → 慢呼气
348
+ const breathDeep = (peak = 0.3, riseRatio = 0.35, holdRatio = 0.15) => {
349
+ const holdEnd = riseRatio + holdRatio;
350
+ return (k) => {
351
+ if (k <= 0 || k >= 1) return 0;
352
+ if (k < riseRatio) {
353
+ const t = k / riseRatio;
354
+ return peak * Math.sin(t * Math.PI / 2);
355
+ }
356
+ if (k < holdEnd) {
357
+ return peak;
358
+ }
359
+ const t = (k - holdEnd) / (1 - holdEnd);
360
+ return peak * Math.cos(t * Math.PI / 2);
361
+ };
362
+ };
363
+
364
+ // Panting:急促浅呼吸——多次小幅起伏 + 正弦包络
365
+ const breathPanting = (cycles = 6, peak = 0.08) => (k) => {
366
+ if (k <= 0 || k >= 1) return 0;
367
+ const envelope = Math.sin(k * Math.PI);
368
+ const wave = 0.5 + 0.5 * Math.sin(k * Math.PI * 2 * cycles - Math.PI / 2);
369
+ return peak * envelope * wave;
370
+ };
371
+
372
+ // Sigh:叹息——快速吸气后慢速释放
373
+ const breathSigh = (peak = 0.25, riseRatio = 0.2) => (k) => {
374
+ if (k <= 0 || k >= 1) return 0;
375
+ if (k < riseRatio) {
376
+ const t = k / riseRatio;
377
+ return peak * Math.sin(t * Math.PI / 2);
378
+ }
379
+ const t = (k - riseRatio) / (1 - riseRatio);
380
+ return peak * (1 - t) * (1 - t);
381
+ };
382
+
383
+ const Breath = Object.freeze({
384
+ Normal: breathNormal(),
385
+ Deep: breathDeep(),
386
+ Panting: breathPanting(),
387
+ Sigh: breathSigh(),
388
+ });
389
+
390
+ // ─── §10 Heart 心跳 ────────────────────────────────────────────────────────
391
+
392
+ // Calm:单次舒缓心跳——单高斯峰
393
+ const heartCalm = (peak = 0.25, center = 0.35, width = 0.1) => (k) => {
394
+ if (k <= 0 || k >= 1) return 0;
395
+ return peak * Math.exp(-((k - center) ** 2) / (2 * width * width));
396
+ };
397
+
398
+ // Excited:兴奋/紧张——密集快速心跳(N 连击)
399
+ const heartExcited = (beats = 4, peak = 0.3, width = 0.04) => {
400
+ const centers = [];
401
+ const span = 0.7;
402
+ for (let i = 0; i < beats; i++) {
403
+ centers.push(0.15 + i * (span / Math.max(1, beats - 1)));
404
+ }
405
+ return (k) => {
406
+ if (k <= 0 || k >= 1) return 0;
407
+ let sum = 0;
408
+ for (const c of centers) {
409
+ sum += Math.exp(-((k - c) ** 2) / (2 * width * width));
410
+ }
411
+ return peak * sum;
412
+ };
413
+ };
414
+
415
+ // LubDub:标准心跳「lub-dub」双音节
416
+ const heartLubDub = (peak = 0.3) => (k) => {
417
+ if (k <= 0 || k >= 1) return 0;
418
+ const bell = (t, c, w) => Math.exp(-((t - c) ** 2) / (2 * w * w));
419
+ // lub(S1):中心 0.25、宽 0.045、幅 1.0
420
+ // dub(S2):中心 0.42、宽 0.03、幅 0.6
421
+ return peak * (bell(k, 0.25, 0.045) + 0.6 * bell(k, 0.42, 0.03));
422
+ };
423
+
424
+ const Heart = Object.freeze({
425
+ Calm: heartCalm(),
426
+ Excited: heartExcited(),
427
+ LubDub: heartLubDub(),
428
+ });
429
+
430
+ // ─── §11 Math 物理 / 数学 ─────────────────────────────────────────────────
431
+
432
+ // JumpArc:抛物线轨迹 4k(1-k)
433
+ const mathJumpArc = () => (k) => {
434
+ if (k <= 0 || k >= 1) return 0;
435
+ return 4 * k * (1 - k);
436
+ };
437
+
438
+ // Pendulum:物理摆——sin(πk) 包络的衰减余弦,端点归零(满足 Wave 契约 f(0)=f(1)=0)
439
+ const mathPendulum = (damping = 3, freq = 2.5) => (k) => {
440
+ if (k <= 0 || k >= 1) return 0;
441
+ return Math.sin(k * Math.PI) * Math.exp(-damping * k) * Math.cos(freq * Math.PI * k);
442
+ };
443
+
444
+ // Tremor:持续高频小幅抖动(不衰减),整体沿 Linear 进行
445
+ const mathTremor = (amplitude = 0.04, freq = 22) => (k) => {
446
+ if (k <= 0) return 0;
447
+ if (k >= 1) return 1;
448
+ return k + amplitude * Math.sin(k * Math.PI * 2 * freq);
449
+ };
450
+
451
+ // Boomerang 包装器:把任意 easing 包装成 0→1→0(先去再回)。
452
+ // 仅作为内部辅助使用,不暴露为公共曲线——常用变体已预实例化为
453
+ // Pulse.Math.BoomerangSharp / BoomerangSoft(见 Pulse 命名空间)。
454
+ const mathBoomerang = (fn) => (k) => {
455
+ if (k <= 0 || k >= 1) return 0;
456
+ return k < 0.5 ? fn(k * 2) : fn(2 - k * 2);
457
+ };
458
+
459
+ const MathExt = Object.freeze({
460
+ JumpArc: mathJumpArc(),
461
+ Pendulum: mathPendulum(),
462
+ Tremor: mathTremor(),
463
+ });
464
+
465
+ // ─── §12 Explosion 爆炸 ────────────────────────────────────────────────────
466
+
467
+ // Impulse:指数脉冲响应 k·e^(1-k·sharpness)(减线性尾项使 k=1 归 0)
468
+ const explosionImpulse = (sharpness = 6) => {
469
+ const tail = sharpness * Math.exp(1 - sharpness);
470
+ return (k) => {
471
+ if (k <= 0 || k >= 1) return 0;
472
+ const h = sharpness * k;
473
+ return h * Math.exp(1 - h) - tail * k;
474
+ };
475
+ };
476
+
477
+ // Flash:瞬间拉满 + 指数衰减到 0
478
+ const explosionFlash = (rise = 0.05, decay = 5) => (k) => {
479
+ if (k <= 0 || k >= 1) return 0;
480
+ if (k < rise) return k / rise;
481
+ return Math.exp(-decay * (k - rise));
482
+ };
483
+
484
+ // Recoil:爆炸反冲——负向冲击 -1 + 阻尼振荡
485
+ const explosionRecoil = (decay = 4, freq = 3) => (k) => {
486
+ if (k <= 0 || k >= 1) return 0;
487
+ return -Math.exp(-decay * k) * Math.cos(freq * Math.PI * k);
488
+ };
489
+
490
+ // Implosion:三段式——负向吸能 → 正向爆发 → 衰减归 0
491
+ const explosionImplosion = (charge = 0.3, depth = 0.4, burstPeak = 1.2) => {
492
+ const sharp = 5;
493
+ const tail = sharp * Math.exp(1 - sharp);
494
+ return (k) => {
495
+ if (k <= 0 || k >= 1) return 0;
496
+ if (k < charge) {
497
+ const t = k / charge;
498
+ return -depth * Math.sin(t * Math.PI / 2);
499
+ }
500
+ const t = (k - charge) / (1 - charge);
501
+ const h = sharp * t;
502
+ const wave = h * Math.exp(1 - h) - tail * t;
503
+ const settle = -depth * Math.pow(1 - t, 3);
504
+ return settle + burstPeak * wave;
505
+ };
506
+ };
507
+
508
+ const Explosion = Object.freeze({
509
+ Impulse: explosionImpulse(),
510
+ Flash: explosionFlash(),
511
+ Recoil: explosionRecoil(),
512
+ Implosion: explosionImplosion(),
513
+ });
514
+
515
+ // ─── §13 Cinema(已整组移除:Creep=k^3.5 与 Cubic.In/Quartic.In 数值等价) ─
516
+
517
+ // ─── §14 Nature 自然现象 ───────────────────────────────────────────────────
518
+
519
+ // Wave:海浪律动——多谐波叠加 + 整体正弦包络
520
+ const natureWave = (cycles = 3, amplitude = 0.25) => (k) => {
521
+ if (k <= 0 || k >= 1) return 0;
522
+ const env = Math.sin(k * Math.PI);
523
+ const w = Math.sin(k * Math.PI * 2 * cycles)
524
+ + 0.5 * Math.sin(k * Math.PI * 2 * cycles * 1.5 + 1.2)
525
+ + 0.25 * Math.sin(k * Math.PI * 2 * cycles * 3 + 2.4);
526
+ return amplitude * env * w * 0.6;
527
+ };
528
+
529
+ // Flicker:火焰闪烁——伪随机采样 + 线性插值 + 正弦包络
530
+ const natureFlicker = (rate = 15, intensity = 0.2, seed = 7) => {
531
+ let s = seed;
532
+ const rand = () => { s = (s * 9301 + 49297) % 233280; return s / 233280; };
533
+ const samples = [];
534
+ for (let i = 0; i <= rate + 1; i++) samples.push(rand());
535
+ return (k) => {
536
+ if (k <= 0 || k >= 1) return 0;
537
+ const env = Math.sin(k * Math.PI);
538
+ const pos = k * rate;
539
+ const idx = Math.floor(pos);
540
+ const t = pos - idx;
541
+ const a = samples[idx];
542
+ const b = samples[idx + 1];
543
+ const interp = a + (b - a) * t;
544
+ return intensity * env * (interp - 0.5) * 2;
545
+ };
546
+ };
547
+
548
+ // Gust:风——N 次高斯阵风叠加
549
+ const natureGust = (gusts = 3, peak = 0.25) => {
550
+ const centers = [];
551
+ const span = 0.7;
552
+ for (let i = 0; i < gusts; i++) {
553
+ centers.push(0.15 + i * (span / Math.max(1, gusts - 1)));
554
+ }
555
+ return (k) => {
556
+ if (k <= 0 || k >= 1) return 0;
557
+ let sum = 0;
558
+ for (const c of centers) {
559
+ sum += Math.exp(-((k - c) ** 2) / (2 * 0.08 * 0.08));
560
+ }
561
+ return peak * sum / gusts * 1.8;
562
+ };
563
+ };
564
+
565
+ const Nature = Object.freeze({
566
+ Wave: natureWave(),
567
+ Flicker: natureFlicker(),
568
+ Gust: natureGust(),
569
+ });
570
+
571
+ // ─── §15 Impact 撞击 / 落地 ────────────────────────────────────────────────
572
+
573
+ // Rain:雨滴下落——重力加速段 + 撞击 + 小幅余震
574
+ const impactRain = (impactAt = 0.7, rippleAmp = 0.08) => (k) => {
575
+ if (k <= 0) return 0;
576
+ if (k >= 1) return 1;
577
+ if (k < impactAt) {
578
+ const t = k / impactAt;
579
+ return t * t;
580
+ }
581
+ const t = (k - impactAt) / (1 - impactAt);
582
+ return 1 + rippleAmp * Math.exp(-4 * t) * Math.sin(t * Math.PI * 6);
583
+ };
584
+
585
+ // Hammer:锤击——抬起蓄力(负值)→ 快速下击 → 微反弹
586
+ const impactHammer = (liftDepth = 0.25) => {
587
+ const liftEnd = 0.35, strikeEnd = 0.6;
588
+ return (k) => {
589
+ if (k <= 0) return 0;
590
+ if (k >= 1) return 1;
591
+ if (k < liftEnd) {
592
+ const t = k / liftEnd;
593
+ return -liftDepth * Math.sin(t * Math.PI);
594
+ }
595
+ if (k < strikeEnd) {
596
+ const t = (k - liftEnd) / (strikeEnd - liftEnd);
597
+ return t * t;
598
+ }
599
+ const t = (k - strikeEnd) / (1 - strikeEnd);
600
+ return 1 - 0.06 * Math.exp(-5 * t) * Math.sin(t * Math.PI * 4);
601
+ };
602
+ };
603
+
604
+ // BounceDrop:下落 + 多次衰减反弹
605
+ const impactBounceDrop = (bounces = 3, rebound = 0.25) => (k) => {
606
+ if (k <= 0) return 0;
607
+ if (k >= 1) return 1;
608
+ if (k < 0.4) {
609
+ const t = k / 0.4;
610
+ return t * t;
611
+ }
612
+ const t = (k - 0.4) / 0.6;
613
+ const env = Math.exp(-2.5 * t);
614
+ const wave = Math.abs(Math.sin(t * Math.PI * bounces));
615
+ return 1 - env * wave * rebound;
616
+ };
617
+
618
+ // Slap:拍击——快速接触 + 短暂保持 + 快速撤回
619
+ const impactSlap = (contactAt = 0.3, holdRatio = 0.1) => (k) => {
620
+ if (k <= 0 || k >= 1) return 0;
621
+ if (k < contactAt) {
622
+ const t = k / contactAt;
623
+ return t * t;
624
+ }
625
+ if (k < contactAt + holdRatio) return 1;
626
+ const t = (k - contactAt - holdRatio) / (1 - contactAt - holdRatio);
627
+ return (1 - t) * (1 - t);
628
+ };
629
+
630
+ // ArrowHit:箭中靶——匀速飞行 + 命中 + 插入后高频振颤衰减
631
+ const impactArrowHit = (impactAt = 0.5) => (k) => {
632
+ if (k <= 0) return 0;
633
+ if (k >= 1) return 1;
634
+ if (k < impactAt) {
635
+ const t = k / impactAt;
636
+ return t * (0.7 + 0.3 * t);
637
+ }
638
+ const t = (k - impactAt) / (1 - impactAt);
639
+ const env = Math.exp(-5 * t);
640
+ const wave = Math.sin(t * Math.PI * 10);
641
+ return 1 + 0.1 * env * wave;
642
+ };
643
+
644
+ // Shatter:撞碎——下落 + 撞击 + 能量 impulse 爆发 + 回到 1
645
+ const impactShatter = (impactAt = 0.55, burstAmp = 0.35) => {
646
+ const sharp = 5;
647
+ const tail = sharp * Math.exp(1 - sharp);
648
+ return (k) => {
649
+ if (k <= 0) return 0;
650
+ if (k >= 1) return 1;
651
+ if (k < impactAt) {
652
+ const t = k / impactAt;
653
+ return t * t;
654
+ }
655
+ const t = (k - impactAt) / (1 - impactAt);
656
+ const h = sharp * t;
657
+ const impulseVal = h * Math.exp(1 - h) - tail * t;
658
+ return 1 + burstAmp * impulseVal;
659
+ };
660
+ };
661
+
662
+ const Impact = Object.freeze({
663
+ Rain: impactRain(),
664
+ Hammer: impactHammer(),
665
+ BounceDrop: impactBounceDrop(),
666
+ Slap: impactSlap(),
667
+ ArrowHit: impactArrowHit(),
668
+ Shatter: impactShatter(),
669
+ });
670
+
671
+ // ─── §16 Rhythm 节奏 / 冲击 ────────────────────────────────────────────────
672
+
673
+ // BassDrop:EDM 重拍——缓慢蓄力 → pause pre-drop → 瞬间掉到 1 → 持续并有微脉动
674
+ const rhythmBassDrop = () => (k) => {
675
+ if (k <= 0) return 0;
676
+ if (k >= 1) return 1;
677
+ if (k < 0.4) {
678
+ const t = k / 0.4;
679
+ return 0.4 * Math.pow(t, 2.5);
680
+ }
681
+ if (k < 0.48) {
682
+ const t = (k - 0.4) / 0.08;
683
+ return 0.4 - 0.2 * t;
684
+ }
685
+ if (k < 0.52) {
686
+ const t = (k - 0.48) / 0.04;
687
+ return 0.2 + 0.8 * t;
688
+ }
689
+ const t = (k - 0.52) / 0.48;
690
+ return 1 - 0.04 * Math.sin(t * Math.PI * 8) * (1 - t);
691
+ };
692
+
693
+ // PunchCombo:拳击三连击——jab-jab-cross,第三拳最重最宽
694
+ const rhythmPunchCombo = (peak = 0.4) => {
695
+ const pattern = [
696
+ { c: 0.15, w: 0.04, a: 0.75 },
697
+ { c: 0.35, w: 0.04, a: 0.75 },
698
+ { c: 0.7, w: 0.055, a: 1.0 },
699
+ ];
700
+ return (k) => {
701
+ if (k <= 0 || k >= 1) return 0;
702
+ let sum = 0;
703
+ for (const { c, w, a } of pattern) {
704
+ sum += a * Math.exp(-((k - c) ** 2) / (2 * w * w));
705
+ }
706
+ return peak * sum;
707
+ };
708
+ };
709
+
710
+ // Staccato:断奏——均匀节拍内 duty 占空比 sin 脉冲
711
+ const rhythmStaccato = (beats = 4, duty = 0.3) => (k) => {
712
+ if (k <= 0 || k >= 1) return 0;
713
+ const beatLen = 1 / beats;
714
+ const phase = (k / beatLen) - Math.floor(k / beatLen);
715
+ if (phase > duty) return 0;
716
+ const t = phase / duty;
717
+ return Math.sin(t * Math.PI);
718
+ };
719
+
720
+ // Kick:极限单击——瞬速冲到 peak,之后强指数衰减
721
+ const rhythmKick = (peak = 1.2) => (k) => {
722
+ if (k <= 0 || k >= 1) return 0;
723
+ if (k < 0.05) return peak * k / 0.05;
724
+ const t = (k - 0.05) / 0.95;
725
+ return peak * Math.exp(-4 * t);
726
+ };
727
+
728
+ // Crescendo:渐强——N 次高斯峰,间距递减、幅度递增
729
+ const rhythmCrescendo = (beats = 4) => {
730
+ const centers = [];
731
+ for (let i = 0; i < beats; i++) {
732
+ const t = Math.pow((i + 1) / beats, 1.4);
733
+ centers.push({ c: Math.max(0.05, t - 0.08), w: 0.03, a: (i + 1) / beats });
734
+ }
735
+ return (k) => {
736
+ if (k <= 0 || k >= 1) return 0;
737
+ let sum = 0;
738
+ for (const { c, w, a } of centers) {
739
+ sum += a * Math.exp(-((k - c) ** 2) / (2 * w * w));
740
+ }
741
+ return sum;
742
+ };
743
+ };
744
+
745
+ // DunDunDun:悬疑递进——3 击幅度递增,末击更宽形成持续感
746
+ const rhythmDunDunDun = () => {
747
+ const bell = (t, c, w) => Math.exp(-((t - c) ** 2) / (2 * w * w));
748
+ return (k) => {
749
+ if (k <= 0 || k >= 1) return 0;
750
+ return 0.3 * bell(k, 0.15, 0.025)
751
+ + 0.6 * bell(k, 0.35, 0.03)
752
+ + 1.0 * bell(k, 0.68, 0.09);
753
+ };
754
+ };
755
+
756
+ // BellToll:钟声——瞬间起振 + 指数衰减调幅的余弦振荡
757
+ const rhythmBellToll = (decay = 3, freq = 8) => {
758
+ const strike = 0.05;
759
+ return (k) => {
760
+ if (k <= 0 || k >= 1) return 0;
761
+ if (k < strike) return k / strike;
762
+ const t = k - strike;
763
+ return Math.exp(-decay * t) * Math.cos(freq * Math.PI * t);
764
+ };
765
+ };
766
+
767
+ const Rhythm = Object.freeze({
768
+ BassDrop: rhythmBassDrop(),
769
+ PunchCombo: rhythmPunchCombo(),
770
+ Staccato: rhythmStaccato(),
771
+ Kick: rhythmKick(),
772
+ Crescendo: rhythmCrescendo(),
773
+ DunDunDun: rhythmDunDunDun(),
774
+ BellToll: rhythmBellToll(),
775
+ });
776
+
777
+ // ─── §17 UI 反馈 ───────────────────────────────────────────────────────────
778
+
779
+ // ClickSnap:按钮点击——压下(负偏移)→ 回弹微过冲 → 归零
780
+ const uiClickSnap = (pressDepth = 0.3, reboundPeak = 0.1) => (k) => {
781
+ if (k <= 0 || k >= 1) return 0;
782
+ if (k < 0.2) {
783
+ const t = k / 0.2;
784
+ return -pressDepth * Math.sin(t * Math.PI / 2);
785
+ }
786
+ if (k < 0.5) {
787
+ const t = (k - 0.2) / 0.3;
788
+ return -pressDepth + (pressDepth + reboundPeak) * (1 - Math.pow(1 - t, 3));
789
+ }
790
+ const t = (k - 0.5) / 0.5;
791
+ return reboundPeak * Math.exp(-4 * t) * Math.cos(t * Math.PI * 3);
792
+ };
793
+
794
+ // HoverBloom:悬停高亮——梯形包络(快升 → plateau → 快降)
795
+ const uiHoverBloom = (riseRatio = 0.2, fallRatio = 0.3) => (k) => {
796
+ if (k <= 0 || k >= 1) return 0;
797
+ if (k < riseRatio) {
798
+ const t = k / riseRatio;
799
+ return 1 - Math.pow(1 - t, 3);
800
+ }
801
+ if (k < 1 - fallRatio) return 1;
802
+ const t = (k - (1 - fallRatio)) / fallRatio;
803
+ return Math.pow(1 - t, 3);
804
+ };
805
+
806
+ // ErrorShake:错误反馈——方波化高频 shake
807
+ const uiErrorShake = (amplitude = 0.15, count = 5) => (k) => {
808
+ if (k <= 0 || k >= 1) return 0;
809
+ const env = 1 - k;
810
+ const raw = Math.sin(k * Math.PI * 2 * count);
811
+ const clipped = Math.sign(raw) * Math.min(1, Math.abs(raw) * 1.8);
812
+ return amplitude * env * clipped;
813
+ };
814
+
815
+ // SuccessPop:成功庆祝——瞬速 scale 到 1.2 → 阻尼余弦回到 1
816
+ const uiSuccessPop = (overshoot = 0.2) => (k) => {
817
+ if (k <= 0) return 0;
818
+ if (k >= 1) return 1;
819
+ if (k < 0.4) {
820
+ const t = k / 0.4;
821
+ return (1 + overshoot) * (1 - Math.pow(1 - t, 2));
822
+ }
823
+ const t = (k - 0.4) / 0.6;
824
+ return 1 + overshoot * Math.exp(-5 * t) * Math.cos(t * Math.PI * 3);
825
+ };
826
+
827
+ // RippleOut:Material 点击涟漪——早峰后淡出
828
+ const uiRippleOut = () => (k) => {
829
+ if (k <= 0 || k >= 1) return 0;
830
+ return 6.75 * k * Math.pow(1 - k, 2);
831
+ };
832
+
833
+ const UI = Object.freeze({
834
+ ClickSnap: uiClickSnap(),
835
+ HoverBloom: uiHoverBloom(),
836
+ ErrorShake: uiErrorShake(),
837
+ SuccessPop: uiSuccessPop(),
838
+ RippleOut: uiRippleOut(),
839
+ });
840
+
841
+ // ─── §18 Magic 能量 / 魔法 ─────────────────────────────────────────────────
842
+
843
+ // ManaCharge:魔法蓄能——指数积蓄 + 高频 pulses
844
+ const magicManaCharge = () => (k) => {
845
+ if (k <= 0) return 0;
846
+ if (k >= 1) return 1;
847
+ const base = (Math.exp(3 * k) - 1) / (Math.exp(3) - 1);
848
+ const pulse = 0.04 * Math.sin(k * Math.PI * 8) * k;
849
+ return base + pulse;
850
+ };
851
+
852
+ // SpellCast:施法——蓄能 + 瞬冲 1 + 拖尾衰减
853
+ const magicSpellCast = (chargeEnd = 0.4) => (k) => {
854
+ if (k <= 0 || k >= 1) return 0;
855
+ if (k < chargeEnd) {
856
+ const t = k / chargeEnd;
857
+ return 0.3 * Math.pow(t, 2) * (1 + 0.2 * Math.sin(t * Math.PI * 6));
858
+ }
859
+ if (k < chargeEnd + 0.1) {
860
+ const t = (k - chargeEnd) / 0.1;
861
+ return 0.3 + 0.7 * t;
862
+ }
863
+ const t = (k - chargeEnd - 0.1) / (1 - chargeEnd - 0.1);
864
+ return Math.exp(-2 * t) * (1 + 0.1 * Math.cos(t * Math.PI * 4));
865
+ };
866
+
867
+ // Teleport:瞬移——加速压缩 → 完全消失(平顶 1)→ 加速重现
868
+ const magicTeleport = () => (k) => {
869
+ if (k <= 0 || k >= 1) return 0;
870
+ if (k < 0.45) {
871
+ const t = k / 0.45;
872
+ return t * t * t;
873
+ }
874
+ if (k < 0.55) return 1;
875
+ const t = (k - 0.55) / 0.45;
876
+ return Math.pow(1 - t, 3);
877
+ };
878
+
879
+ // Shield:护盾——波纹扩散过冲到 1.2 → 稳定到 1 → 微脉动
880
+ const magicShield = () => (k) => {
881
+ if (k <= 0) return 0;
882
+ if (k >= 1) return 1;
883
+ if (k < 0.3) {
884
+ const t = k / 0.3;
885
+ return 1.2 * (1 - Math.pow(1 - t, 2));
886
+ }
887
+ if (k < 0.6) {
888
+ const t = (k - 0.3) / 0.3;
889
+ return 1.2 - 0.2 * t;
890
+ }
891
+ const t = (k - 0.6) / 0.4;
892
+ return 1 + 0.03 * Math.sin(t * Math.PI * 3);
893
+ };
894
+
895
+ // MagicAura:魔法光环——基频 + 2 次谐波 + 3 次泛音的正弦叠加
896
+ const magicAura = (peak = 0.15) => (k) => {
897
+ if (k <= 0 || k >= 1) return 0;
898
+ const env = Math.sin(k * Math.PI);
899
+ const fundamental = 0.6 * Math.sin(k * Math.PI * 2);
900
+ const harmonic = 0.3 * Math.sin(k * Math.PI * 4 + 1);
901
+ const overtone = 0.1 * Math.sin(k * Math.PI * 6 + 2);
902
+ return peak * env * (fundamental + harmonic + overtone);
903
+ };
904
+
905
+ const Magic = Object.freeze({
906
+ ManaCharge: magicManaCharge(),
907
+ SpellCast: magicSpellCast(),
908
+ Teleport: magicTeleport(),
909
+ Shield: magicShield(),
910
+ MagicAura: magicAura(),
911
+ });
912
+
913
+ // ─── §19 Animal 动物动作 ───────────────────────────────────────────────────
914
+
915
+ // CatPounce:猫扑击——蹲伏蓄力 + 起跳 + 空中抛物线 + 落地微压
916
+ const animalCatPounce = () => (k) => {
917
+ if (k <= 0) return 0;
918
+ if (k >= 1) return 1;
919
+ if (k < 0.2) {
920
+ const t = k / 0.2;
921
+ return -0.2 * Math.sin(t * Math.PI);
922
+ }
923
+ if (k < 0.3) {
924
+ const t = (k - 0.2) / 0.1;
925
+ return 0.5 * t * t;
926
+ }
927
+ if (k < 0.8) {
928
+ const t = (k - 0.3) / 0.5;
929
+ return 0.5 + 0.5 * t + 0.2 * Math.sin(t * Math.PI);
930
+ }
931
+ const t = (k - 0.8) / 0.2;
932
+ return 1 + 0.05 * Math.sin(t * Math.PI);
933
+ };
934
+
935
+ // BirdFlap:翅膀拍打——不对称基波(下扑快、上挥慢)+ sin 包络
936
+ const animalBirdFlap = (flaps = 4) => (k) => {
937
+ if (k <= 0 || k >= 1) return 0;
938
+ const env = Math.sin(k * Math.PI);
939
+ const phase = k * Math.PI * 2 * flaps;
940
+ const wave = Math.sin(phase) - 0.3 * Math.sin(phase * 2);
941
+ return 0.2 * env * wave;
942
+ };
943
+
944
+ // SnakeSlither:蛇蜿蜒——连续 S 波
945
+ const animalSnakeSlither = (waves = 3) => (k) => {
946
+ if (k <= 0 || k >= 1) return 0;
947
+ const env = Math.sin(k * Math.PI);
948
+ const wave = Math.sin(k * Math.PI * 2 * waves);
949
+ return 0.2 * env * wave;
950
+ };
951
+
952
+ // ButterflyFlit:蝴蝶乱飞——seed 可复现的随机采样 + cubic 平滑插值
953
+ const animalButterflyFlit = (seed = 13) => {
954
+ let s = seed;
955
+ const rand = () => { s = (s * 9301 + 49297) % 233280; return s / 233280; };
956
+ const samples = [];
957
+ for (let i = 0; i <= 26; i++) samples.push(rand() - 0.5);
958
+ return (k) => {
959
+ if (k <= 0 || k >= 1) return 0;
960
+ const env = Math.sin(k * Math.PI);
961
+ const pos = k * 25;
962
+ const idx = Math.floor(pos);
963
+ const t = pos - idx;
964
+ const smooth = t * t * (3 - 2 * t);
965
+ const interp = samples[idx] + (samples[idx + 1] - samples[idx]) * smooth;
966
+ return 0.3 * env * interp;
967
+ };
968
+ };
969
+
970
+ // HorseGallop:马奔驰——每周期 4 蹄击地 + 空中相位间隙
971
+ const animalHorseGallop = (cycles = 3) => (k) => {
972
+ if (k <= 0 || k >= 1) return 0;
973
+ const env = Math.sin(k * Math.PI);
974
+ const cyclePos = (k * cycles) - Math.floor(k * cycles);
975
+ const bell = (c, w = 0.04) => Math.exp(-((cyclePos - c) ** 2) / (2 * w * w));
976
+ return 0.25 * env * (bell(0.0) + bell(0.18) + bell(0.36) + bell(0.54));
977
+ };
978
+
979
+ const Animal = Object.freeze({
980
+ CatPounce: animalCatPounce(),
981
+ BirdFlap: animalBirdFlap(),
982
+ SnakeSlither: animalSnakeSlither(),
983
+ ButterflyFlit: animalButterflyFlit(),
984
+ HorseGallop: animalHorseGallop(),
985
+ });
986
+
987
+ // ─── 导出(形态分类:Progress / Pulse / Wave) ─────────────────────────────
988
+ //
989
+ // 上方各主题常量(Physics / Motion / Step / Attention / Breath / Heart /
990
+ // MathExt / Explosion / Nature / Impact / Rhythm / UI / Magic / Animal)
991
+ // 及业界库 factory(libSpring / libSteps / libHeartBeat)仅作为
992
+ // "源池"使用,不再作为顶层导出;由下列 Progress / Pulse / Wave 三个按形态
993
+ // 分类的命名空间统一暴露。
994
+ //
995
+ // 通用 UI 柔化(Smooth / Bezier 两组共 6 条命名曲线)已整组移除——数值上
996
+ // 与原生 Sinusoidal/Quadratic/Cubic 等价;需定制贝塞尔请直接调用顶层
997
+ // cubicBezier('Material.Standard' | x1,y1,x2,y2) 工厂。
998
+
999
+ // Progress —— 单调或衰减至 1 的曲线(A→B 过渡)
1000
+ const Progress = Object.freeze({
1001
+ // Physics:原生 + Spring(Framer Motion 参数化弹簧)
1002
+ Physics: Object.freeze({
1003
+ ...Physics, // SpringSoft / SpringStiff / DampedOscillation
1004
+ Spring: libSpring(), // Framer Motion 风格默认弹簧
1005
+ }),
1006
+ Motion, // Anticipate / Overshoot110 / Overshoot125 / SnapBack / Swing
1007
+ // Step:固定段数实例 —— Steps4/6/8/12End 覆盖实用区间,无任意段数工厂
1008
+ Step: Object.freeze({
1009
+ ...Step, // Steps4End / Steps8End / Steps12End
1010
+ Steps6: libSteps(),
1011
+ }),
1012
+ Math: Object.freeze({
1013
+ Tremor: MathExt.Tremor,
1014
+ }),
1015
+ Impact: Object.freeze({
1016
+ Rain: Impact.Rain,
1017
+ Hammer: Impact.Hammer,
1018
+ BounceDrop: Impact.BounceDrop,
1019
+ ArrowHit: Impact.ArrowHit,
1020
+ Shatter: Impact.Shatter,
1021
+ }),
1022
+ Rhythm: Object.freeze({
1023
+ BassDrop: Rhythm.BassDrop,
1024
+ }),
1025
+ UI: Object.freeze({
1026
+ SuccessPop: UI.SuccessPop,
1027
+ }),
1028
+ Magic: Object.freeze({
1029
+ ManaCharge: Magic.ManaCharge,
1030
+ Shield: Magic.Shield,
1031
+ }),
1032
+ Animal: Object.freeze({
1033
+ CatPounce: Animal.CatPounce,
1034
+ }),
1035
+ });
1036
+
1037
+ // Pulse —— 单次返零脉冲(f(0)=f(1)=0, 单主峰;reversals ≤ 2 为主)
1038
+ const Pulse = Object.freeze({
1039
+ Attention: Object.freeze({
1040
+ Ping: Attention.Ping,
1041
+ }),
1042
+ Breath: Object.freeze({
1043
+ Deep: Breath.Deep,
1044
+ Sigh: Breath.Sigh,
1045
+ }),
1046
+ Heart: Object.freeze({
1047
+ Calm: Heart.Calm,
1048
+ }),
1049
+ Math: Object.freeze({
1050
+ JumpArc: MathExt.JumpArc, // 对称抛物 4k(1-k)
1051
+ BoomerangSharp: mathBoomerang(E.Cubic.In), // 尖峰回程:缓→冲到峰→缓回(峰值锐利)
1052
+ BoomerangSoft: mathBoomerang(E.Cubic.Out), // 平顶回程:快→在峰上停留→快回(峰值平滑)
1053
+ }),
1054
+ Explosion: Object.freeze({
1055
+ Impulse: Explosion.Impulse,
1056
+ Flash: Explosion.Flash,
1057
+ Recoil: Explosion.Recoil,
1058
+ Implosion: Explosion.Implosion,
1059
+ }),
1060
+ Impact: Object.freeze({
1061
+ Slap: Impact.Slap,
1062
+ }),
1063
+ Rhythm: Object.freeze({
1064
+ Kick: Rhythm.Kick,
1065
+ }),
1066
+ UI: Object.freeze({
1067
+ ClickSnap: UI.ClickSnap,
1068
+ HoverBloom: UI.HoverBloom,
1069
+ RippleOut: UI.RippleOut,
1070
+ }),
1071
+ Magic: Object.freeze({
1072
+ SpellCast: Magic.SpellCast,
1073
+ Teleport: Magic.Teleport,
1074
+ }),
1075
+ });
1076
+
1077
+ // Wave —— 周期多峰振荡(f(0)=f(1)=0, 多次反转)
1078
+ const Wave = Object.freeze({
1079
+ Attention: Object.freeze({
1080
+ Wiggle: Attention.Wiggle,
1081
+ Strum: Attention.Strum,
1082
+ }),
1083
+ Breath: Object.freeze({
1084
+ Normal: Breath.Normal,
1085
+ Panting: Breath.Panting,
1086
+ }),
1087
+ Heart: Object.freeze({
1088
+ Excited: Heart.Excited,
1089
+ LubDub: Heart.LubDub,
1090
+ Beat: libHeartBeat(), // 迁移自 Lib.HeartBeat
1091
+ }),
1092
+ Math: Object.freeze({
1093
+ Pendulum: MathExt.Pendulum,
1094
+ }),
1095
+ Nature, // Wave / Flicker / Gust
1096
+ Rhythm: Object.freeze({
1097
+ PunchCombo: Rhythm.PunchCombo,
1098
+ Staccato: Rhythm.Staccato,
1099
+ Crescendo: Rhythm.Crescendo,
1100
+ DunDunDun: Rhythm.DunDunDun,
1101
+ BellToll: Rhythm.BellToll,
1102
+ }),
1103
+ UI: Object.freeze({
1104
+ ErrorShake: UI.ErrorShake,
1105
+ }),
1106
+ Magic: Object.freeze({
1107
+ MagicAura: Magic.MagicAura,
1108
+ }),
1109
+ Animal: Object.freeze({
1110
+ BirdFlap: Animal.BirdFlap,
1111
+ SnakeSlither: Animal.SnakeSlither,
1112
+ ButterflyFlit: Animal.ButterflyFlit,
1113
+ HorseGallop: Animal.HorseGallop,
1114
+ }),
1115
+ });
1116
+
1117
+ const customEasings = Object.freeze({
1118
+ makeOutIn,
1119
+ OutIn,
1120
+ Progress,
1121
+ Pulse,
1122
+ Wave,
1123
+ cubicBezier,
1124
+ });
1125
+
1126
+ exports.customEasings = customEasings;
1127
+ exports.default = customEasings;
scripts/7681318995261132040/AmazingFeature/js/ThreeJS/scriptScene.js ADDED
@@ -0,0 +1,800 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * 场景核心模块
3
+ *
4
+ * 包含Three.js核心对象的创建和管理
5
+ * 提供场景管理的核心功能:初始化、配置和更新
6
+ */
7
+
8
+ // ThreeJS Env
9
+ // 导入TWEEN库
10
+ // const TWEEN = require('../lib/tween');
11
+ // 导入Three.js库
12
+ // const THREE = require('three');
13
+
14
+
15
+ // Effect Env
16
+ // 导入TWEEN库
17
+ const TWEEN = require('./tween');
18
+ // 导入自定义缓动函数库(OutIn 模式等官方未提供的组合)
19
+ const customEasings = require('./customEasings').customEasings;
20
+ // 导入Three.js 的 wrapper库
21
+ const THREE = require('./three-amg-wrapper').THREE;
22
+ const { ShaderPass } = require('./ShaderPass.js');
23
+ /**
24
+ * ScriptScene类 - 3D场景管理器
25
+ * 负责创建和管理Three.js场景、相机、渲染器及场景对象
26
+ */
27
+ class ScriptScene {
28
+ /**
29
+ * 构造函数,创建场景管理器
30
+ * @param {effect.Amaz.Scene} [amgScene] - AMG场景对象,可选参数
31
+ * @param {HTMLElement} [container] - 放置渲染器的DOM容器,可选参数
32
+ */
33
+ constructor(amgScene = null, container = null) {
34
+ // 核心对象初始化
35
+ if (amgScene) {
36
+ this.scene = new THREE.Scene();
37
+ this.scene._amgScene = amgScene;
38
+ } else {
39
+ this.scene = new THREE.Scene();
40
+ }
41
+ this.effect_type = "transition";
42
+ this.camera = null;
43
+ this.renderer = null;
44
+ this.scene.background = new THREE.Color(0x333333);
45
+ this.isAnimating = false;
46
+ this.animationFrameId = null;
47
+ this.sceneObjects = null;
48
+
49
+ this.texture1 = null;
50
+ this.texture2 = null;
51
+
52
+ // 后处理相关属性
53
+ this.composer = null;
54
+ this.renderPass = null;
55
+ this.usePostProcessing = true; // 是否启用后处理效果
56
+
57
+ // 初始化核心对象和基本场景
58
+ this.initCoreObjects();
59
+ if (container) {
60
+ this.init(container);
61
+ }
62
+ }
63
+
64
+ /**
65
+ * 析构函数,清理场景并释放资源
66
+ * 在不再需要场景时调用,确保正确释放内存和停止动画循环
67
+ */
68
+ destroy() {
69
+ // 停止动画循环
70
+ this.isAnimating = false;
71
+
72
+ // 取消动画帧请求
73
+ if (this.animationFrameId !== null && typeof cancelAnimationFrame !== 'undefined') {
74
+ cancelAnimationFrame(this.animationFrameId);
75
+ this.animationFrameId = null;
76
+ }
77
+
78
+ // 清理渲染器
79
+ if (this.renderer) {
80
+ this.renderer.setAnimationLoop(null);
81
+ this.renderer.dispose();
82
+
83
+ // 移除渲染器的DOM元素
84
+ if (this.renderer.domElement && this.renderer.domElement.parentNode) {
85
+ this.renderer.domElement.parentNode.removeChild(this.renderer.domElement);
86
+ }
87
+ }
88
+
89
+ // 清理纹理资源
90
+ if (this.texture1) {
91
+ if (typeof this.texture1.dispose === "function") this.texture1.dispose();
92
+ this.texture1 = null;
93
+ }
94
+ if (this.texture2) {
95
+ if (typeof this.texture2.dispose === "function") this.texture2.dispose();
96
+ this.texture2 = null;
97
+ }
98
+
99
+
100
+
101
+ // 清理场景中的对象
102
+ if (this.scene) {
103
+ this.scene.dispose();
104
+ }
105
+
106
+ // 移除窗口事件监听器
107
+ if (typeof window !== 'undefined') {
108
+ window.removeEventListener('resize', this.handleResize);
109
+ }
110
+
111
+ // 清理TWEEN动画
112
+ if (this.sceneObjects && this.sceneObjects.tweens) {
113
+ this.sceneObjects.tweens.forEach(tween => {
114
+ if (tween && typeof tween.stop === 'function') {
115
+ tween.stop();
116
+ }
117
+ });
118
+ this.sceneObjects.tweens = [];
119
+ }
120
+
121
+ // 清理多pass
122
+ if (this.shaderPasses && this.shaderPasses.length) {
123
+ this.shaderPasses.forEach((pass) => {
124
+ if (pass && typeof pass.dispose === "function") {
125
+ try {
126
+ pass.dispose();
127
+ } catch (e) {}
128
+ }
129
+ });
130
+ this.shaderPasses = [];
131
+ }
132
+ if (this.shaderPass && typeof this.shaderPass.dispose === "function") {
133
+ try {
134
+ this.shaderPass.dispose();
135
+ } catch (e) {}
136
+ }
137
+ this.shaderPass = null;
138
+ // 清理后处理效果
139
+ if (this.composer) {
140
+ this.composer.dispose();
141
+ this.composer = null;
142
+ }
143
+
144
+ this.renderPass = null;
145
+
146
+ // 清理引用
147
+ this.scene = null;
148
+ this.camera = null;
149
+ this.renderer = null;
150
+ this.sceneObjects = null;
151
+ }
152
+
153
+ /**
154
+ * 初始化Three.js核心对象
155
+ * 包括场景、相机和渲染器
156
+ */
157
+ initCoreObjects() {
158
+ if (typeof window !== "undefined") {
159
+ if (!window.innerWidth || !window.innerHeight) {
160
+ window.innerWidth = 600;
161
+ window.innerHeight = 600;
162
+ }
163
+ window.devicePixelRatio = window.devicePixelRatio || 1;
164
+ if (this.scene && this.scene._amgScene && this.scene._amgScene.assetMgr) {
165
+ const inputTexture = this.scene._amgScene.assetMgr.SyncLoad("share://input.texture");
166
+ if (inputTexture && inputTexture.width > 0 && inputTexture.height > 0) {
167
+ window.innerWidth = inputTexture.width;
168
+ window.innerHeight = inputTexture.height;
169
+ }
170
+ }
171
+ }
172
+ this.camera = new THREE.PerspectiveCamera(
173
+ 53.1, // 视场角
174
+ window.innerWidth / window.innerHeight, // 纵横比
175
+ 0.1, // 近平面
176
+ 10000 // 远平面
177
+ );
178
+ this.camera.position.z = 10; // 设置默认相机位置
179
+ this.scene.add(this.camera);
180
+
181
+ // 创建渲染器,启用抗锯齿
182
+ // 当amgScene为null时,创建渲染器
183
+ if (this.scene._amgScene == null)
184
+ {
185
+ this.renderer = new THREE.WebGLRenderer({ antialias: true });
186
+ this.renderer.outputColorSpace = THREE.LinearSRGBColorSpace;
187
+ }
188
+ if (this.renderer)
189
+ {
190
+ this.renderer.setSize(window.innerWidth, window.innerHeight);
191
+ this.renderer.setPixelRatio(window.devicePixelRatio);
192
+ }
193
+
194
+ // 滑竿列表
195
+ this.sliders = {};
196
+
197
+ // 创建TWEEN实例
198
+ this.TWEEN = TWEEN;
199
+ // 自定义缓动函数库:使用方式 this.customEasings.OutIn.Back 等
200
+ this.customEasings = customEasings;
201
+
202
+ // 时长 毫秒
203
+ this.Duration = 2000;
204
+ }
205
+
206
+ /**
207
+ * 添加ShaderPass
208
+ * @param {Array} shaderPassConfigs - ShaderPass配置数组
209
+ * @return {void}
210
+ */
211
+ addShaderPass(shaderPassConfigs) {
212
+ if (!Array.isArray(shaderPassConfigs)) {
213
+ shaderPassConfigs = [shaderPassConfigs];
214
+ }
215
+
216
+ shaderPassConfigs.forEach(config => {
217
+ const atomicName = config.name;
218
+ const className = atomicName.startsWith('Lumi') ? atomicName.substring(4) : atomicName;
219
+ const shaderPassModule = require('../pp/Lumi' + className + '/' + className + 'ShaderPass.js');
220
+ const ShaderPassClass = shaderPassModule[className + 'ShaderPass'];
221
+ const initConfig = (config && (config.initConfig || config.config || config.params)) || {};
222
+ const shaderPass = new ShaderPassClass(initConfig);
223
+ // console.log('ShaderPass created:', shaderPass, className);
224
+ this.composer.addPass(shaderPass);
225
+ this.shaderPasses.push(shaderPass);
226
+ });
227
+ }
228
+
229
+ /**
230
+ * 设置后处理
231
+ * @param {Array} shaderPassConfigs - ShaderPass配置数组
232
+ * @return {void}
233
+ */
234
+ setupPostProcessing(shaderPassConfigs) {
235
+ const { EffectComposer } = require('./EffectComposer.js');
236
+ const { RenderPass } = require('./RenderPass.js');
237
+
238
+ // 创建后处理渲染目标
239
+ this.composer = new EffectComposer(this.renderer);
240
+ this.renderPass = new RenderPass(this.scene, this.camera);
241
+ this.composer.addPass(this.renderPass);
242
+ this.shaderPasses = [];
243
+
244
+ this.addShaderPass(shaderPassConfigs);
245
+ }
246
+
247
+ //===begin_pp===
248
+ initPostProcessing() {}
249
+ //===end_pp===
250
+
251
+ /**
252
+ * 初始化场景
253
+ * 设置基本的Three.js环境,添加渲染器到DOM
254
+ * @param {HTMLElement} container - 放置渲染器的DOM容器
255
+ */
256
+ init(container) {
257
+ if (this.renderer) {
258
+ if (container) {
259
+ container.appendChild(this.renderer.domElement);
260
+ } else if (typeof document !== 'undefined') {
261
+ document.body.appendChild(this.renderer.domElement);
262
+ }
263
+ }
264
+ if (typeof window !== 'undefined') {
265
+ window.addEventListener('resize', () => this.handleResize());
266
+ }
267
+ }
268
+
269
+ /**
270
+ * 开始场景动画循环
271
+ * @param {Function} updateCallback - 每帧调用的更新函数
272
+ */
273
+ start(updateCallback) {
274
+ if (this.isAnimating) return;
275
+
276
+ this.isAnimating = true;
277
+
278
+ // 如果提供了更新回调,使用requestAnimationFrame
279
+ if (updateCallback) {
280
+ const animateFrame = () => {
281
+ if (!this.isAnimating) return;
282
+ updateCallback();
283
+ this.animationFrameId = requestAnimationFrame(animateFrame);
284
+ };
285
+
286
+ animateFrame();
287
+ } else {
288
+ // 否则使用Three.js的setAnimationLoop,直接调用update渲染场景
289
+ this.renderer.setAnimationLoop(() => {
290
+ this.update();
291
+ });
292
+ }
293
+ }
294
+
295
+
296
+
297
+ /**
298
+ * 更新场景(由外部动画循环调用)
299
+ * @param {number} timestamp - 当前时间戳
300
+ */
301
+ updateScene(timestamp) {
302
+ // 标记动画开始
303
+ if (!this.isAnimating) {
304
+ this.isAnimating = true;
305
+ }
306
+
307
+ // 直接调用默认更新函数,传入时间戳
308
+ this.defaultUpdate(timestamp);
309
+ }
310
+
311
+ /**
312
+ * 更新并渲染场景
313
+ * 在每一帧调用,将当前场景通过渲染器绘制到屏幕
314
+ */
315
+ update() {
316
+ if (this.usePostProcessing && this.composer) {
317
+ // 确保composer使用当前活动的相机
318
+ if (this.renderPass) {
319
+ this.renderPass.camera = this.camera;
320
+ }
321
+
322
+ // 使用后处理效果渲染
323
+ this.composer.render();
324
+ } else if (this.renderer) {
325
+ // 直接渲染场景
326
+ this.renderer.render(this.scene, this.camera);
327
+ }
328
+ }
329
+
330
+ /**
331
+ * 窗口大小调整处理
332
+ * 在窗口大小变化时调整相机和渲染器
333
+ */
334
+ handleResize() {
335
+ this.camera.aspect = window.innerWidth / window.innerHeight;
336
+ this.camera.updateProjectionMatrix();
337
+ if (this.renderer) {
338
+ this.renderer.setSize(window.innerWidth, window.innerHeight);
339
+ }
340
+
341
+ // 调整后处理效果的大小
342
+ // if (this.composer) {
343
+ // this.composer.setSize(window.innerWidth, window.innerHeight);
344
+ // }
345
+
346
+ // 如果不在动画循环中,触发一次渲染以更新视图
347
+ if (!this.isAnimating) {
348
+ this.update();
349
+ }
350
+ }
351
+
352
+ loadTextures() {
353
+ const textureLoader = new THREE.TextureLoader();
354
+ return Promise.all([
355
+ new Promise(resolve => {
356
+ this.texture1 = textureLoader.load('image/Sample1.jpg', resolve);
357
+ this.texture1.colorSpace = THREE.LinearSRGBColorSpace;
358
+ this.texture1.wrapS = THREE.RepeatWrapping;
359
+ this.texture1.wrapT = THREE.RepeatWrapping;
360
+ }),
361
+ new Promise(resolve => {
362
+ this.texture2 = textureLoader.load('image/Sample2.jpg', resolve);
363
+ this.texture2.colorSpace = THREE.LinearSRGBColorSpace;
364
+ this.texture2.wrapS = THREE.RepeatWrapping;
365
+ this.texture2.wrapT = THREE.RepeatWrapping;
366
+ })
367
+ ]);
368
+ }
369
+
370
+ _applyTweenInitialState(tween) {
371
+ if (!tween._propertiesAreSetUp) {
372
+ tween.start(0);
373
+ }
374
+ if (!tween._valuesStart || !tween._valuesEnd) {
375
+ return;
376
+ }
377
+ tween._updateProperties(tween._object, tween._valuesStart, tween._valuesEnd, 0);
378
+ if (typeof tween._onUpdateCallback === 'function') {
379
+ tween._onUpdateCallback(tween._object, 0);
380
+ }
381
+ }
382
+
383
+ _applyTweenFinalState(tween) {
384
+ if (!tween._propertiesAreSetUp) {
385
+ tween.start(0);
386
+ }
387
+ if (!tween._valuesStart || !tween._valuesEnd) {
388
+ return;
389
+ }
390
+ tween._updateProperties(tween._object, tween._valuesStart, tween._valuesEnd, 1);
391
+ if (typeof tween._onUpdateCallback === 'function') {
392
+ tween._onUpdateCallback(tween._object, 1);
393
+ }
394
+ }
395
+
396
+ /**
397
+ * 根据时间直接设置动画状态(用于时间跳转)
398
+ * @param {number} time - 动画时间(毫秒)
399
+ */
400
+ seekToTime(time) {
401
+ // 标记动画开始
402
+ if (!this.isAnimating) {
403
+ this.isAnimating = true;
404
+ }
405
+
406
+ // 限制时间范围
407
+ const clampedTime = Math.max(0, Math.min(time, this.Duration));
408
+
409
+ // seek ShaderPass后处理逻辑,该函数已预先定义,无需生成_predef_seekShaderPass实现
410
+ if (this._predef_seekShaderPass)
411
+ {
412
+ this._predef_seekShaderPass(clampedTime);
413
+ }
414
+
415
+ if (!this.sceneObjects.tweens || this.sceneObjects.tweens.length === 0) {
416
+ return;
417
+ }
418
+
419
+ // 使用逆序遍历 TWEEN,确保正确的属性覆盖优先级
420
+ // 逆序处理:让开始时间晚的tween先处理,开始时间早的tween后处理并覆盖
421
+
422
+ let notStartTweens = [];
423
+ let runningTweens = [];
424
+ let finishedTweens = [];
425
+
426
+ for (let i = 0; i <= this.sceneObjects.tweens.length - 1; i++) {
427
+ const tween = this.sceneObjects.tweens[i];
428
+
429
+ let TweenStartTime = tween._delayTime + 10;
430
+ let TweenEndTime = tween._delayTime + tween._duration;
431
+
432
+ // 将tween分为三种,未开始,进行中,已结束
433
+ // 分到3个列表中
434
+
435
+ if (clampedTime <= TweenStartTime) {
436
+ notStartTweens.push({time: TweenStartTime, tween: tween});
437
+ }
438
+ else if (clampedTime >= TweenEndTime) {
439
+ finishedTweens.push({time: TweenEndTime, tween: tween});
440
+ }
441
+ else
442
+ {
443
+ runningTweens.push(tween);
444
+ }
445
+ }
446
+
447
+ // 按照开始时间排序
448
+ notStartTweens.sort((a, b) => b.time - a.time);
449
+ // 按照结束时间排序
450
+ finishedTweens.sort((a, b) => a.time - b.time);
451
+
452
+ notStartTweens.forEach(item => {
453
+ this._applyTweenInitialState(item.tween);
454
+ });
455
+
456
+ finishedTweens.forEach(item => {
457
+ this._applyTweenFinalState(item.tween);
458
+ });
459
+
460
+ runningTweens.forEach(tween => {
461
+ tween.stop();
462
+ tween.start(0);
463
+ tween.update(clampedTime);
464
+ });
465
+
466
+ this.update();
467
+ }
468
+
469
+ //===begin===
470
+ //===滑竿begin===
471
+ //===滑竿end===
472
+ /**
473
+ * 初始化滑竿
474
+ */
475
+ setupSliders(){
476
+ }
477
+
478
+ /**
479
+ * 更新滑竿
480
+ */
481
+ updateSliders(){
482
+ }
483
+
484
+ /**
485
+ * 初始化一个完整的基本场景(不包含动画循环)
486
+ * 包括相机、场景对象的创建和特效材质
487
+ * @returns {Object} 场景中的对象引用
488
+ */
489
+ setupScene() {
490
+ // 初始化场景对象容器
491
+ this.initSceneObjects();
492
+
493
+ // 更新滑竿
494
+ this.setupSliders();
495
+ this.updateSliders();
496
+
497
+ // 设置场景背景为黑色
498
+ this.scene.background = new THREE.Color(0x000000);
499
+
500
+ // 创建效果平面
501
+ this.createPlane();
502
+
503
+ // 设置动画
504
+ this.setupAnimation();
505
+
506
+ return this.sceneObjects;
507
+ }
508
+
509
+ /**
510
+ * 初始化场景对象容器
511
+ */
512
+ initSceneObjects() {
513
+ this.sceneObjects = {
514
+ plane: null, // 主平面对象
515
+ material: null, // 效果材质
516
+ tweens: [] // 动画对象数组
517
+ };
518
+ }
519
+
520
+ /**
521
+ * 创建效果平面
522
+ */
523
+ createPlane() {
524
+ // 创建平面几何体,宽高比为1:1
525
+ const geometry = new THREE.PlaneGeometry(10, 10, 100, 1);
526
+
527
+ // 使用自定义着色器材质实现扫描线效果
528
+ const material = this.createMaterial();
529
+ this.sceneObjects.material = material;
530
+
531
+ // 创建��片
532
+ const plane = new THREE.Mesh(geometry, material);
533
+ plane.name = "Plane";
534
+ this.sceneObjects.plane = plane;
535
+
536
+ // 将面片添加到场景
537
+ this.scene.add(plane);
538
+ }
539
+
540
+ /**
541
+ * 创建效果平面的着色器材质
542
+ * @returns {THREE.ShaderMaterial} 效果平面着色器材质
543
+ */
544
+ createMaterial() {
545
+ // 确保纹理已加载
546
+ if (!this.texture1 || !this.texture2) {
547
+ console.error("纹理未加载!");
548
+ return new THREE.MeshBasicMaterial({ color: 0xff0000 });
549
+ }
550
+
551
+ // 为纹理设置适当的参数
552
+ this.texture1.minFilter = THREE.LinearFilter;
553
+ this.texture1.magFilter = THREE.LinearFilter;
554
+ this.texture1.wrapS = THREE.ClampToEdgeWrapping;
555
+ this.texture1.wrapT = THREE.ClampToEdgeWrapping;
556
+
557
+ this.texture2.minFilter = THREE.LinearFilter;
558
+ this.texture2.magFilter = THREE.LinearFilter;
559
+ this.texture2.wrapS = THREE.ClampToEdgeWrapping;
560
+ this.texture2.wrapT = THREE.ClampToEdgeWrapping;
561
+
562
+ // 创建自定义着色器材质
563
+ this.shaderPass = new (require('../pp/LumiCustom/CustomShaderPass.js').CustomShaderPass)();
564
+ var material = this.shaderPass.material;
565
+ // 传入默认纹理
566
+ material.uniforms.tDiffuse.value = this.texture1;
567
+ material.uniforms.tDiffuse1.value = this.texture2;
568
+ return material;
569
+ }
570
+
571
+ /**
572
+ * 设置动画
573
+ */
574
+ setupAnimation() {
575
+ if (!this.shaderPass) {
576
+ console.error("着色器传递对象未创建!");
577
+ return;
578
+ }
579
+ if (typeof this.shaderPass.setParameter !== 'function') {
580
+ console.error(`${this.shaderPass.constructor.name} 中没有 setParameter 方法`);
581
+ return;
582
+ }
583
+
584
+ const duration = this.Duration; // 使用已定义的持续时间
585
+ const tweens = [];
586
+ this.sceneObjects.tweens = [];
587
+
588
+ // 创建从0到1的动画
589
+ const tween1 = new TWEEN.Tween({ intensity: 0, progress: 0 })
590
+ .to({ intensity: 1, progress: 0.5 }, duration * 0.35)
591
+ .delay(duration * 0.15)
592
+ .easing(TWEEN.Easing.Linear.None)
593
+ .onUpdate((obj) => {
594
+ // 遍历obj中的所有属性,自动设置参数
595
+ for (const key in obj) {
596
+ this.shaderPass.setParameter(key, obj[key]);
597
+ }
598
+ });
599
+
600
+ // 创建从1到0的动画
601
+ const tween2 = new TWEEN.Tween({ intensity: 1, progress: 0.5 })
602
+ .to({ intensity: 0, progress: 1 }, duration * 0.35)
603
+ .delay(duration * 0.5)
604
+ .easing(TWEEN.Easing.Linear.None)
605
+ .onUpdate((obj) => {
606
+ // 遍历obj中的所有属性,自动设置参数
607
+ for (const key in obj) {
608
+ this.shaderPass.setParameter(key, obj[key]);
609
+ }
610
+ });
611
+
612
+ tweens.push(tween1, tween2);
613
+
614
+ // 启动所有动画
615
+ tweens.forEach(tween => tween.start());
616
+
617
+ // 存储动画对象引用
618
+ if (tweens.length > 0) {
619
+ if (!this.sceneObjects.tweens) {
620
+ this.sceneObjects.tweens = [];
621
+ }
622
+ this.sceneObjects.tweens.push(...tweens);
623
+ }
624
+ }
625
+ //===end===
626
+
627
+ /**
628
+ * 默认的场景更新函数,实现轨道交错转场动画
629
+ */
630
+ defaultUpdate(timestamp) {
631
+ // 更新所有TWEEN动画
632
+ if (this.sceneObjects.tweens && this.sceneObjects.tweens.length > 0) {
633
+ this.sceneObjects.tweens.forEach(tween => {
634
+ if (tween && typeof tween.update === 'function') {
635
+ tween.update(timestamp);
636
+ }
637
+ });
638
+ }
639
+
640
+ this.update();
641
+ }
642
+
643
+ //===Predefined Function Begin===
644
+ _predef_addTopCenterBottomStyleBorder(parent, offset, texture, cutoutAreaPosition, cutoutAreaSize) {
645
+ const aspectRatio = this.texture1.image.width / this.texture1.image.height;
646
+ const parentInitScale = parent.scale.y;
647
+ const parentPosition = parent.position;
648
+ const textureWidth = texture.image.width;
649
+ const textureHeight = texture.image.height;
650
+ const geometry = new THREE.PlaneGeometry(10, 10);
651
+
652
+ // center
653
+ const textureCenter = texture.clone();
654
+ textureCenter.repeat.set(1, cutoutAreaSize.y / textureHeight);
655
+ textureCenter.offset.set(0, (textureHeight - cutoutAreaPosition.y - cutoutAreaSize.y) / textureHeight);
656
+
657
+ const materialCenter = new THREE.MeshBasicMaterial({
658
+ map: textureCenter,
659
+ transparent: true,
660
+ opacity: 1,
661
+ premultipliedAlpha: true,
662
+ side: THREE.DoubleSide
663
+ });
664
+ materialCenter.name = 'PlaneCenterMaterial';
665
+
666
+ const planeCenter = new THREE.Mesh(geometry, materialCenter);
667
+ planeCenter.name = 'PlaneCenter';
668
+ planeCenter.position.set(parentPosition.x + offset.x, parentPosition.y + offset.y, parentPosition.z + offset.z);
669
+ planeCenter.scale.set(parentInitScale * aspectRatio / (cutoutAreaSize.x / textureWidth), parentInitScale, 1);
670
+
671
+ this.scene.add(planeCenter);
672
+ parent.attach(planeCenter);
673
+
674
+ // top
675
+ const textureTop = texture.clone();
676
+ textureTop.repeat.set(1, cutoutAreaPosition.y / textureHeight);
677
+ textureTop.offset.set(0, 1 - cutoutAreaPosition.y / textureHeight);
678
+
679
+ const materialTop = new THREE.MeshBasicMaterial({
680
+ map: textureTop,
681
+ transparent: true,
682
+ opacity: 1,
683
+ premultipliedAlpha: true,
684
+ side: THREE.DoubleSide
685
+ });
686
+ materialTop.name = 'PlaneTopMaterial';
687
+
688
+ const scaleXTop = parentInitScale * aspectRatio / (cutoutAreaSize.x / textureWidth);
689
+ const scaleYTop = scaleXTop * cutoutAreaPosition.y / textureWidth;
690
+
691
+ const planeTop = new THREE.Mesh(geometry, materialTop);
692
+ planeTop.name = 'PlaneTop';
693
+ planeTop.position.set(parentPosition.x + offset.x, parentPosition.y + offset.y + parentInitScale * 10 * 0.5 + scaleYTop * 10 * 0.5, parentPosition.z + offset.z);
694
+ planeTop.scale.set(scaleXTop, scaleYTop, 1);
695
+
696
+ this.scene.add(planeTop);
697
+ parent.attach(planeTop);
698
+
699
+ // bottom
700
+ const textureBottom = texture.clone();
701
+ textureBottom.repeat.set(1, (textureHeight - cutoutAreaPosition.y - cutoutAreaSize.y) / textureHeight);
702
+ textureBottom.offset.set(0, 0);
703
+
704
+ const materialBottom = new THREE.MeshBasicMaterial({
705
+ map: textureBottom,
706
+ transparent: true,
707
+ opacity: 1,
708
+ premultipliedAlpha: true,
709
+ side: THREE.DoubleSide
710
+ });
711
+ materialBottom.name = 'PlaneBottomMaterial';
712
+
713
+ const scaleXBottom = parentInitScale * aspectRatio / (cutoutAreaSize.x / textureWidth);
714
+ const scaleYBottom = scaleXBottom * (textureHeight - cutoutAreaPosition.y - cutoutAreaSize.y) / textureWidth;
715
+
716
+ const planeBottom = new THREE.Mesh(geometry, materialBottom);
717
+ planeBottom.name = 'PlaneBottom';
718
+ planeBottom.position.set(parentPosition.x + offset.x, parentPosition.y + offset.y - parentInitScale * 10 * 0.5 - scaleYBottom * 10 * 0.5, parentPosition.z + offset.z);
719
+ planeBottom.scale.set(scaleXBottom, scaleYBottom, 1);
720
+
721
+ this.scene.add(planeBottom);
722
+ parent.attach(planeBottom);
723
+ }
724
+ _predef_loadVideoTexture(path, loop, playbackRate) {
725
+ if (this.scene._amgScene == null) {
726
+ const video = document.createElement('video');
727
+ video.src = path;
728
+ video.muted = true;
729
+ video.loop = loop;
730
+ //video.play();
731
+ video.load();
732
+
733
+ // video.style.position = 'absolute';
734
+ // video.style.top = '400px';
735
+ // video.style.left = '0px';
736
+ // video.style.width = '480px';
737
+ // video.style.height = '360px';
738
+ // video.style.zIndex = '100';
739
+ // document.body.appendChild(video);
740
+
741
+ const videoTexture = new THREE.VideoTexture(video);
742
+ videoTexture.currentTime = 0;
743
+ videoTexture.playbackRate = playbackRate;
744
+
745
+ this.videoTexture = videoTexture;
746
+
747
+ return videoTexture;
748
+ } else if (typeof this.scene._amgScene === 'string') {
749
+ return new THREE.Texture();
750
+ } else {
751
+ const texture = new THREE.VideoTexture(path, loop, playbackRate);
752
+ texture.load();
753
+ return texture;
754
+ }
755
+ }
756
+ _predef_seekVideoTexture(time) {
757
+ if (this.videoTexture != null) {
758
+ const videoTexture = this.videoTexture;
759
+ const video = videoTexture.image;
760
+ if (video.readyState >= 2) {
761
+ const textureProperties = this.renderer.properties.get(videoTexture);
762
+ var newTime = time / 1000 * videoTexture.playbackRate;
763
+ if (newTime < 0) {
764
+ newTime = 0;
765
+ } else if (newTime > video.duration) {
766
+ if (video.loop) {
767
+ newTime = newTime % video.duration;
768
+ } else {
769
+ newTime = video.duration;
770
+ }
771
+ }
772
+ if (textureProperties.__version == videoTexture.version) {
773
+ videoTexture.currentTime = newTime;
774
+ video.currentTime = videoTexture.currentTime;
775
+ }
776
+ }
777
+ }
778
+ }
779
+ _predef_seekShaderPass(time) {
780
+ if (!('shaderPasses' in this) || this.shaderPasses == null) {
781
+ return;
782
+ }
783
+ this.shaderPasses.forEach(shaderPass => {
784
+ if (shaderPass.constructor.name === 'AnimSeqLoadAndCropBlendShaderPass') {
785
+ if (this.texture1 && this.texture1.image) {
786
+ const ratio = this.texture1.image.width / this.texture1.image.height;
787
+ if (typeof shaderPass.setAspectRatio === 'function') {
788
+ shaderPass.setAspectRatio(ratio);
789
+ }
790
+ }
791
+ }
792
+ })
793
+ }//===Predefined Function End===
794
+ }
795
+
796
+ // 导入Three.js库
797
+ // module.exports = ScriptScene;
798
+
799
+ // 导入Three.js 的 wrapper库
800
+ exports.ScriptScene = ScriptScene;