diff --git a/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/ShaderPass.js b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/ShaderPass.js new file mode 100644 index 0000000000000000000000000000000000000000..53e789f5ab728356060ddab3581334dcfaaa967b --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/ShaderPass.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/scriptScene.js b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/scriptScene.js new file mode 100644 index 0000000000000000000000000000000000000000..5d5f0a8bde54f7efa0912b77bb0a8298e3fb04e9 --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/scriptScene.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/three-amg-wrapper.js b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/three-amg-wrapper.js new file mode 100644 index 0000000000000000000000000000000000000000..c2037e314e032c4d36912923d4cc1258cba3ab19 --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/three-amg-wrapper.js @@ -0,0 +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;iobj.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; \ No newline at end of file diff --git a/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/tween.js b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/tween.js new file mode 100644 index 0000000000000000000000000000000000000000..690fb9e4284728629129deed5a5a3f4bcec291ed --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/tween.js @@ -0,0 +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=power1e4?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;_i0){this._tweensAddedDuringUpdate={};for(var i=0;i1){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[m1;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;itotalTime){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;ithis.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;ithis.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.xthis.max.x||box.max.ythis.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; \ No newline at end of file diff --git a/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Box3.js b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Box3.js new file mode 100644 index 0000000000000000000000000000000000000000..4100dc7442d3a622827c8a415e24557f68c491f1 --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Box3.js @@ -0,0 +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=3?array[offset+2]:0;if(xthis.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=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.xthis.max.x||box.max.ythis.max.y||box.max.zthis.max.z)}}exports.Box3=Box3; \ No newline at end of file diff --git a/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..be3b8b1334a62f5e88c45feee098063a199fca55 --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js @@ -0,0 +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=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; \ No newline at end of file diff --git a/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..af9a8a13a46500e78f082a35e18d0b5932061234 --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js @@ -0,0 +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;iObject.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;i1?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; \ No newline at end of file diff --git a/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Constants.js b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Constants.js new file mode 100644 index 0000000000000000000000000000000000000000..6b8adda19a4d67236719804f5170889b39fd4582 --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Constants.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js new file mode 100644 index 0000000000000000000000000000000000000000..29b0aad5599401be17f967ba1d48851acb70c2ac --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js @@ -0,0 +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;i0||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;i0?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;imaxX)maxX=p.x;if(p.ymaxY)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; \ No newline at end of file diff --git a/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..f3dee08bf1c089e040fcfef228902ab9a39c93cb --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Earcut.js b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Earcut.js new file mode 100644 index 0000000000000000000000000000000000000000..953abffdf38c2def26df73fed180eff8c7644ced --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Earcut.js @@ -0,0 +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;imaxX)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=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=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.x&&p.x>=mx&&hx!==p.x&&pointInTriangle(hym.x||p.x===m.x&§orContainsSector(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.xb.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;i0||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=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;i0){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;imaxX)maxX=contour[i].x;if(contour[i].ymaxY)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;layerIdx0?-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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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; \ No newline at end of file diff --git a/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Group.js b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Group.js new file mode 100644 index 0000000000000000000000000000000000000000..90c4dbef65aa04d7a3bb6b6d76ec3317ea65a228 --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Group.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");class Group extends Object3D{constructor(name="Group_w"){super(name)}dispose(){super.dispose()}}exports.Group=Group; \ No newline at end of file diff --git a/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Material.js b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Material.js new file mode 100644 index 0000000000000000000000000000000000000000..81b97053ad9d1e4b1ef05d5ac6ed992487b2ca8e --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Material.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..dcf34d4cffb9de0869382a24690f78f60dda6049 --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js new file mode 100644 index 0000000000000000000000000000000000000000..41e6cd0a0eee7dd7bc497be5deac584806b68dc3 --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Mesh.js b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Mesh.js new file mode 100644 index 0000000000000000000000000000000000000000..254d69b074e797dd34c16d7dad723bbcc3b4895d --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Mesh.js @@ -0,0 +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;imaterial,set:value=>{material=value;if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;im.dispose&&m.dispose());else if(this.material.dispose)this.material.dispose()}}}exports.MeshWrapper=MeshWrapper; \ No newline at end of file diff --git a/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..ac394f66efc4e113a7127ee0f50ec672e4c5e9eb --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Object3D.js b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Object3D.js new file mode 100644 index 0000000000000000000000000000000000000000..8532c6122f839460aab34fe88957802ff523318b --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Object3D.js @@ -0,0 +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{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&¤tScene._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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js new file mode 100644 index 0000000000000000000000000000000000000000..ba39801de50d38ec04424f3c2ebfa2ff5d28fded --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js @@ -0,0 +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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..bc595fb80ad9e7c2f4d8360c67dbef556f3d6cbe --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js @@ -0,0 +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;iy0){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; \ No newline at end of file diff --git a/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..02dc1be955bc766de744222a7e75c65bf147bb61 --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js @@ -0,0 +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&¶meters.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{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=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=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=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; \ No newline at end of file diff --git a/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Shape.js b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Shape.js new file mode 100644 index 0000000000000000000000000000000000000000..ecde48b5ceb30812c922aa5c7cfe2aa7b50cabe4 --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Shape.js @@ -0,0 +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;i0){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;i0||(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;imaxX)maxX=p.x;if(p.ymaxY)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;i0?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;ipoints.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;itwoPi)deltaAngle-=twoPi;if(deltaAngle>4;uuid[i]=chars[i===19?r&3|8:r]}}return uuid.join("")}exports.Shape=Shape; \ No newline at end of file diff --git a/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..3786abc7d64ed80b56101c4ac9d30ce9fcb8f941 --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js @@ -0,0 +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;i0){const bounds=calculateBounds(flatVertices);const vertexOffset=vertices.length/3;for(let j=0;j0){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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}function calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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; \ No newline at end of file diff --git a/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..1ea27a55fbce9fc3771c66840c068e5ff6347092 --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Texture.js b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Texture.js new file mode 100644 index 0000000000000000000000000000000000000000..35bff49d732c9884e07bfcb5682f18a860485e1f --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Texture.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Vector2.js b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Vector2.js new file mode 100644 index 0000000000000000000000000000000000000000..a30a2431264ee62cec937714dfa9e50932ddedeb --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/ThreeJS/wrapper/Vector2.js @@ -0,0 +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)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)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) { + if (k <= 0) return 0; + if (k >= 1) return 1; + return 1 - Math.exp(-6 * k) * Math.cos(12 * k); +}; + +// 欠阻尼弹簧(硬):更高频振荡、更慢收敛 +const springStiff = (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return 1 - Math.exp(-5 * k) * Math.cos(18 * k); +}; + +// 阻尼振荡:sin 基波收尾抖动 +const dampedOscillation = (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return 1 - Math.exp(-5 * k) * Math.cos(10 * k); +}; + +const Physics = Object.freeze({ + SpringSoft: springSoft, + SpringStiff: springStiff, + DampedOscillation: dampedOscillation, +}); + +// ─── §4 Motion 动作设计系 ────────────────────────────────────────────────── + +// 先回拉 10% 再冲向终点:蓄力动作 +const anticipate = (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + const pullback = 0.1; + if (k < 0.3) { + const p = k / 0.3; + return -pullback * p * (2 - p); // easeOutQuad 到 -pullback + } + const p = (k - 0.3) / 0.7; + return -pullback + (1 + pullback) * p * p * (3 - 2 * p); // smoothstep 到 1 +}; + +// 冲到 peak 再回到 1 的工厂 +const overshootFactory = (peak) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.6) { + const p = k / 0.6; + return peak * p * (2 - p); // easeOutQuad 到 peak + } + const p = (k - 0.6) / 0.4; + return peak + (1 - peak) * (1 - Math.pow(1 - p, 3)); // easeOutCubic 到 1 +}; + +const overshoot110 = overshootFactory(1.10); +const overshoot125 = overshootFactory(1.25); + +// 快速到位(前 60% 冲到 1.05),后 40% 回到 1:磁吸、卡扣 +const snapBack = (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.6) { + const p = k / 0.6; + return 1.05 * (1 - Math.pow(1 - p, 3)); + } + const p = (k - 0.6) / 0.4; + return 1.05 - 0.05 * p * p * (3 - 2 * p); +}; + +// 摆锤式:一次轻微过冲后收敛 +const swing = (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return 1 - Math.cos(1.5 * Math.PI * k) * Math.exp(-2.5 * k); +}; + +const Motion = Object.freeze({ + Anticipate: anticipate, + Overshoot110: overshoot110, + Overshoot125: overshoot125, + SnapBack: snapBack, + Swing: swing, +}); + +// ─── §5 Step 步进系 ──────────────────────────────────────────────────────── + +/** + * CSS steps() 等价工厂。 + * @param {number} n 段数 + * @param {'start' | 'end'} jumpTerm 跳变在每段的起始还是结束(默认 'end') + */ +const makeStep = (n, jumpTerm = 'end') => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (jumpTerm === 'start') return Math.ceil(k * n) / n; + return Math.floor(k * n) / n; +}; + +const Step = Object.freeze({ + Steps4End: makeStep(4, 'end'), + Steps8End: makeStep(8, 'end'), + Steps12End: makeStep(12, 'end'), +}); + +// ─── §6 Bezier 规范贝塞尔 ────────────────────────────────────────────────── + +/** + * 给定两个控制点 (x1,y1) 与 (x2,y2),P0=(0,0) P3=(1,1)。 + * 返回函数 f(t) -> y,其中 t 是输入时间(需先用牛顿法从 x 反解 s)。 + */ +function buildCubicBezier(x1, y1, x2, y2) { + const cx = 3 * x1, bx = 3 * (x2 - x1) - cx, ax = 1 - cx - bx; + const cy = 3 * y1, by = 3 * (y2 - y1) - cy, ay = 1 - cy - by; + const sampleX = (s) => ((ax * s + bx) * s + cx) * s; + const sampleY = (s) => ((ay * s + by) * s + cy) * s; + const sampleDX = (s) => (3 * ax * s + 2 * bx) * s + cx; + + const solveS = (x) => { + let s = x; + for (let i = 0; i < 8; i++) { + const cur = sampleX(s) - x; + if (Math.abs(cur) < 1e-6) return s; + const d = sampleDX(s); + if (Math.abs(d) < 1e-6) break; + s -= cur / d; + if (s < 0) s = 0; + if (s > 1) s = 1; + } + // 兜底二分 + let lo = 0, hi = 1; + for (let i = 0; i < 32 && hi - lo > 1e-6; i++) { + const mid = (lo + hi) / 2; + if (sampleX(mid) < x) lo = mid; else hi = mid; + } + return (lo + hi) / 2; + }; + + return (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return sampleY(solveS(k)); + }; +} + +// 贝塞尔白名单:(x1, y1, x2, y2) +const BEZIER_PRESETS = Object.freeze({ + 'Material.Standard': [0.4, 0, 0.2, 1], + 'Material.Accelerate': [0.4, 0, 1, 1], + 'Material.Decelerate': [0, 0, 0.2, 1], + 'CSS.Ease': [0.25, 0.1, 0.25, 1], +}); + +// 工厂 memoization(避免同参数重复构造) +const _bezierCache = new Map(); +function _cachedBezier(x1, y1, x2, y2) { + const key = x1 + ',' + y1 + ',' + x2 + ',' + y2; + let fn = _bezierCache.get(key); + if (!fn) { + fn = buildCubicBezier(x1, y1, x2, y2); + _bezierCache.set(key, fn); + } + return fn; +} + +/** + * cubicBezier('Material.Standard') | cubicBezier(x1, y1, x2, y2) + * 直写参数受控域:x1/x2 ∈ [0,1],y1/y2 ∈ [-0.5, 1.5] + */ +function cubicBezier(a, b, c, d) { + if (typeof a === 'string') { + let preset = BEZIER_PRESETS[a]; + if (!preset) { + console.warn('[customEasings.cubicBezier] unknown preset, falling back to Material.Standard:', a); + preset = BEZIER_PRESETS['Material.Standard']; + } + return _cachedBezier(preset[0], preset[1], preset[2], preset[3]); + } + // 数值入口:裁剪到允许域 + const clamp = (v, lo, hi) => Math.max(lo, Math.min(hi, v)); + const x1 = clamp(a, 0, 1); + const y1 = clamp(b, -0.5, 1.5); + const x2 = clamp(c, 0, 1); + const y2 = clamp(d, -0.5, 1.5); + return _cachedBezier(x1, y1, x2, y2); +} + +// 命名贝塞尔实例已整组移除:Material/CSS 预设与原生 Sinusoidal/Quadratic/Cubic +// 数值上几乎等价,特殊场景请直接调用 cubicBezier('Material.Standard') 等工厂。 + +// ═══════════════════════════════════════════════════════════════════════════ +// 扩展分组(与已有 6 组并列,不污染既有命名空间) +// ═══════════════════════════════════════════════════════════════════════════ + +// ─── §7 业界库扩展(已并入 Physics / Step / Heart) ───────────────────────── +// 以下工厂原本聚合在 Lib.* 命名空间下,现已按语义归入相应主题: +// Spring (Framer Motion) → Progress.Physics.Spring +// Steps (GSAP) → Progress.Step.Steps6 +// HeartBeat → Wave.Heart.Beat +// 退役:Framer Motion 的 Anticipate / GSAP 的 Overshoot factory(由 Motion.* +// 覆盖);GSAP ExpoScale / Unity SmoothDamp(数值上与原生 Sinusoidal/Quadratic +// 等价,已整组移除)。 + +// Spring(Framer Motion 风格):参数化弹簧,离散积分 +const libSpring = ({ stiffness = 180, damping = 12, mass = 1 } = {}) => { + const DT = 1 / 240; + const T = 1.5; + let x = 0, v = 0; + const samples = []; + for (let t = 0; t <= T; t += DT) { + const force = -stiffness * (x - 1) - damping * v; + v += (force / mass) * DT; + x += v * DT; + samples.push({ t, x }); + } + let T_end = T; + for (let i = samples.length - 1; i >= 0; i--) { + if (Math.abs(samples[i].x - 1) > 0.01) { T_end = samples[i].t; break; } + } + return (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + const t = k * T_end; + const idx = Math.min(samples.length - 1, Math.floor(t / DT)); + return samples[idx].x; + }; +}; + +// HeartBeat(简易版):两高斯峰的绝对值轨迹 +const libHeartBeat = (peak = 0.3) => (k) => { + if (k <= 0 || k >= 1) return 0; + const bell = (t, c) => Math.exp(-((t - c) ** 2) / (2 * 0.07 * 0.07)); + return peak * (bell(k, 0.2) + bell(k, 0.5)); +}; + +// Steps(GSAP SteppedEase 风格 factory):离散 N 段阶梯(默认 n=6) +const libSteps = (n = 6) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return Math.floor(k * n) / n; +}; + +// ─── §8 Attention 注意力 / 抖振 ──────────────────────────────────────────── + +// Ping:单次衰减脉冲(雷达 ping),sin(π·k) × exp(-decay·k) +const attentionPing = (peak = 0.35, decay = 2) => (k) => { + if (k <= 0 || k >= 1) return 0; + return peak * Math.sin(Math.PI * k) * Math.exp(-decay * k); +}; + +// Wiggle:衰减正弦振荡(easing 值本身,非位置增量) +const attentionWiggle = (count = 4, amplitude = 0.25) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = 1 - k; + return amplitude * env * Math.sin(k * Math.PI * 2 * count); +}; + +// Strum:多峰衰减(吉他拨弦) +const attentionStrum = (notes = 4, peak = 0.4) => { + const centers = []; + for (let i = 0; i < notes; i++) { + centers.push({ c: 0.15 + i * (0.7 / Math.max(1, notes - 1)), a: Math.pow(0.72, i) }); + } + return (k) => { + if (k <= 0 || k >= 1) return 0; + let sum = 0; + for (const { c, a } of centers) { + sum += a * Math.exp(-((k - c) ** 2) / (2 * 0.05 * 0.05)); + } + return peak * sum; + }; +}; + +const Attention = Object.freeze({ + Ping: attentionPing(), + Wiggle: attentionWiggle(), + Strum: attentionStrum(), +}); + +// ─── §9 Breath 呼吸 ──────────────────────────────────────────────────────── + +// Normal:慢节奏正弦呼吸 +const breathNormal = (cycles = 2, peak = 0.15) => (k) => { + if (k <= 0 || k >= 1) return 0; + return peak * Math.sin(k * Math.PI * 2 * cycles) * Math.sin(k * Math.PI); +}; + +// Deep:深呼吸——慢吸气 → hold → 慢呼气 +const breathDeep = (peak = 0.3, riseRatio = 0.35, holdRatio = 0.15) => { + const holdEnd = riseRatio + holdRatio; + return (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < riseRatio) { + const t = k / riseRatio; + return peak * Math.sin(t * Math.PI / 2); + } + if (k < holdEnd) { + return peak; + } + const t = (k - holdEnd) / (1 - holdEnd); + return peak * Math.cos(t * Math.PI / 2); + }; +}; + +// Panting:急促浅呼吸——多次小幅起伏 + 正弦包络 +const breathPanting = (cycles = 6, peak = 0.08) => (k) => { + if (k <= 0 || k >= 1) return 0; + const envelope = Math.sin(k * Math.PI); + const wave = 0.5 + 0.5 * Math.sin(k * Math.PI * 2 * cycles - Math.PI / 2); + return peak * envelope * wave; +}; + +// Sigh:叹息——快速吸气后慢速释放 +const breathSigh = (peak = 0.25, riseRatio = 0.2) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < riseRatio) { + const t = k / riseRatio; + return peak * Math.sin(t * Math.PI / 2); + } + const t = (k - riseRatio) / (1 - riseRatio); + return peak * (1 - t) * (1 - t); +}; + +const Breath = Object.freeze({ + Normal: breathNormal(), + Deep: breathDeep(), + Panting: breathPanting(), + Sigh: breathSigh(), +}); + +// ─── §10 Heart 心跳 ──────────────────────────────────────────────────────── + +// Calm:单次舒缓心跳——单高斯峰 +const heartCalm = (peak = 0.25, center = 0.35, width = 0.1) => (k) => { + if (k <= 0 || k >= 1) return 0; + return peak * Math.exp(-((k - center) ** 2) / (2 * width * width)); +}; + +// Excited:兴奋/紧张——密集快速心跳(N 连击) +const heartExcited = (beats = 4, peak = 0.3, width = 0.04) => { + const centers = []; + const span = 0.7; + for (let i = 0; i < beats; i++) { + centers.push(0.15 + i * (span / Math.max(1, beats - 1))); + } + return (k) => { + if (k <= 0 || k >= 1) return 0; + let sum = 0; + for (const c of centers) { + sum += Math.exp(-((k - c) ** 2) / (2 * width * width)); + } + return peak * sum; + }; +}; + +// LubDub:标准心跳「lub-dub」双音节 +const heartLubDub = (peak = 0.3) => (k) => { + if (k <= 0 || k >= 1) return 0; + const bell = (t, c, w) => Math.exp(-((t - c) ** 2) / (2 * w * w)); + // lub(S1):中心 0.25、宽 0.045、幅 1.0 + // dub(S2):中心 0.42、宽 0.03、幅 0.6 + return peak * (bell(k, 0.25, 0.045) + 0.6 * bell(k, 0.42, 0.03)); +}; + +const Heart = Object.freeze({ + Calm: heartCalm(), + Excited: heartExcited(), + LubDub: heartLubDub(), +}); + +// ─── §11 Math 物理 / 数学 ───────────────────────────────────────────────── + +// JumpArc:抛物线轨迹 4k(1-k) +const mathJumpArc = () => (k) => { + if (k <= 0 || k >= 1) return 0; + return 4 * k * (1 - k); +}; + +// Pendulum:物理摆——sin(πk) 包络的衰减余弦,端点归零(满足 Wave 契约 f(0)=f(1)=0) +const mathPendulum = (damping = 3, freq = 2.5) => (k) => { + if (k <= 0 || k >= 1) return 0; + return Math.sin(k * Math.PI) * Math.exp(-damping * k) * Math.cos(freq * Math.PI * k); +}; + +// Tremor:持续高频小幅抖动(不衰减),整体沿 Linear 进行 +const mathTremor = (amplitude = 0.04, freq = 22) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return k + amplitude * Math.sin(k * Math.PI * 2 * freq); +}; + +// Boomerang 包装器:把任意 easing 包装成 0→1→0(先去再回)。 +// 仅作为内部辅助使用,不暴露为公共曲线——常用变体已预实例化为 +// Pulse.Math.BoomerangSharp / BoomerangSoft(见 Pulse 命名空间)。 +const mathBoomerang = (fn) => (k) => { + if (k <= 0 || k >= 1) return 0; + return k < 0.5 ? fn(k * 2) : fn(2 - k * 2); +}; + +const MathExt = Object.freeze({ + JumpArc: mathJumpArc(), + Pendulum: mathPendulum(), + Tremor: mathTremor(), +}); + +// ─── §12 Explosion 爆炸 ──────────────────────────────────────────────────── + +// Impulse:指数脉冲响应 k·e^(1-k·sharpness)(减线性尾项使 k=1 归 0) +const explosionImpulse = (sharpness = 6) => { + const tail = sharpness * Math.exp(1 - sharpness); + return (k) => { + if (k <= 0 || k >= 1) return 0; + const h = sharpness * k; + return h * Math.exp(1 - h) - tail * k; + }; +}; + +// Flash:瞬间拉满 + 指数衰减到 0 +const explosionFlash = (rise = 0.05, decay = 5) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < rise) return k / rise; + return Math.exp(-decay * (k - rise)); +}; + +// Recoil:爆炸反冲——负向冲击 -1 + 阻尼振荡 +const explosionRecoil = (decay = 4, freq = 3) => (k) => { + if (k <= 0 || k >= 1) return 0; + return -Math.exp(-decay * k) * Math.cos(freq * Math.PI * k); +}; + +// Implosion:三段式——负向吸能 → 正向爆发 → 衰减归 0 +const explosionImplosion = (charge = 0.3, depth = 0.4, burstPeak = 1.2) => { + const sharp = 5; + const tail = sharp * Math.exp(1 - sharp); + return (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < charge) { + const t = k / charge; + return -depth * Math.sin(t * Math.PI / 2); + } + const t = (k - charge) / (1 - charge); + const h = sharp * t; + const wave = h * Math.exp(1 - h) - tail * t; + const settle = -depth * Math.pow(1 - t, 3); + return settle + burstPeak * wave; + }; +}; + +const Explosion = Object.freeze({ + Impulse: explosionImpulse(), + Flash: explosionFlash(), + Recoil: explosionRecoil(), + Implosion: explosionImplosion(), +}); + +// ─── §13 Cinema(已整组移除:Creep=k^3.5 与 Cubic.In/Quartic.In 数值等价) ─ + +// ─── §14 Nature 自然现象 ─────────────────────────────────────────────────── + +// Wave:海浪律动——多谐波叠加 + 整体正弦包络 +const natureWave = (cycles = 3, amplitude = 0.25) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const w = Math.sin(k * Math.PI * 2 * cycles) + + 0.5 * Math.sin(k * Math.PI * 2 * cycles * 1.5 + 1.2) + + 0.25 * Math.sin(k * Math.PI * 2 * cycles * 3 + 2.4); + return amplitude * env * w * 0.6; +}; + +// Flicker:火焰闪烁——伪随机采样 + 线性插值 + 正弦包络 +const natureFlicker = (rate = 15, intensity = 0.2, seed = 7) => { + let s = seed; + const rand = () => { s = (s * 9301 + 49297) % 233280; return s / 233280; }; + const samples = []; + for (let i = 0; i <= rate + 1; i++) samples.push(rand()); + return (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const pos = k * rate; + const idx = Math.floor(pos); + const t = pos - idx; + const a = samples[idx]; + const b = samples[idx + 1]; + const interp = a + (b - a) * t; + return intensity * env * (interp - 0.5) * 2; + }; +}; + +// Gust:风——N 次高斯阵风叠加 +const natureGust = (gusts = 3, peak = 0.25) => { + const centers = []; + const span = 0.7; + for (let i = 0; i < gusts; i++) { + centers.push(0.15 + i * (span / Math.max(1, gusts - 1))); + } + return (k) => { + if (k <= 0 || k >= 1) return 0; + let sum = 0; + for (const c of centers) { + sum += Math.exp(-((k - c) ** 2) / (2 * 0.08 * 0.08)); + } + return peak * sum / gusts * 1.8; + }; +}; + +const Nature = Object.freeze({ + Wave: natureWave(), + Flicker: natureFlicker(), + Gust: natureGust(), +}); + +// ─── §15 Impact 撞击 / 落地 ──────────────────────────────────────────────── + +// Rain:雨滴下落——重力加速段 + 撞击 + 小幅余震 +const impactRain = (impactAt = 0.7, rippleAmp = 0.08) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < impactAt) { + const t = k / impactAt; + return t * t; + } + const t = (k - impactAt) / (1 - impactAt); + return 1 + rippleAmp * Math.exp(-4 * t) * Math.sin(t * Math.PI * 6); +}; + +// Hammer:锤击——抬起蓄力(负值)→ 快速下击 → 微反弹 +const impactHammer = (liftDepth = 0.25) => { + const liftEnd = 0.35, strikeEnd = 0.6; + return (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < liftEnd) { + const t = k / liftEnd; + return -liftDepth * Math.sin(t * Math.PI); + } + if (k < strikeEnd) { + const t = (k - liftEnd) / (strikeEnd - liftEnd); + return t * t; + } + const t = (k - strikeEnd) / (1 - strikeEnd); + return 1 - 0.06 * Math.exp(-5 * t) * Math.sin(t * Math.PI * 4); + }; +}; + +// BounceDrop:下落 + 多次衰减反弹 +const impactBounceDrop = (bounces = 3, rebound = 0.25) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.4) { + const t = k / 0.4; + return t * t; + } + const t = (k - 0.4) / 0.6; + const env = Math.exp(-2.5 * t); + const wave = Math.abs(Math.sin(t * Math.PI * bounces)); + return 1 - env * wave * rebound; +}; + +// Slap:拍击——快速接触 + 短暂保持 + 快速撤回 +const impactSlap = (contactAt = 0.3, holdRatio = 0.1) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < contactAt) { + const t = k / contactAt; + return t * t; + } + if (k < contactAt + holdRatio) return 1; + const t = (k - contactAt - holdRatio) / (1 - contactAt - holdRatio); + return (1 - t) * (1 - t); +}; + +// ArrowHit:箭中靶——匀速飞行 + 命中 + 插入后高频振颤衰减 +const impactArrowHit = (impactAt = 0.5) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < impactAt) { + const t = k / impactAt; + return t * (0.7 + 0.3 * t); + } + const t = (k - impactAt) / (1 - impactAt); + const env = Math.exp(-5 * t); + const wave = Math.sin(t * Math.PI * 10); + return 1 + 0.1 * env * wave; +}; + +// Shatter:撞碎——下落 + 撞击 + 能量 impulse 爆发 + 回到 1 +const impactShatter = (impactAt = 0.55, burstAmp = 0.35) => { + const sharp = 5; + const tail = sharp * Math.exp(1 - sharp); + return (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < impactAt) { + const t = k / impactAt; + return t * t; + } + const t = (k - impactAt) / (1 - impactAt); + const h = sharp * t; + const impulseVal = h * Math.exp(1 - h) - tail * t; + return 1 + burstAmp * impulseVal; + }; +}; + +const Impact = Object.freeze({ + Rain: impactRain(), + Hammer: impactHammer(), + BounceDrop: impactBounceDrop(), + Slap: impactSlap(), + ArrowHit: impactArrowHit(), + Shatter: impactShatter(), +}); + +// ─── §16 Rhythm 节奏 / 冲击 ──────────────────────────────────────────────── + +// BassDrop:EDM 重拍——缓慢蓄力 → pause pre-drop → 瞬间掉到 1 → 持续并有微脉动 +const rhythmBassDrop = () => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.4) { + const t = k / 0.4; + return 0.4 * Math.pow(t, 2.5); + } + if (k < 0.48) { + const t = (k - 0.4) / 0.08; + return 0.4 - 0.2 * t; + } + if (k < 0.52) { + const t = (k - 0.48) / 0.04; + return 0.2 + 0.8 * t; + } + const t = (k - 0.52) / 0.48; + return 1 - 0.04 * Math.sin(t * Math.PI * 8) * (1 - t); +}; + +// PunchCombo:拳击三连击——jab-jab-cross,第三拳最重最宽 +const rhythmPunchCombo = (peak = 0.4) => { + const pattern = [ + { c: 0.15, w: 0.04, a: 0.75 }, + { c: 0.35, w: 0.04, a: 0.75 }, + { c: 0.7, w: 0.055, a: 1.0 }, + ]; + return (k) => { + if (k <= 0 || k >= 1) return 0; + let sum = 0; + for (const { c, w, a } of pattern) { + sum += a * Math.exp(-((k - c) ** 2) / (2 * w * w)); + } + return peak * sum; + }; +}; + +// Staccato:断奏——均匀节拍内 duty 占空比 sin 脉冲 +const rhythmStaccato = (beats = 4, duty = 0.3) => (k) => { + if (k <= 0 || k >= 1) return 0; + const beatLen = 1 / beats; + const phase = (k / beatLen) - Math.floor(k / beatLen); + if (phase > duty) return 0; + const t = phase / duty; + return Math.sin(t * Math.PI); +}; + +// Kick:极限单击——瞬速冲到 peak,之后强指数衰减 +const rhythmKick = (peak = 1.2) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < 0.05) return peak * k / 0.05; + const t = (k - 0.05) / 0.95; + return peak * Math.exp(-4 * t); +}; + +// Crescendo:渐强——N 次高斯峰,间距递减、幅度递增 +const rhythmCrescendo = (beats = 4) => { + const centers = []; + for (let i = 0; i < beats; i++) { + const t = Math.pow((i + 1) / beats, 1.4); + centers.push({ c: Math.max(0.05, t - 0.08), w: 0.03, a: (i + 1) / beats }); + } + return (k) => { + if (k <= 0 || k >= 1) return 0; + let sum = 0; + for (const { c, w, a } of centers) { + sum += a * Math.exp(-((k - c) ** 2) / (2 * w * w)); + } + return sum; + }; +}; + +// DunDunDun:悬疑递进——3 击幅度递增,末击更宽形成持续感 +const rhythmDunDunDun = () => { + const bell = (t, c, w) => Math.exp(-((t - c) ** 2) / (2 * w * w)); + return (k) => { + if (k <= 0 || k >= 1) return 0; + return 0.3 * bell(k, 0.15, 0.025) + + 0.6 * bell(k, 0.35, 0.03) + + 1.0 * bell(k, 0.68, 0.09); + }; +}; + +// BellToll:钟声——瞬间起振 + 指数衰减调幅的余弦振荡 +const rhythmBellToll = (decay = 3, freq = 8) => { + const strike = 0.05; + return (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < strike) return k / strike; + const t = k - strike; + return Math.exp(-decay * t) * Math.cos(freq * Math.PI * t); + }; +}; + +const Rhythm = Object.freeze({ + BassDrop: rhythmBassDrop(), + PunchCombo: rhythmPunchCombo(), + Staccato: rhythmStaccato(), + Kick: rhythmKick(), + Crescendo: rhythmCrescendo(), + DunDunDun: rhythmDunDunDun(), + BellToll: rhythmBellToll(), +}); + +// ─── §17 UI 反馈 ─────────────────────────────────────────────────────────── + +// ClickSnap:按钮点击——压下(负偏移)→ 回弹微过冲 → 归零 +const uiClickSnap = (pressDepth = 0.3, reboundPeak = 0.1) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < 0.2) { + const t = k / 0.2; + return -pressDepth * Math.sin(t * Math.PI / 2); + } + if (k < 0.5) { + const t = (k - 0.2) / 0.3; + return -pressDepth + (pressDepth + reboundPeak) * (1 - Math.pow(1 - t, 3)); + } + const t = (k - 0.5) / 0.5; + return reboundPeak * Math.exp(-4 * t) * Math.cos(t * Math.PI * 3); +}; + +// HoverBloom:悬停高亮——梯形包络(快升 → plateau → 快降) +const uiHoverBloom = (riseRatio = 0.2, fallRatio = 0.3) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < riseRatio) { + const t = k / riseRatio; + return 1 - Math.pow(1 - t, 3); + } + if (k < 1 - fallRatio) return 1; + const t = (k - (1 - fallRatio)) / fallRatio; + return Math.pow(1 - t, 3); +}; + +// ErrorShake:错误反馈——方波化高频 shake +const uiErrorShake = (amplitude = 0.15, count = 5) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = 1 - k; + const raw = Math.sin(k * Math.PI * 2 * count); + const clipped = Math.sign(raw) * Math.min(1, Math.abs(raw) * 1.8); + return amplitude * env * clipped; +}; + +// SuccessPop:成功庆祝——瞬速 scale 到 1.2 → 阻尼余弦回到 1 +const uiSuccessPop = (overshoot = 0.2) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.4) { + const t = k / 0.4; + return (1 + overshoot) * (1 - Math.pow(1 - t, 2)); + } + const t = (k - 0.4) / 0.6; + return 1 + overshoot * Math.exp(-5 * t) * Math.cos(t * Math.PI * 3); +}; + +// RippleOut:Material 点击涟漪——早峰后淡出 +const uiRippleOut = () => (k) => { + if (k <= 0 || k >= 1) return 0; + return 6.75 * k * Math.pow(1 - k, 2); +}; + +const UI = Object.freeze({ + ClickSnap: uiClickSnap(), + HoverBloom: uiHoverBloom(), + ErrorShake: uiErrorShake(), + SuccessPop: uiSuccessPop(), + RippleOut: uiRippleOut(), +}); + +// ─── §18 Magic 能量 / 魔法 ───────────────────────────────────────────────── + +// ManaCharge:魔法蓄能——指数积蓄 + 高频 pulses +const magicManaCharge = () => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + const base = (Math.exp(3 * k) - 1) / (Math.exp(3) - 1); + const pulse = 0.04 * Math.sin(k * Math.PI * 8) * k; + return base + pulse; +}; + +// SpellCast:施法——蓄能 + 瞬冲 1 + 拖尾衰减 +const magicSpellCast = (chargeEnd = 0.4) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < chargeEnd) { + const t = k / chargeEnd; + return 0.3 * Math.pow(t, 2) * (1 + 0.2 * Math.sin(t * Math.PI * 6)); + } + if (k < chargeEnd + 0.1) { + const t = (k - chargeEnd) / 0.1; + return 0.3 + 0.7 * t; + } + const t = (k - chargeEnd - 0.1) / (1 - chargeEnd - 0.1); + return Math.exp(-2 * t) * (1 + 0.1 * Math.cos(t * Math.PI * 4)); +}; + +// Teleport:瞬移——加速压缩 → 完全消失(平顶 1)→ 加速重现 +const magicTeleport = () => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < 0.45) { + const t = k / 0.45; + return t * t * t; + } + if (k < 0.55) return 1; + const t = (k - 0.55) / 0.45; + return Math.pow(1 - t, 3); +}; + +// Shield:护盾——波纹扩散过冲到 1.2 → 稳定到 1 → 微脉动 +const magicShield = () => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.3) { + const t = k / 0.3; + return 1.2 * (1 - Math.pow(1 - t, 2)); + } + if (k < 0.6) { + const t = (k - 0.3) / 0.3; + return 1.2 - 0.2 * t; + } + const t = (k - 0.6) / 0.4; + return 1 + 0.03 * Math.sin(t * Math.PI * 3); +}; + +// MagicAura:魔法光环——基频 + 2 次谐波 + 3 次泛音的正弦叠加 +const magicAura = (peak = 0.15) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const fundamental = 0.6 * Math.sin(k * Math.PI * 2); + const harmonic = 0.3 * Math.sin(k * Math.PI * 4 + 1); + const overtone = 0.1 * Math.sin(k * Math.PI * 6 + 2); + return peak * env * (fundamental + harmonic + overtone); +}; + +const Magic = Object.freeze({ + ManaCharge: magicManaCharge(), + SpellCast: magicSpellCast(), + Teleport: magicTeleport(), + Shield: magicShield(), + MagicAura: magicAura(), +}); + +// ─── §19 Animal 动物动作 ─────────────────────────────────────────────────── + +// CatPounce:猫扑击——蹲伏蓄力 + 起跳 + 空中抛物线 + 落地微压 +const animalCatPounce = () => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.2) { + const t = k / 0.2; + return -0.2 * Math.sin(t * Math.PI); + } + if (k < 0.3) { + const t = (k - 0.2) / 0.1; + return 0.5 * t * t; + } + if (k < 0.8) { + const t = (k - 0.3) / 0.5; + return 0.5 + 0.5 * t + 0.2 * Math.sin(t * Math.PI); + } + const t = (k - 0.8) / 0.2; + return 1 + 0.05 * Math.sin(t * Math.PI); +}; + +// BirdFlap:翅膀拍打——不对称基波(下扑快、上挥慢)+ sin 包络 +const animalBirdFlap = (flaps = 4) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const phase = k * Math.PI * 2 * flaps; + const wave = Math.sin(phase) - 0.3 * Math.sin(phase * 2); + return 0.2 * env * wave; +}; + +// SnakeSlither:蛇蜿蜒——连续 S 波 +const animalSnakeSlither = (waves = 3) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const wave = Math.sin(k * Math.PI * 2 * waves); + return 0.2 * env * wave; +}; + +// ButterflyFlit:蝴蝶乱飞——seed 可复现的随机采样 + cubic 平滑插值 +const animalButterflyFlit = (seed = 13) => { + let s = seed; + const rand = () => { s = (s * 9301 + 49297) % 233280; return s / 233280; }; + const samples = []; + for (let i = 0; i <= 26; i++) samples.push(rand() - 0.5); + return (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const pos = k * 25; + const idx = Math.floor(pos); + const t = pos - idx; + const smooth = t * t * (3 - 2 * t); + const interp = samples[idx] + (samples[idx + 1] - samples[idx]) * smooth; + return 0.3 * env * interp; + }; +}; + +// HorseGallop:马奔驰——每周期 4 蹄击地 + 空中相位间隙 +const animalHorseGallop = (cycles = 3) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const cyclePos = (k * cycles) - Math.floor(k * cycles); + const bell = (c, w = 0.04) => Math.exp(-((cyclePos - c) ** 2) / (2 * w * w)); + return 0.25 * env * (bell(0.0) + bell(0.18) + bell(0.36) + bell(0.54)); +}; + +const Animal = Object.freeze({ + CatPounce: animalCatPounce(), + BirdFlap: animalBirdFlap(), + SnakeSlither: animalSnakeSlither(), + ButterflyFlit: animalButterflyFlit(), + HorseGallop: animalHorseGallop(), +}); + +// ─── 导出(形态分类:Progress / Pulse / Wave) ───────────────────────────── +// +// 上方各主题常量(Physics / Motion / Step / Attention / Breath / Heart / +// MathExt / Explosion / Nature / Impact / Rhythm / UI / Magic / Animal) +// 及业界库 factory(libSpring / libSteps / libHeartBeat)仅作为 +// "源池"使用,不再作为顶层导出;由下列 Progress / Pulse / Wave 三个按形态 +// 分类的命名空间统一暴露。 +// +// 通用 UI 柔化(Smooth / Bezier 两组共 6 条命名曲线)已整组移除——数值上 +// 与原生 Sinusoidal/Quadratic/Cubic 等价;需定制贝塞尔请直接调用顶层 +// cubicBezier('Material.Standard' | x1,y1,x2,y2) 工厂。 + +// Progress —— 单调或衰减至 1 的曲线(A→B 过渡) +const Progress = Object.freeze({ + // Physics:原生 + Spring(Framer Motion 参数化弹簧) + Physics: Object.freeze({ + ...Physics, // SpringSoft / SpringStiff / DampedOscillation + Spring: libSpring(), // Framer Motion 风格默认弹簧 + }), + Motion, // Anticipate / Overshoot110 / Overshoot125 / SnapBack / Swing + // Step:固定段数实例 —— Steps4/6/8/12End 覆盖实用区间,无任意段数工厂 + Step: Object.freeze({ + ...Step, // Steps4End / Steps8End / Steps12End + Steps6: libSteps(), + }), + Math: Object.freeze({ + Tremor: MathExt.Tremor, + }), + Impact: Object.freeze({ + Rain: Impact.Rain, + Hammer: Impact.Hammer, + BounceDrop: Impact.BounceDrop, + ArrowHit: Impact.ArrowHit, + Shatter: Impact.Shatter, + }), + Rhythm: Object.freeze({ + BassDrop: Rhythm.BassDrop, + }), + UI: Object.freeze({ + SuccessPop: UI.SuccessPop, + }), + Magic: Object.freeze({ + ManaCharge: Magic.ManaCharge, + Shield: Magic.Shield, + }), + Animal: Object.freeze({ + CatPounce: Animal.CatPounce, + }), +}); + +// Pulse —— 单次返零脉冲(f(0)=f(1)=0, 单主峰;reversals ≤ 2 为主) +const Pulse = Object.freeze({ + Attention: Object.freeze({ + Ping: Attention.Ping, + }), + Breath: Object.freeze({ + Deep: Breath.Deep, + Sigh: Breath.Sigh, + }), + Heart: Object.freeze({ + Calm: Heart.Calm, + }), + Math: Object.freeze({ + JumpArc: MathExt.JumpArc, // 对称抛物 4k(1-k) + BoomerangSharp: mathBoomerang(E.Cubic.In), // 尖峰回程:缓→冲到峰→缓回(峰值锐利) + BoomerangSoft: mathBoomerang(E.Cubic.Out), // 平顶回程:快→在峰上停留→快回(峰值平滑) + }), + Explosion: Object.freeze({ + Impulse: Explosion.Impulse, + Flash: Explosion.Flash, + Recoil: Explosion.Recoil, + Implosion: Explosion.Implosion, + }), + Impact: Object.freeze({ + Slap: Impact.Slap, + }), + Rhythm: Object.freeze({ + Kick: Rhythm.Kick, + }), + UI: Object.freeze({ + ClickSnap: UI.ClickSnap, + HoverBloom: UI.HoverBloom, + RippleOut: UI.RippleOut, + }), + Magic: Object.freeze({ + SpellCast: Magic.SpellCast, + Teleport: Magic.Teleport, + }), +}); + +// Wave —— 周期多峰振荡(f(0)=f(1)=0, 多次反转) +const Wave = Object.freeze({ + Attention: Object.freeze({ + Wiggle: Attention.Wiggle, + Strum: Attention.Strum, + }), + Breath: Object.freeze({ + Normal: Breath.Normal, + Panting: Breath.Panting, + }), + Heart: Object.freeze({ + Excited: Heart.Excited, + LubDub: Heart.LubDub, + Beat: libHeartBeat(), // 迁移自 Lib.HeartBeat + }), + Math: Object.freeze({ + Pendulum: MathExt.Pendulum, + }), + Nature, // Wave / Flicker / Gust + Rhythm: Object.freeze({ + PunchCombo: Rhythm.PunchCombo, + Staccato: Rhythm.Staccato, + Crescendo: Rhythm.Crescendo, + DunDunDun: Rhythm.DunDunDun, + BellToll: Rhythm.BellToll, + }), + UI: Object.freeze({ + ErrorShake: UI.ErrorShake, + }), + Magic: Object.freeze({ + MagicAura: Magic.MagicAura, + }), + Animal: Object.freeze({ + BirdFlap: Animal.BirdFlap, + SnakeSlither: Animal.SnakeSlither, + ButterflyFlit: Animal.ButterflyFlit, + HorseGallop: Animal.HorseGallop, + }), +}); + +const customEasings = Object.freeze({ + makeOutIn, + OutIn, + Progress, + Pulse, + Wave, + cubicBezier, +}); + +exports.customEasings = customEasings; +exports.default = customEasings; diff --git a/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/scriptScene.js b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/scriptScene.js new file mode 100644 index 0000000000000000000000000000000000000000..8642c5b96e62ccd27ab63ba9d26170c4e3bf2d07 --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/scriptScene.js @@ -0,0 +1,800 @@ +/** + * 场景核心模块 + * + * 包含Three.js核心对象的创建和管理 + * 提供场景管理的核心功能:初始化、配置和更新 + */ + +// ThreeJS Env +// 导入TWEEN库 +// const TWEEN = require('../lib/tween'); +// 导入Three.js库 +// const THREE = require('three'); + + +// Effect Env +// 导入TWEEN库 +const TWEEN = require('./tween'); +// 导入自定义缓动函数库(OutIn 模式等官方未提供的组合) +const customEasings = require('./customEasings').customEasings; +// 导入Three.js 的 wrapper库 +const THREE = require('./three-amg-wrapper').THREE; +const { ShaderPass } = require('./ShaderPass.js'); +/** + * ScriptScene类 - 3D场景管理器 + * 负责创建和管理Three.js场景、相机、渲染器及场景对象 + */ +class ScriptScene { + /** + * 构造函数,创建场景管理器 + * @param {effect.Amaz.Scene} [amgScene] - AMG场景对象,可选参数 + * @param {HTMLElement} [container] - 放置渲染器的DOM容器,可选参数 + */ + 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(0x333333); + 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(); + + // 移除渲染器的DOM元素 + 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); + } + + // 清理TWEEN动画 + if (this.sceneObjects && this.sceneObjects.tweens) { + this.sceneObjects.tweens.forEach(tween => { + if (tween && typeof tween.stop === 'function') { + tween.stop(); + } + }); + this.sceneObjects.tweens = []; + } + + // 清理多pass + 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; + } + + /** + * 初始化Three.js核心对象 + * 包括场景、相机和渲染器 + */ + 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, // 纵横比 + 0.1, // 近平面 + 10000 // 远平面 + ); + this.camera.position.z = 10; // 设置默认相机位置 + this.scene.add(this.camera); + + // 创建渲染器,启用抗锯齿 + // 当amgScene为null时,创建渲染器 + 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 = {}; + + // 创建TWEEN实例 + this.TWEEN = TWEEN; + // 自定义缓动函数库:使用方式 this.customEasings.OutIn.Back 等 + this.customEasings = customEasings; + + // 时长 毫秒 + this.Duration = 2000; + } + + /** + * 添加ShaderPass + * @param {Array} shaderPassConfigs - ShaderPass配置数组 + * @return {void} + */ + 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); + // console.log('ShaderPass created:', shaderPass, className); + this.composer.addPass(shaderPass); + this.shaderPasses.push(shaderPass); + }); + } + + /** + * 设置后处理 + * @param {Array} shaderPassConfigs - ShaderPass配置数组 + * @return {void} + */ + 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); + } + +//===begin_pp=== +initPostProcessing() {} +//===end_pp=== + + /** + * 初始化场景 + * 设置基本的Three.js环境,添加渲染器到DOM + * @param {HTMLElement} container - 放置渲染器的DOM容器 + */ + 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()); + } + } + + /** + * 开始场景动画循环 + * @param {Function} updateCallback - 每帧调用的更新函数 + */ + start(updateCallback) { + if (this.isAnimating) return; + + this.isAnimating = true; + + // 如果提供了更新回调,使用requestAnimationFrame + if (updateCallback) { + const animateFrame = () => { + if (!this.isAnimating) return; + updateCallback(); + this.animationFrameId = requestAnimationFrame(animateFrame); + }; + + animateFrame(); + } else { + // 否则使用Three.js的setAnimationLoop,直接调用update渲染场景 + this.renderer.setAnimationLoop(() => { + this.update(); + }); + } + } + + + + /** + * 更新场景(由外部动画循环调用) + * @param {number} timestamp - 当前时间戳 + */ + updateScene(timestamp) { + // 标记动画开始 + if (!this.isAnimating) { + this.isAnimating = true; + } + + // 直接调用默认更新函数,传入时间戳 + this.defaultUpdate(timestamp); + } + + /** + * 更新并渲染场景 + * 在每一帧调用,将当前场景通过渲染器绘制到屏幕 + */ + update() { + if (this.usePostProcessing && this.composer) { + // 确保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.composer) { + // this.composer.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); + } + } + + /** + * 根据时间直接设置动画状态(用于时间跳转) + * @param {number} time - 动画时间(毫秒) + */ + seekToTime(time) { + // 标记动画开始 + if (!this.isAnimating) { + this.isAnimating = true; + } + + // 限制时间范围 + const clampedTime = Math.max(0, Math.min(time, this.Duration)); + + // seek ShaderPass后处理逻辑,该函数已预先定义,无需生成_predef_seekShaderPass实现 + if (this._predef_seekShaderPass) + { + this._predef_seekShaderPass(clampedTime); + } + + if (!this.sceneObjects.tweens || this.sceneObjects.tweens.length === 0) { + return; + } + + // 使用逆序遍历 TWEEN,确保正确的属性覆盖优先级 + // 逆序处理:让开始时间晚的tween先处理,开始时间早的tween后处理并覆盖 + + 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; + + // 将tween分为三种,未开始,进行中,已结束 + // 分到3个列表中 + + 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(); + } + +//===begin=== +//===滑竿begin=== +//===滑竿end=== +/** + * 初始化滑竿 + */ +setupSliders(){ +} + +/** + * 更新滑竿 + */ +updateSliders(){ +} + +/** + * 初始化一个完整的基本场景(不包含动画循环) + * 包括相机、场景对象的创建和特效材质 + * @returns {Object} 场景中的对象引用 + */ +setupScene() { + // 初始化场景对象容器 + this.initSceneObjects(); + + // 更新滑竿 + this.setupSliders(); + this.updateSliders(); + + // 设置场景背景为黑色 + this.scene.background = new THREE.Color(0x000000); + + // 创建效果平面 + this.createPlane(); + + // 设置动画 + this.setupAnimation(); + + return this.sceneObjects; +} + +/** + * 初始化场景对象容器 + */ +initSceneObjects() { + this.sceneObjects = { + plane: null, // 主平面对象 + material: null, // 效果材质 + tweens: [] // 动画对象数组 + }; +} + +/** + * 创建效果平面 + */ +createPlane() { + // 创建平面几何体,宽高比为1:1 + 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); +} + +/** + * 创建效果平面的着色器材质 + * @returns {THREE.ShaderMaterial} 效果平面着色器材质 + */ +createMaterial() { + // 确保纹理已加载 + if (!this.texture1 || !this.texture2) { + console.error("纹理未加载!"); + return new THREE.MeshBasicMaterial({ color: 0xff0000 }); + } + + // 为纹理设置适当的参数 + 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 = []; + + // 创建从0到1的动画 + const tween1 = new TWEEN.Tween({ intensity: 0, progress: 0 }) + .to({ intensity: 1, progress: 0.5 }, duration * 0.35) + .delay(duration * 0.15) + .easing(TWEEN.Easing.Linear.None) + .onUpdate((obj) => { + // 遍历obj中的所有属性,自动设置参数 + for (const key in obj) { + this.shaderPass.setParameter(key, obj[key]); + } + }); + + // 创建从1到0的动画 + const tween2 = new TWEEN.Tween({ intensity: 1, progress: 0.5 }) + .to({ intensity: 0, progress: 1 }, duration * 0.35) + .delay(duration * 0.5) + .easing(TWEEN.Easing.Linear.None) + .onUpdate((obj) => { + // 遍历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); + } +} +//===end=== + + /** + * 默认的场景更新函数,实现轨道交错转场动画 + */ + defaultUpdate(timestamp) { + // 更新所有TWEEN动画 + 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(); + } + + //===Predefined Function Begin=== +_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); + + // center + 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); + + // top + 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 * 0.5 + scaleYTop * 10 * 0.5, parentPosition.z + offset.z); + planeTop.scale.set(scaleXTop, scaleYTop, 1); + + this.scene.add(planeTop); + parent.attach(planeTop); + + // bottom + 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 * 0.5 - scaleYBottom * 10 * 0.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.play(); + video.load(); + + // video.style.position = 'absolute'; + // video.style.top = '400px'; + // video.style.left = '0px'; + // video.style.width = '480px'; + // video.style.height = '360px'; + // video.style.zIndex = '100'; + // document.body.appendChild(video); + + 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 / 1000 * 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); + } + } + } + }) +}//===Predefined Function End=== +} + +// 导入Three.js库 +// module.exports = ScriptScene; + +// 导入Three.js 的 wrapper库 +exports.ScriptScene = ScriptScene; diff --git a/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/three-amg-wrapper.js b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/three-amg-wrapper.js new file mode 100644 index 0000000000000000000000000000000000000000..a5fd4883bac974897a1c16105d092d5a770bfa4c --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/three-amg-wrapper.js @@ -0,0 +1,399 @@ +/** + * ThreeJS 到 AMG 的包装器 + * 让基于ThreeJS开发的应用能够在AMG引擎上运行 + * 此包装器将ThreeJS的API转换为AMG引擎的调用,实现无缝迁移 + */ + +// 获取AMG引擎API +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'); + +// 模拟浏览器环境中的window对象,使ThreeJS代码能在非浏览器环境中运行 +if (typeof window === 'undefined') { + // 定义模拟的window对象 + const mockWindow = { + innerWidth: 720, + innerHeight: 1280, + devicePixelRatio: 1, + addEventListener: function(event, callback) { + // 空函数,模拟事件监听 + }, + requestAnimationFrame: function(callback) { + // 空实现 + // 在实际环境中应该取消动画帧请求 + }, + cancelAnimationFrame: function(id) { + // 空实现 + // 在实际环境中应该取消动画帧请求 + }, + removeEventListener: function(event, callback) { + // 空实现 + // 在实际环境中应该取消事件监听 + } + }; + + // 定义模拟的document对象 + 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; +} + +// 定义命名空间对象,类似于THREE +const THREE = {}; + +// 常量定义(从 wrapper/Constants 统一导入,避免重复定义) +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._amgScene = new Amaz.Scene(); + this._objects = []; + + // 将场景添加到AMG管理器 + // effect.Amaz.AmazingManager.addScene(this._amgScene); + + // 设置全局场景实例 + setCurrentScene(this); + + console.log('AMG scene created'); + } + + /** + * 添加对象到场景 + * 支持一次添加多个对象,如: scene.add(obj1, obj2, obj3) + * @param {...Object} objects - 要添加的对象(可变参数) + */ + 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属性'); + } + } + } + + /** + * 从场景中移除对象,不删除AMG实体 + * @param {Object} object - 要移除的对象 + */ + 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.'); + } + } + + /** + * 从场景中删除对象,删除AMG实体 + */ + 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)); + } + + /** + * 析构函数,清理场景资源 + * 在不再需要场景时调用,确保释放所有资源并从AMG管理器中移除 + */ + dispose() { + console.log('Scene: 开始清理场景资源'); + + // 清理所有对象 + while (this._objects.length > 0) { + const object = this._objects[0]; + this.delete(object); + + // 如果对象有自己的dispose方法,调用它 + 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(); + } + } + } + + // 从AMG管理器中移除场景 + 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) { + // 二次贝塞尔曲线公式: B(t) = (1-t)²P₀ + 2(1-t)tP₁ + t²P₂ + 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; + } +} + + +/** #region 基础数学与类型 */ +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; +/** #endregion 基础数学与类型 */ + +/** #region 场景与相机 */ +THREE.Scene = Scene; +/** #endregion 场景与相机 */ + +/** #region 渲染器 */ +THREE.WebGLRenderer = WebGLRenderer; +/** #endregion 渲染器 */ + +/** #region 几何体与属性 */ +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; +/** #endregion 几何体与属性 */ + +/** #region 材质与着色 */ +THREE.Material = Material; +THREE.MeshBasicMaterial = MeshBasicMaterial; +THREE.ShaderMaterial = ShaderMaterial; +/** #endregion 材质与着色 */ + +/** #region 纹理相关 */ +THREE.Texture = Texture; +THREE.VideoTexture = VideoTexture; +THREE.TextureLoader = TextureLoader; +/** #endregion 纹理相关 */ + +/** #region 物体与层级 */ +THREE.Object3D = Group; +THREE.Group = Group; +THREE.Mesh = Mesh; +THREE.PerspectiveCamera = PerspectiveCamera; +/** #endregion 物体与层级 */ + +// 导出THREE命名空间和工具函数 +exports.THREE = THREE; +exports.getCurrentScene = getCurrentScene; \ No newline at end of file diff --git a/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/tween.js b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/tween.js new file mode 100644 index 0000000000000000000000000000000000000000..e66c48c1214e9291408c0279764dfea2a447c79c --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/tween.js @@ -0,0 +1,1455 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +/** + * The Ease class provides a collection of easing functions for use with tween.js. + */ +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 0.5 * amount * amount; + } + return -0.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 0.5 * amount * amount * amount; + } + return 0.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 0.5 * amount * amount * amount * amount; + } + return -0.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 0.5 * amount * amount * amount * amount * amount; + } + return 0.5 * ((amount -= 2) * amount * amount * amount * amount + 2); + }, + }), + Sinusoidal: Object.freeze({ + In: function (amount) { + return 1 - Math.sin(((1.0 - amount) * Math.PI) / 2); + }, + Out: function (amount) { + return Math.sin((amount * Math.PI) / 2); + }, + InOut: function (amount) { + return 0.5 * (1 - Math.sin(Math.PI * (0.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 0.5 * Math.pow(1024, amount - 1); + } + return 0.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 -0.5 * (Math.sqrt(1 - amount * amount) - 1); + } + return 0.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 - 0.1) * 5 * Math.PI) + 1; + }, + InOut: function (amount) { + if (amount === 0) { + return 0; + } + if (amount === 1) { + return 1; + } + amount *= 2; + if (amount < 1) { + return -0.5 * Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI); + } + return 0.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 0.5 * (amount * amount * ((s + 1) * amount - s)); + } + return 0.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 + 0.75; + } + else if (amount < 2.5 / 2.75) { + return 7.5625 * (amount -= 2.25 / 2.75) * amount + 0.9375; + } + else { + return 7.5625 * (amount -= 2.625 / 2.75) * amount + 0.984375; + } + }, + InOut: function (amount) { + if (amount < 0.5) { + return Easing.Bounce.In(amount * 2) * 0.5; + } + return Easing.Bounce.Out(amount * 2 - 1) * 0.5 + 0.5; + }, + }), + generatePow: function (power) { + if (power === void 0) { power = 4; } + power = power < Number.EPSILON ? Number.EPSILON : power; + power = power > 10000 ? 10000 : 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 < 0.5) { + return Math.pow((amount * 2), power) / 2; + } + return (1 - Math.pow((2 - amount * 2), power)) / 2 + 0.5; + }, + }; + }, +}); + +var now = function () { + // 优先使用原生performance.now() + // if (typeof performance !== 'undefined' && performance.now) { + // return performance.now(); + // } + + // Node.js环境:使用高精度时间 + if (typeof process !== 'undefined' && process.hrtime) { + if (!now._nodeStartTime) { + now._nodeStartTime = process.hrtime(); + } + var hrTime = process.hrtime(now._nodeStartTime); + return hrTime[0] * 1000 + hrTime[1] / 1000000; + } + + // 浏览器兜底:模拟performance.now()行为 + if (typeof now._startTime === 'undefined') { + now._startTime = Date.now(); + now._lastReturned = 0; + } + + var elapsed = Date.now() - now._startTime; + + // 确保时间单调递增,同时添加微小递增来模拟高精度 + if (elapsed <= now._lastReturned) { + now._lastReturned += 0.001; + } else { + now._lastReturned = elapsed; + } + + return now._lastReturned; +}; +function setNow(nowFunction) { + _nowFunc = nowFunction; +} + +/** + * Controlling groups of tweens + * + * Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components. + * In these cases, you may want to create your own smaller groups of tween + */ +var Group = /** @class */ (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]; + // Remove from any other group first, a tween can only be in one group at a time. + // @ts-expect-error library internal access + (_a = tween._group) === null || _a === void 0 ? void 0 : _a.remove(tween); + // @ts-expect-error library internal access + 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]; + // @ts-expect-error library internal access + tween._group = undefined; + delete this._tweens[tween.getId()]; + delete this._tweensAddedDuringUpdate[tween.getId()]; + } + }; + /** Return true if all tweens in the group are not paused or playing. */ + 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; + // Tweens are updated in "batches". If you add a new tween during an + // update, then the new tween will be updated in the next batch. + // If you remove a tween during an update, it may or may not be updated. + // However, if the removed tween was added during the current batch, + // then it will not be updated. + 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); + // After the onComplete callback completes, _isPlaying is updated to false, so if the total number of completed tweens is -1, then they are all complete. + 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) * 0.5; + var v1 = (p3 - p1) * 0.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; + }, + }, +}; + +/** + * Utils + */ +var Sequence = /** @class */ (function () { + function Sequence() { + } + Sequence.nextId = function () { + return Sequence._nextId++; + }; + Sequence._nextId = 0; + return Sequence; +}()); + +var mainGroup = new Group(); + +/** + * Tween.js - Licensed under the MIT license + * https://github.com/tweenjs/tween.js + * ---------------------------------------------- + * + * See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors. + * Thank you all, you're awesome! + */ +var Tween = /** @class */ (function () { + function Tween(object, group) { + this._isPaused = false; + this._pauseStart = 0; + this._valuesStart = {}; + this._valuesEnd = {}; + this._valuesStartRepeat = {}; + this._duration = 1000; + 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; + // eslint-disable-next-line + 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); + } + // Use "true" to restore old behavior (will be removed in future release). + 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 = 1000; } + 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 = 1000; } + 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) { + // If we were reversed (f.e. using the yoyo feature) then we need to + // flip the tween direction back to forward. + 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 dynamic is not enabled, clone the end values instead of using the passed-in end values. + 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 `to()` specifies a property that doesn't exist in the source object, + // we should not set that property in the object + if (propType === 'undefined' || propType === 'function') { + continue; + } + // Check if an Array was provided as property value + if (isInterpolationList) { + var endValues = _valuesEnd[property]; + if (endValues.length === 0) { + continue; + } + // Handle an array of relative values. + // Creates a local copy of the Array with the start value at the front + 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) { + // if (_valuesStart[property] === undefined) { // handle end values only the first time. NOT NEEDED? setupProperties is now guarded by _propertiesAreSetUp. + _valuesEnd[property] = temp; + // } + } + } + // handle the deepness of the values + if ((propType === 'object' || startValueIsArray) && startValue && !isInterpolationList) { + _valuesStart[property] = startValueIsArray ? [] : {}; + var nestedObject = startValue; + for (var prop in nestedObject) { + _valuesStart[property][prop] = nestedObject[prop]; + } + // TODO? repeat nested values? And yoyo? And array values? + _valuesStartRepeat[property] = startValueIsArray ? [] : {}; + var endValues = _valuesEnd[property]; + // If dynamic is not enabled, clone the end values instead of using the passed-in end values. + 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 { + // Save the starting value, but only once unless override is requested. + if (typeof _valuesStart[property] === 'undefined' || overrideStartingValues) { + _valuesStart[property] = startValue; + } + if (!startValueIsArray) { + // eslint-disable-next-line + // @ts-ignore FIXME? + _valuesStart[property] *= 1.0; // Ensures we're using numbers, not strings + } + if (isInterpolationList) { + // eslint-disable-next-line + // @ts-ignore FIXME? + _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; + }; + /** + * Removes the tween from whichever group it is in. + */ + 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; + }; + // eslint-disable-next-line + 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; + }; + /** + * @returns true if the tween is still playing after the update, false + * otherwise (calling update on a paused tween still returns true because + * it is still playing, just paused). + * + * @param autoStart - When true, calling update will implicitly call start() + * as well. Note, if you stop() or end() the tween, but are still calling + * update(), it will start again! + */ + 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; + // TODO use %? + // const timeIntoCurrentRepeat = elapsedTime % 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); + // properties transformations + 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; + } + // Reassign starting values, restart by making startTime = now + for (property in this._valuesStartRepeat) { + if (!this._yoyo && typeof this._valuesEnd[property] === 'string') { + this._valuesStartRepeat[property] = + // eslint-disable-next-line + // @ts-ignore FIXME? + 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++) { + // Make the chained tweens start exactly at the time they should, + // even if the `update()` method was called way past the duration of the tween + 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) { + // Don't update properties that do not exist in the source object + 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) { + // eslint-disable-next-line + // @ts-ignore FIXME? + this._updateProperties(_object[property], start, end, value); + } + else { + // Parses relative end values with start as base (e.g.: +10, -3) + end = this._handleRelativeValue(start, end); + // Protect against non numeric properties. + if (typeof end === 'number') { + // eslint-disable-next-line + // @ts-ignore FIXME? + _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'; + +/** + * Tween.js - Licensed under the MIT license + * https://github.com/tweenjs/tween.js + * ---------------------------------------------- + * + * See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors. + * Thank you all, you're awesome! + */ +var nextId = Sequence.nextId; +/** + * Controlling groups of tweens + * + * Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components. + * In these cases, you may want to create your own smaller groups of tweens. + */ +var TWEEN = mainGroup; +// This is the best way to export things in a way that's compatible with both ES +// Modules and CommonJS, without build hacks, and so as not to break the +// existing API. +// https://github.com/rollup/rollup/issues/1961#issuecomment-423037881 +/** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ +var getAll = TWEEN.getAll.bind(TWEEN); +/** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ +var removeAll = TWEEN.removeAll.bind(TWEEN); +/** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ +var add = TWEEN.add.bind(TWEEN); +/** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ +var remove = TWEEN.remove.bind(TWEEN); +/** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ +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, + /** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ + getAll: getAll, + /** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ + removeAll: removeAll, + /** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ + add: add, + /** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ + remove: remove, + /** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ + 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; \ No newline at end of file diff --git a/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Box2.js b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Box2.js new file mode 100644 index 0000000000000000000000000000000000000000..eb886973d02e86c0cb5201c6f1d953ce3c587e74 --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Box2.js @@ -0,0 +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.xthis.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;ithis.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.xthis.max.x||box.max.ythis.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; \ No newline at end of file diff --git a/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Box3.js b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Box3.js new file mode 100644 index 0000000000000000000000000000000000000000..4100dc7442d3a622827c8a415e24557f68c491f1 --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Box3.js @@ -0,0 +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=3?array[offset+2]:0;if(xthis.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=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.xthis.max.x||box.max.ythis.max.y||box.max.zthis.max.z)}}exports.Box3=Box3; \ No newline at end of file diff --git a/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..be3b8b1334a62f5e88c45feee098063a199fca55 --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js @@ -0,0 +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=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; \ No newline at end of file diff --git a/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..af9a8a13a46500e78f082a35e18d0b5932061234 --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js @@ -0,0 +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;iObject.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;i1?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; \ No newline at end of file diff --git a/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Constants.js b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Constants.js new file mode 100644 index 0000000000000000000000000000000000000000..6b8adda19a4d67236719804f5170889b39fd4582 --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Constants.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js new file mode 100644 index 0000000000000000000000000000000000000000..29b0aad5599401be17f967ba1d48851acb70c2ac --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js @@ -0,0 +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;i0||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;i0?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;imaxX)maxX=p.x;if(p.ymaxY)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; \ No newline at end of file diff --git a/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..f3dee08bf1c089e040fcfef228902ab9a39c93cb --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Earcut.js b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Earcut.js new file mode 100644 index 0000000000000000000000000000000000000000..953abffdf38c2def26df73fed180eff8c7644ced --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Earcut.js @@ -0,0 +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;imaxX)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=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=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.x&&p.x>=mx&&hx!==p.x&&pointInTriangle(hym.x||p.x===m.x&§orContainsSector(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.xb.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;i0||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=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;i0){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;imaxX)maxX=contour[i].x;if(contour[i].ymaxY)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;layerIdx0?-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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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; \ No newline at end of file diff --git a/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Group.js b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Group.js new file mode 100644 index 0000000000000000000000000000000000000000..90c4dbef65aa04d7a3bb6b6d76ec3317ea65a228 --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Group.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");class Group extends Object3D{constructor(name="Group_w"){super(name)}dispose(){super.dispose()}}exports.Group=Group; \ No newline at end of file diff --git a/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Material.js b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Material.js new file mode 100644 index 0000000000000000000000000000000000000000..81b97053ad9d1e4b1ef05d5ac6ed992487b2ca8e --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Material.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..dcf34d4cffb9de0869382a24690f78f60dda6049 --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js new file mode 100644 index 0000000000000000000000000000000000000000..41e6cd0a0eee7dd7bc497be5deac584806b68dc3 --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Mesh.js b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Mesh.js new file mode 100644 index 0000000000000000000000000000000000000000..254d69b074e797dd34c16d7dad723bbcc3b4895d --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Mesh.js @@ -0,0 +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;imaterial,set:value=>{material=value;if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;im.dispose&&m.dispose());else if(this.material.dispose)this.material.dispose()}}}exports.MeshWrapper=MeshWrapper; \ No newline at end of file diff --git a/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..ac394f66efc4e113a7127ee0f50ec672e4c5e9eb --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Object3D.js b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Object3D.js new file mode 100644 index 0000000000000000000000000000000000000000..8532c6122f839460aab34fe88957802ff523318b --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Object3D.js @@ -0,0 +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{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&¤tScene._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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js new file mode 100644 index 0000000000000000000000000000000000000000..ba39801de50d38ec04424f3c2ebfa2ff5d28fded --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js @@ -0,0 +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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..bc595fb80ad9e7c2f4d8360c67dbef556f3d6cbe --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js @@ -0,0 +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;iy0){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; \ No newline at end of file diff --git a/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..02dc1be955bc766de744222a7e75c65bf147bb61 --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js @@ -0,0 +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&¶meters.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{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=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=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=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; \ No newline at end of file diff --git a/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Shape.js b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Shape.js new file mode 100644 index 0000000000000000000000000000000000000000..ecde48b5ceb30812c922aa5c7cfe2aa7b50cabe4 --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Shape.js @@ -0,0 +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;i0){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;i0||(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;imaxX)maxX=p.x;if(p.ymaxY)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;i0?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;ipoints.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;itwoPi)deltaAngle-=twoPi;if(deltaAngle>4;uuid[i]=chars[i===19?r&3|8:r]}}return uuid.join("")}exports.Shape=Shape; \ No newline at end of file diff --git a/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..3786abc7d64ed80b56101c4ac9d30ce9fcb8f941 --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js @@ -0,0 +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;i0){const bounds=calculateBounds(flatVertices);const vertexOffset=vertices.length/3;for(let j=0;j0){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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}function calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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; \ No newline at end of file diff --git a/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..1ea27a55fbce9fc3771c66840c068e5ff6347092 --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Texture.js b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Texture.js new file mode 100644 index 0000000000000000000000000000000000000000..35bff49d732c9884e07bfcb5682f18a860485e1f --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Texture.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Vector2.js b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Vector2.js new file mode 100644 index 0000000000000000000000000000000000000000..a30a2431264ee62cec937714dfa9e50932ddedeb --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/js/ThreeJS/wrapper/Vector2.js @@ -0,0 +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)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)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)= 1.0) return texel2; + + float foldPhase = sin(3.14159265 * p); + float bands = max(1.0, bandCount); + float bandId = floor(vUv.y * bands); + + float rnd = hash1((bandId + 1.0) * 127.1); + float dir = rnd * 2.0 - 1.0; + float localShift = dir * foldAmount * foldPhase * (0.45 + 0.55 * rnd); + + vec2 uvA = vec2(clamp(vUv.x + localShift, 0.0, 1.0), vUv.y); + vec2 uvB = vec2(clamp(vUv.x - localShift * 0.8, 0.0, 1.0), vUv.y); + + vec4 src = texture2D(tDiffuse, uvA); + vec4 dst = texture2D(tDiffuse1, uvB); + + float s = clamp(reconstructionSmoothness, 0.01, 0.45); + float mixP = smoothstep(0.0 + s, 1.0 - s, p); + vec4 col = mix(src, dst, mixP); + + float scan = sin((vUv.y * bands * 1.35 + vUv.x * ratio * 2.0) * 6.2831853); + float scanAmp = scanIntensity * foldPhase; + col.rgb *= 1.0 + scan * scanAmp * 0.25; + + col.rgb = clamp(col.rgb, 0.0, 1.0); + return col; +} + +void main() { + // Get the pixel color from both textures + vec4 texel1 = texture2D(tDiffuse, vUv); + vec4 texel2 = texture2D(tDiffuse1, vUv); + + // --- Transition Configuration --- + const float fadeInEnd = 0.1; + const float fadeOutStart = 0.9; + + // 1. Calculate the transition's own progress. + float transitionProgress = clamp((progress - fadeInEnd) / (fadeOutStart - fadeInEnd), 0.0, 1.0); + vec4 transitionColor = transition(texel1, texel2, transitionProgress); + + // 2. Calculate smooth blending factors for the start and end zones. + float blendInFactor = smoothstep(0.0, fadeInEnd, progress); + float blendOutFactor = smoothstep(fadeOutStart, 1.0, progress); + + // 3. Apply the blending. + vec4 finalColor = mix(texel1, transitionColor, blendInFactor); + finalColor = mix(finalColor, texel2, blendOutFactor); + + gl_FragColor = finalColor; +} +//===end_frag_code=== +`; \ No newline at end of file diff --git a/scripts/7681318995261132040/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js b/scripts/7681318995261132040/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js new file mode 100644 index 0000000000000000000000000000000000000000..2c87ab8ca97aecc86f650141dcf51ecc1ee7f46e --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js @@ -0,0 +1,8 @@ +exports.source=` +varying vec2 vUv; + +void main() { + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); +} +`; \ No newline at end of file diff --git a/scripts/7681318995261132040/AmazingFeature/xshader/Unlit.frag b/scripts/7681318995261132040/AmazingFeature/xshader/Unlit.frag new file mode 100644 index 0000000000000000000000000000000000000000..2b8ef6c235afd5362d14d87961e5b7fa2fe044b1 --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/xshader/Unlit.frag @@ -0,0 +1,25 @@ +precision highp float; +uniform sampler2D u_AlbedoTexture; +uniform vec4 u_AlbedoColor; +uniform vec2 u_Repeat; +uniform vec2 u_Offset; +uniform float u_Translucency; +uniform float u_Opacity; +varying vec2 g_vary_uv0; +void main () +{ + vec2 uv_1; + uv_1.x = g_vary_uv0.x; + uv_1.y = (g_vary_uv0.y); + lowp vec4 tmpvar_2; + tmpvar_2 = texture2D (u_AlbedoTexture, (uv_1 * u_Repeat + u_Offset)); + lowp vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2.xyz * u_AlbedoColor.xyz); + lowp float tmpvar_4; + tmpvar_4 = (tmpvar_2.w * u_Translucency); + mediump vec4 tmpvar_5; + tmpvar_5.xyz = tmpvar_3; + tmpvar_5.w = tmpvar_4; + gl_FragColor = vec4(tmpvar_5.xyz * u_Opacity, tmpvar_5.w * u_Opacity); +} + diff --git a/scripts/7681318995261132040/AmazingFeature/xshader/Unlit.vert b/scripts/7681318995261132040/AmazingFeature/xshader/Unlit.vert new file mode 100644 index 0000000000000000000000000000000000000000..64a27d816e6146a0fb85643a9991207e5fda2acb --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/xshader/Unlit.vert @@ -0,0 +1,35 @@ +precision highp float; +attribute vec3 attPosition; +attribute vec2 attTexcoord0; + +//#define AMAZING_USE_BONES + +#ifdef AMAZING_USE_BONES +attribute vec4 attBoneIds; +attribute vec4 attWeights; +const int MAX_BONES = 50; +uniform mat4 u_Palatte[MAX_BONES]; +#endif + +uniform mat4 u_Model; +uniform mat4 u_MVP; +varying vec2 g_vary_uv0; + + + +void main () +{ + vec3 modelPostiton = attPosition; + vec4 homogeneous_pos = vec4(attPosition, 1.0); + g_vary_uv0 = attTexcoord0; + +#ifdef AMAZING_USE_BONES + mat4 boneTransform = u_Palatte[int(attBoneIds.x)] * attWeights.x; + boneTransform += u_Palatte[int(attBoneIds.y)] * attWeights.y; + boneTransform += u_Palatte[int(attBoneIds.z)] * attWeights.z; + boneTransform += u_Palatte[int(attBoneIds.w)] * attWeights.w; + gl_Position = u_MVP * boneTransform * homogeneous_pos; +#else + gl_Position = u_MVP * homogeneous_pos; +#endif +} diff --git a/scripts/7681318995261132040/AmazingFeature/xshader/noface.frag b/scripts/7681318995261132040/AmazingFeature/xshader/noface.frag new file mode 100644 index 0000000000000000000000000000000000000000..88e9ec343761b2395bae9430e6e55466b0367d67 --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/xshader/noface.frag @@ -0,0 +1,7 @@ +precision lowp float; +varying highp vec2 uv0; +uniform sampler2D u_albedo; +void main() +{ + gl_FragColor = texture2D(u_albedo, uv0); +} diff --git a/scripts/7681318995261132040/AmazingFeature/xshader/noface.vert b/scripts/7681318995261132040/AmazingFeature/xshader/noface.vert new file mode 100644 index 0000000000000000000000000000000000000000..16450a4b5880cf8d83528ea1ae0f47d10b2ab1d8 --- /dev/null +++ b/scripts/7681318995261132040/AmazingFeature/xshader/noface.vert @@ -0,0 +1,12 @@ +precision highp float; + +attribute vec2 position; +attribute vec2 texcoord0; +varying vec2 uv0; +//uniform mat4 u_MVP; +void main() +{ + //gl_Position = u_MVP * position; + gl_Position = sign(vec4(position.xy, 0.0, 1.0)); + uv0 = texcoord0; +} diff --git a/scripts/7681318995261132040/config.json b/scripts/7681318995261132040/config.json new file mode 100644 index 0000000000000000000000000000000000000000..557ff9895b4c8c8a7d91baae310b40001cd6c20d --- /dev/null +++ b/scripts/7681318995261132040/config.json @@ -0,0 +1,16 @@ +{ + "ae_tool": "AmazingEditor", + "bALG_BACH_CONFIG": false, + "effect": { + "Link": [ + { + "path": "AmazingFeature/", + "type": "AmazingFeature", + "zorder": 8011 + } + ] + }, + "name": "AlgorithmGraph_7bdbHcdcscQkbEdcc9cIlcNdvTdtb", + "version": "13.4.0", + "item_source": "user_post_pc_lumi_ai" +} \ No newline at end of file diff --git a/scripts/7681318995261132040/extra.json b/scripts/7681318995261132040/extra.json new file mode 100644 index 0000000000000000000000000000000000000000..8984aece5d7e3b688d449fe70bfe1ae4fbd83c6b --- /dev/null +++ b/scripts/7681318995261132040/extra.json @@ -0,0 +1,51 @@ +{ + "transition": { + "defaultDura": 2.0, + "isOverlap": true + }, + "External_Producer": true, + "setting": { + "lumiai_material_properties": [ + { + "effect_key": "progress", + "effect_key_cn": "\u6548\u679c\u8fdb\u5ea6", + "type": "float", + "default": 0, + "min": 0, + "max": 1 + }, + { + "effect_key": "bandCount", + "effect_key_cn": "band C", + "type": "float", + "default": 140, + "min": 20, + "max": 400 + }, + { + "effect_key": "foldAmount", + "effect_key_cn": "fold A", + "type": "float", + "default": 0.035, + "min": 0, + "max": 0.2 + }, + { + "effect_key": "scanIntensity", + "effect_key_cn": "scan I", + "type": "float", + "default": 0.06, + "min": 0, + "max": 0.2 + }, + { + "effect_key": "reconstructionSmoothness", + "effect_key_cn": "recons", + "type": "float", + "default": 0.18, + "min": 0.01, + "max": 0.45 + } + ] + } +} \ No newline at end of file diff --git a/scripts/7681319861905001746/AmazingFeature/content.json b/scripts/7681319861905001746/AmazingFeature/content.json new file mode 100644 index 0000000000000000000000000000000000000000..df43720515b1b6981b24c4268c902195fa613d43 --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/content.json @@ -0,0 +1,7 @@ +{ + "ae_tool" : "AmazingEditor", + "content" : {}, + "needblend" : false, + "tag" : "AMG_1515088281693380358513659446614427937212", + "version" : "1.0" +} \ No newline at end of file diff --git a/scripts/7681319861905001746/AmazingFeature/js/JSSys.js b/scripts/7681319861905001746/AmazingFeature/js/JSSys.js new file mode 100644 index 0000000000000000000000000000000000000000..bbcbf36f0f75c1beebe88c33dd0464bb4477158e --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/js/JSSys.js @@ -0,0 +1,89 @@ +const effect_api = "undefined" != typeof effect ? effect : "undefined" != typeof tt ? tt : "undefined" != typeof lynx ? lynx : {}; +const Amaz = effect_api.getAmaz(); + +const { ScriptScene } = require('./ThreeJS/scriptScene'); +const THREE = require('./ThreeJS/three-amg-wrapper').THREE; + +class JSSys { + constructor() { + this.name = "JSSys"; + this.comps = {} + this.compsdirty = true + } + + onComponentAdded(comp) { + // console.log("running:JSSys:onComponentAdded"); + } + onComponentRemoved(comp) { + // console.log("running:JSSys:onComponentRemoved"); + } + + onStart() { + console.log("running:JSSys:onStart"); + + this.renderTexture = this.scene.assetMgr.SyncLoad('rt/outputTex.rt'); + + // 添加光源到场景 + console.log('JSSys: 创建ScriptScene实例'); + this.scriptScene = new ScriptScene(this.scene); + + this.input = Amaz.AmazingManager.getSingleton("Input"); + const builtinObject = Amaz.AmazingManager.getSingleton("BuiltinObject"); + + if (builtinObject.getUserTexture("#TransitionInput0") && builtinObject.getUserTexture("#TransitionInput1")) { + this.scriptScene.texture1 = new THREE.Texture(); + this.scriptScene.texture1.setImage(builtinObject.getUserTexture("#TransitionInput0")); + this.scriptScene.texture2 = new THREE.Texture(); + this.scriptScene.texture2.setImage(builtinObject.getUserTexture("#TransitionInput1")); + console.log("JSSys: 获取到纹理"); + } + else + { + this.scriptScene.texture1 = new THREE.Texture(); + this.scriptScene.texture1.setImage(this.scene.assetMgr.SyncLoad('image/Sample1.jpg')); + this.scriptScene.texture2 = new THREE.Texture(); + this.scriptScene.texture2.setImage(this.scene.assetMgr.SyncLoad('image/Sample2.jpg')); + console.log("JSSys: 未获取到纹理,使用默认纹理"); + } + + this.scriptScene.setupScene(); + // 初始化后处理效果 + if (this.scriptScene.initPostProcessing != null) { + this.scriptScene.initPostProcessing(); + } + } + + onUpdate(deltaTime) { + this.time = this.input.getFrameTimestamp(); + // this.time = this.time % 2; + // this.time = this.time / 2.0; + this.scriptScene.seekToTime(this.time * this.scriptScene.Duration); + // this.scriptScene.updateScene(); + } + onLateUpdate(deltaTime) { + // console.log("running:JSSys:onLateUpdate"); + this.scriptScene.scene.seekToTime(this.time * this.scriptScene.Duration); + } + + onEvent(event) { + console.log("running:JSSys:onEvent"); + if (event.type == Amaz.EventType.VIEWER) { + // console.log("JSSys: 窗口大小改变"); + console.log("renderTexture.width",this.renderTexture.width); + console.log("renderTexture.height",this.renderTexture.height); + + window.innerWidth = this.renderTexture.width; + window.innerHeight = this.renderTexture.height; + // console.log("JSSys: 窗口大小改变"); + this.scriptScene.handleResize(); + } + } + + onDestroy() { + // console.log("running:JSSys:onDestroy"); + this.scriptScene.destroy(); + } +} + +exports.JSSys = JSSys; + diff --git a/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/EffectComposer.js b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/EffectComposer.js new file mode 100644 index 0000000000000000000000000000000000000000..e7d8fd7a3f3978d9da1a9bf29af1854806f60014 --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/EffectComposer.js @@ -0,0 +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 { + if (k <= 0) return 0; + if (k >= 1) return 1; + return 1 - Math.exp(-6 * k) * Math.cos(12 * k); +}; + +// 欠阻尼弹簧(硬):更高频振荡、更慢收敛 +const springStiff = (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return 1 - Math.exp(-5 * k) * Math.cos(18 * k); +}; + +// 阻尼振荡:sin 基波收尾抖动 +const dampedOscillation = (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return 1 - Math.exp(-5 * k) * Math.cos(10 * k); +}; + +const Physics = Object.freeze({ + SpringSoft: springSoft, + SpringStiff: springStiff, + DampedOscillation: dampedOscillation, +}); + +// ─── §4 Motion 动作设计系 ────────────────────────────────────────────────── + +// 先回拉 10% 再冲向终点:蓄力动作 +const anticipate = (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + const pullback = 0.1; + if (k < 0.3) { + const p = k / 0.3; + return -pullback * p * (2 - p); // easeOutQuad 到 -pullback + } + const p = (k - 0.3) / 0.7; + return -pullback + (1 + pullback) * p * p * (3 - 2 * p); // smoothstep 到 1 +}; + +// 冲到 peak 再回到 1 的工厂 +const overshootFactory = (peak) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.6) { + const p = k / 0.6; + return peak * p * (2 - p); // easeOutQuad 到 peak + } + const p = (k - 0.6) / 0.4; + return peak + (1 - peak) * (1 - Math.pow(1 - p, 3)); // easeOutCubic 到 1 +}; + +const overshoot110 = overshootFactory(1.10); +const overshoot125 = overshootFactory(1.25); + +// 快速到位(前 60% 冲到 1.05),后 40% 回到 1:磁吸、卡扣 +const snapBack = (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.6) { + const p = k / 0.6; + return 1.05 * (1 - Math.pow(1 - p, 3)); + } + const p = (k - 0.6) / 0.4; + return 1.05 - 0.05 * p * p * (3 - 2 * p); +}; + +// 摆锤式:一次轻微过冲后收敛 +const swing = (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return 1 - Math.cos(1.5 * Math.PI * k) * Math.exp(-2.5 * k); +}; + +const Motion = Object.freeze({ + Anticipate: anticipate, + Overshoot110: overshoot110, + Overshoot125: overshoot125, + SnapBack: snapBack, + Swing: swing, +}); + +// ─── §5 Step 步进系 ──────────────────────────────────────────────────────── + +/** + * CSS steps() 等价工厂。 + * @param {number} n 段数 + * @param {'start' | 'end'} jumpTerm 跳变在每段的起始还是结束(默认 'end') + */ +const makeStep = (n, jumpTerm = 'end') => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (jumpTerm === 'start') return Math.ceil(k * n) / n; + return Math.floor(k * n) / n; +}; + +const Step = Object.freeze({ + Steps4End: makeStep(4, 'end'), + Steps8End: makeStep(8, 'end'), + Steps12End: makeStep(12, 'end'), +}); + +// ─── §6 Bezier 规范贝塞尔 ────────────────────────────────────────────────── + +/** + * 给定两个控制点 (x1,y1) 与 (x2,y2),P0=(0,0) P3=(1,1)。 + * 返回函数 f(t) -> y,其中 t 是输入时间(需先用牛顿法从 x 反解 s)。 + */ +function buildCubicBezier(x1, y1, x2, y2) { + const cx = 3 * x1, bx = 3 * (x2 - x1) - cx, ax = 1 - cx - bx; + const cy = 3 * y1, by = 3 * (y2 - y1) - cy, ay = 1 - cy - by; + const sampleX = (s) => ((ax * s + bx) * s + cx) * s; + const sampleY = (s) => ((ay * s + by) * s + cy) * s; + const sampleDX = (s) => (3 * ax * s + 2 * bx) * s + cx; + + const solveS = (x) => { + let s = x; + for (let i = 0; i < 8; i++) { + const cur = sampleX(s) - x; + if (Math.abs(cur) < 1e-6) return s; + const d = sampleDX(s); + if (Math.abs(d) < 1e-6) break; + s -= cur / d; + if (s < 0) s = 0; + if (s > 1) s = 1; + } + // 兜底二分 + let lo = 0, hi = 1; + for (let i = 0; i < 32 && hi - lo > 1e-6; i++) { + const mid = (lo + hi) / 2; + if (sampleX(mid) < x) lo = mid; else hi = mid; + } + return (lo + hi) / 2; + }; + + return (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return sampleY(solveS(k)); + }; +} + +// 贝塞尔白名单:(x1, y1, x2, y2) +const BEZIER_PRESETS = Object.freeze({ + 'Material.Standard': [0.4, 0, 0.2, 1], + 'Material.Accelerate': [0.4, 0, 1, 1], + 'Material.Decelerate': [0, 0, 0.2, 1], + 'CSS.Ease': [0.25, 0.1, 0.25, 1], +}); + +// 工厂 memoization(避免同参数重复构造) +const _bezierCache = new Map(); +function _cachedBezier(x1, y1, x2, y2) { + const key = x1 + ',' + y1 + ',' + x2 + ',' + y2; + let fn = _bezierCache.get(key); + if (!fn) { + fn = buildCubicBezier(x1, y1, x2, y2); + _bezierCache.set(key, fn); + } + return fn; +} + +/** + * cubicBezier('Material.Standard') | cubicBezier(x1, y1, x2, y2) + * 直写参数受控域:x1/x2 ∈ [0,1],y1/y2 ∈ [-0.5, 1.5] + */ +function cubicBezier(a, b, c, d) { + if (typeof a === 'string') { + let preset = BEZIER_PRESETS[a]; + if (!preset) { + console.warn('[customEasings.cubicBezier] unknown preset, falling back to Material.Standard:', a); + preset = BEZIER_PRESETS['Material.Standard']; + } + return _cachedBezier(preset[0], preset[1], preset[2], preset[3]); + } + // 数值入口:裁剪到允许域 + const clamp = (v, lo, hi) => Math.max(lo, Math.min(hi, v)); + const x1 = clamp(a, 0, 1); + const y1 = clamp(b, -0.5, 1.5); + const x2 = clamp(c, 0, 1); + const y2 = clamp(d, -0.5, 1.5); + return _cachedBezier(x1, y1, x2, y2); +} + +// 命名贝塞尔实例已整组移除:Material/CSS 预设与原生 Sinusoidal/Quadratic/Cubic +// 数值上几乎等价,特殊场景请直接调用 cubicBezier('Material.Standard') 等工厂。 + +// ═══════════════════════════════════════════════════════════════════════════ +// 扩展分组(与已有 6 组并列,不污染既有命名空间) +// ═══════════════════════════════════════════════════════════════════════════ + +// ─── §7 业界库扩展(已并入 Physics / Step / Heart) ───────────────────────── +// 以下工厂原本聚合在 Lib.* 命名空间下,现已按语义归入相应主题: +// Spring (Framer Motion) → Progress.Physics.Spring +// Steps (GSAP) → Progress.Step.Steps6 +// HeartBeat → Wave.Heart.Beat +// 退役:Framer Motion 的 Anticipate / GSAP 的 Overshoot factory(由 Motion.* +// 覆盖);GSAP ExpoScale / Unity SmoothDamp(数值上与原生 Sinusoidal/Quadratic +// 等价,已整组移除)。 + +// Spring(Framer Motion 风格):参数化弹簧,离散积分 +const libSpring = ({ stiffness = 180, damping = 12, mass = 1 } = {}) => { + const DT = 1 / 240; + const T = 1.5; + let x = 0, v = 0; + const samples = []; + for (let t = 0; t <= T; t += DT) { + const force = -stiffness * (x - 1) - damping * v; + v += (force / mass) * DT; + x += v * DT; + samples.push({ t, x }); + } + let T_end = T; + for (let i = samples.length - 1; i >= 0; i--) { + if (Math.abs(samples[i].x - 1) > 0.01) { T_end = samples[i].t; break; } + } + return (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + const t = k * T_end; + const idx = Math.min(samples.length - 1, Math.floor(t / DT)); + return samples[idx].x; + }; +}; + +// HeartBeat(简易版):两高斯峰的绝对值轨迹 +const libHeartBeat = (peak = 0.3) => (k) => { + if (k <= 0 || k >= 1) return 0; + const bell = (t, c) => Math.exp(-((t - c) ** 2) / (2 * 0.07 * 0.07)); + return peak * (bell(k, 0.2) + bell(k, 0.5)); +}; + +// Steps(GSAP SteppedEase 风格 factory):离散 N 段阶梯(默认 n=6) +const libSteps = (n = 6) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return Math.floor(k * n) / n; +}; + +// ─── §8 Attention 注意力 / 抖振 ──────────────────────────────────────────── + +// Ping:单次衰减脉冲(雷达 ping),sin(π·k) × exp(-decay·k) +const attentionPing = (peak = 0.35, decay = 2) => (k) => { + if (k <= 0 || k >= 1) return 0; + return peak * Math.sin(Math.PI * k) * Math.exp(-decay * k); +}; + +// Wiggle:衰减正弦振荡(easing 值本身,非位置增量) +const attentionWiggle = (count = 4, amplitude = 0.25) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = 1 - k; + return amplitude * env * Math.sin(k * Math.PI * 2 * count); +}; + +// Strum:多峰衰减(吉他拨弦) +const attentionStrum = (notes = 4, peak = 0.4) => { + const centers = []; + for (let i = 0; i < notes; i++) { + centers.push({ c: 0.15 + i * (0.7 / Math.max(1, notes - 1)), a: Math.pow(0.72, i) }); + } + return (k) => { + if (k <= 0 || k >= 1) return 0; + let sum = 0; + for (const { c, a } of centers) { + sum += a * Math.exp(-((k - c) ** 2) / (2 * 0.05 * 0.05)); + } + return peak * sum; + }; +}; + +const Attention = Object.freeze({ + Ping: attentionPing(), + Wiggle: attentionWiggle(), + Strum: attentionStrum(), +}); + +// ─── §9 Breath 呼吸 ──────────────────────────────────────────────────────── + +// Normal:慢节奏正弦呼吸 +const breathNormal = (cycles = 2, peak = 0.15) => (k) => { + if (k <= 0 || k >= 1) return 0; + return peak * Math.sin(k * Math.PI * 2 * cycles) * Math.sin(k * Math.PI); +}; + +// Deep:深呼吸——慢吸气 → hold → 慢呼气 +const breathDeep = (peak = 0.3, riseRatio = 0.35, holdRatio = 0.15) => { + const holdEnd = riseRatio + holdRatio; + return (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < riseRatio) { + const t = k / riseRatio; + return peak * Math.sin(t * Math.PI / 2); + } + if (k < holdEnd) { + return peak; + } + const t = (k - holdEnd) / (1 - holdEnd); + return peak * Math.cos(t * Math.PI / 2); + }; +}; + +// Panting:急促浅呼吸——多次小幅起伏 + 正弦包络 +const breathPanting = (cycles = 6, peak = 0.08) => (k) => { + if (k <= 0 || k >= 1) return 0; + const envelope = Math.sin(k * Math.PI); + const wave = 0.5 + 0.5 * Math.sin(k * Math.PI * 2 * cycles - Math.PI / 2); + return peak * envelope * wave; +}; + +// Sigh:叹息——快速吸气后慢速释放 +const breathSigh = (peak = 0.25, riseRatio = 0.2) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < riseRatio) { + const t = k / riseRatio; + return peak * Math.sin(t * Math.PI / 2); + } + const t = (k - riseRatio) / (1 - riseRatio); + return peak * (1 - t) * (1 - t); +}; + +const Breath = Object.freeze({ + Normal: breathNormal(), + Deep: breathDeep(), + Panting: breathPanting(), + Sigh: breathSigh(), +}); + +// ─── §10 Heart 心跳 ──────────────────────────────────────────────────────── + +// Calm:单次舒缓心跳——单高斯峰 +const heartCalm = (peak = 0.25, center = 0.35, width = 0.1) => (k) => { + if (k <= 0 || k >= 1) return 0; + return peak * Math.exp(-((k - center) ** 2) / (2 * width * width)); +}; + +// Excited:兴奋/紧张——密集快速心跳(N 连击) +const heartExcited = (beats = 4, peak = 0.3, width = 0.04) => { + const centers = []; + const span = 0.7; + for (let i = 0; i < beats; i++) { + centers.push(0.15 + i * (span / Math.max(1, beats - 1))); + } + return (k) => { + if (k <= 0 || k >= 1) return 0; + let sum = 0; + for (const c of centers) { + sum += Math.exp(-((k - c) ** 2) / (2 * width * width)); + } + return peak * sum; + }; +}; + +// LubDub:标准心跳「lub-dub」双音节 +const heartLubDub = (peak = 0.3) => (k) => { + if (k <= 0 || k >= 1) return 0; + const bell = (t, c, w) => Math.exp(-((t - c) ** 2) / (2 * w * w)); + // lub(S1):中心 0.25、宽 0.045、幅 1.0 + // dub(S2):中心 0.42、宽 0.03、幅 0.6 + return peak * (bell(k, 0.25, 0.045) + 0.6 * bell(k, 0.42, 0.03)); +}; + +const Heart = Object.freeze({ + Calm: heartCalm(), + Excited: heartExcited(), + LubDub: heartLubDub(), +}); + +// ─── §11 Math 物理 / 数学 ───────────────────────────────────────────────── + +// JumpArc:抛物线轨迹 4k(1-k) +const mathJumpArc = () => (k) => { + if (k <= 0 || k >= 1) return 0; + return 4 * k * (1 - k); +}; + +// Pendulum:物理摆——sin(πk) 包络的衰减余弦,端点归零(满足 Wave 契约 f(0)=f(1)=0) +const mathPendulum = (damping = 3, freq = 2.5) => (k) => { + if (k <= 0 || k >= 1) return 0; + return Math.sin(k * Math.PI) * Math.exp(-damping * k) * Math.cos(freq * Math.PI * k); +}; + +// Tremor:持续高频小幅抖动(不衰减),整体沿 Linear 进行 +const mathTremor = (amplitude = 0.04, freq = 22) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return k + amplitude * Math.sin(k * Math.PI * 2 * freq); +}; + +// Boomerang 包装器:把任意 easing 包装成 0→1→0(先去再回)。 +// 仅作为内部辅助使用,不暴露为公共曲线——常用变体已预实例化为 +// Pulse.Math.BoomerangSharp / BoomerangSoft(见 Pulse 命名空间)。 +const mathBoomerang = (fn) => (k) => { + if (k <= 0 || k >= 1) return 0; + return k < 0.5 ? fn(k * 2) : fn(2 - k * 2); +}; + +const MathExt = Object.freeze({ + JumpArc: mathJumpArc(), + Pendulum: mathPendulum(), + Tremor: mathTremor(), +}); + +// ─── §12 Explosion 爆炸 ──────────────────────────────────────────────────── + +// Impulse:指数脉冲响应 k·e^(1-k·sharpness)(减线性尾项使 k=1 归 0) +const explosionImpulse = (sharpness = 6) => { + const tail = sharpness * Math.exp(1 - sharpness); + return (k) => { + if (k <= 0 || k >= 1) return 0; + const h = sharpness * k; + return h * Math.exp(1 - h) - tail * k; + }; +}; + +// Flash:瞬间拉满 + 指数衰减到 0 +const explosionFlash = (rise = 0.05, decay = 5) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < rise) return k / rise; + return Math.exp(-decay * (k - rise)); +}; + +// Recoil:爆炸反冲——负向冲击 -1 + 阻尼振荡 +const explosionRecoil = (decay = 4, freq = 3) => (k) => { + if (k <= 0 || k >= 1) return 0; + return -Math.exp(-decay * k) * Math.cos(freq * Math.PI * k); +}; + +// Implosion:三段式——负向吸能 → 正向爆发 → 衰减归 0 +const explosionImplosion = (charge = 0.3, depth = 0.4, burstPeak = 1.2) => { + const sharp = 5; + const tail = sharp * Math.exp(1 - sharp); + return (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < charge) { + const t = k / charge; + return -depth * Math.sin(t * Math.PI / 2); + } + const t = (k - charge) / (1 - charge); + const h = sharp * t; + const wave = h * Math.exp(1 - h) - tail * t; + const settle = -depth * Math.pow(1 - t, 3); + return settle + burstPeak * wave; + }; +}; + +const Explosion = Object.freeze({ + Impulse: explosionImpulse(), + Flash: explosionFlash(), + Recoil: explosionRecoil(), + Implosion: explosionImplosion(), +}); + +// ─── §13 Cinema(已整组移除:Creep=k^3.5 与 Cubic.In/Quartic.In 数值等价) ─ + +// ─── §14 Nature 自然现象 ─────────────────────────────────────────────────── + +// Wave:海浪律动——多谐波叠加 + 整体正弦包络 +const natureWave = (cycles = 3, amplitude = 0.25) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const w = Math.sin(k * Math.PI * 2 * cycles) + + 0.5 * Math.sin(k * Math.PI * 2 * cycles * 1.5 + 1.2) + + 0.25 * Math.sin(k * Math.PI * 2 * cycles * 3 + 2.4); + return amplitude * env * w * 0.6; +}; + +// Flicker:火焰闪烁——伪随机采样 + 线性插值 + 正弦包络 +const natureFlicker = (rate = 15, intensity = 0.2, seed = 7) => { + let s = seed; + const rand = () => { s = (s * 9301 + 49297) % 233280; return s / 233280; }; + const samples = []; + for (let i = 0; i <= rate + 1; i++) samples.push(rand()); + return (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const pos = k * rate; + const idx = Math.floor(pos); + const t = pos - idx; + const a = samples[idx]; + const b = samples[idx + 1]; + const interp = a + (b - a) * t; + return intensity * env * (interp - 0.5) * 2; + }; +}; + +// Gust:风——N 次高斯阵风叠加 +const natureGust = (gusts = 3, peak = 0.25) => { + const centers = []; + const span = 0.7; + for (let i = 0; i < gusts; i++) { + centers.push(0.15 + i * (span / Math.max(1, gusts - 1))); + } + return (k) => { + if (k <= 0 || k >= 1) return 0; + let sum = 0; + for (const c of centers) { + sum += Math.exp(-((k - c) ** 2) / (2 * 0.08 * 0.08)); + } + return peak * sum / gusts * 1.8; + }; +}; + +const Nature = Object.freeze({ + Wave: natureWave(), + Flicker: natureFlicker(), + Gust: natureGust(), +}); + +// ─── §15 Impact 撞击 / 落地 ──────────────────────────────────────────────── + +// Rain:雨滴下落——重力加速段 + 撞击 + 小幅余震 +const impactRain = (impactAt = 0.7, rippleAmp = 0.08) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < impactAt) { + const t = k / impactAt; + return t * t; + } + const t = (k - impactAt) / (1 - impactAt); + return 1 + rippleAmp * Math.exp(-4 * t) * Math.sin(t * Math.PI * 6); +}; + +// Hammer:锤击——抬起蓄力(负值)→ 快速下击 → 微反弹 +const impactHammer = (liftDepth = 0.25) => { + const liftEnd = 0.35, strikeEnd = 0.6; + return (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < liftEnd) { + const t = k / liftEnd; + return -liftDepth * Math.sin(t * Math.PI); + } + if (k < strikeEnd) { + const t = (k - liftEnd) / (strikeEnd - liftEnd); + return t * t; + } + const t = (k - strikeEnd) / (1 - strikeEnd); + return 1 - 0.06 * Math.exp(-5 * t) * Math.sin(t * Math.PI * 4); + }; +}; + +// BounceDrop:下落 + 多次衰减反弹 +const impactBounceDrop = (bounces = 3, rebound = 0.25) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.4) { + const t = k / 0.4; + return t * t; + } + const t = (k - 0.4) / 0.6; + const env = Math.exp(-2.5 * t); + const wave = Math.abs(Math.sin(t * Math.PI * bounces)); + return 1 - env * wave * rebound; +}; + +// Slap:拍击——快速接触 + 短暂保持 + 快速撤回 +const impactSlap = (contactAt = 0.3, holdRatio = 0.1) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < contactAt) { + const t = k / contactAt; + return t * t; + } + if (k < contactAt + holdRatio) return 1; + const t = (k - contactAt - holdRatio) / (1 - contactAt - holdRatio); + return (1 - t) * (1 - t); +}; + +// ArrowHit:箭中靶——匀速飞行 + 命中 + 插入后高频振颤衰减 +const impactArrowHit = (impactAt = 0.5) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < impactAt) { + const t = k / impactAt; + return t * (0.7 + 0.3 * t); + } + const t = (k - impactAt) / (1 - impactAt); + const env = Math.exp(-5 * t); + const wave = Math.sin(t * Math.PI * 10); + return 1 + 0.1 * env * wave; +}; + +// Shatter:撞碎——下落 + 撞击 + 能量 impulse 爆发 + 回到 1 +const impactShatter = (impactAt = 0.55, burstAmp = 0.35) => { + const sharp = 5; + const tail = sharp * Math.exp(1 - sharp); + return (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < impactAt) { + const t = k / impactAt; + return t * t; + } + const t = (k - impactAt) / (1 - impactAt); + const h = sharp * t; + const impulseVal = h * Math.exp(1 - h) - tail * t; + return 1 + burstAmp * impulseVal; + }; +}; + +const Impact = Object.freeze({ + Rain: impactRain(), + Hammer: impactHammer(), + BounceDrop: impactBounceDrop(), + Slap: impactSlap(), + ArrowHit: impactArrowHit(), + Shatter: impactShatter(), +}); + +// ─── §16 Rhythm 节奏 / 冲击 ──────────────────────────────────────────────── + +// BassDrop:EDM 重拍——缓慢蓄力 → pause pre-drop → 瞬间掉到 1 → 持续并有微脉动 +const rhythmBassDrop = () => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.4) { + const t = k / 0.4; + return 0.4 * Math.pow(t, 2.5); + } + if (k < 0.48) { + const t = (k - 0.4) / 0.08; + return 0.4 - 0.2 * t; + } + if (k < 0.52) { + const t = (k - 0.48) / 0.04; + return 0.2 + 0.8 * t; + } + const t = (k - 0.52) / 0.48; + return 1 - 0.04 * Math.sin(t * Math.PI * 8) * (1 - t); +}; + +// PunchCombo:拳击三连击——jab-jab-cross,第三拳最重最宽 +const rhythmPunchCombo = (peak = 0.4) => { + const pattern = [ + { c: 0.15, w: 0.04, a: 0.75 }, + { c: 0.35, w: 0.04, a: 0.75 }, + { c: 0.7, w: 0.055, a: 1.0 }, + ]; + return (k) => { + if (k <= 0 || k >= 1) return 0; + let sum = 0; + for (const { c, w, a } of pattern) { + sum += a * Math.exp(-((k - c) ** 2) / (2 * w * w)); + } + return peak * sum; + }; +}; + +// Staccato:断奏——均匀节拍内 duty 占空比 sin 脉冲 +const rhythmStaccato = (beats = 4, duty = 0.3) => (k) => { + if (k <= 0 || k >= 1) return 0; + const beatLen = 1 / beats; + const phase = (k / beatLen) - Math.floor(k / beatLen); + if (phase > duty) return 0; + const t = phase / duty; + return Math.sin(t * Math.PI); +}; + +// Kick:极限单击——瞬速冲到 peak,之后强指数衰减 +const rhythmKick = (peak = 1.2) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < 0.05) return peak * k / 0.05; + const t = (k - 0.05) / 0.95; + return peak * Math.exp(-4 * t); +}; + +// Crescendo:渐强——N 次高斯峰,间距递减、幅度递增 +const rhythmCrescendo = (beats = 4) => { + const centers = []; + for (let i = 0; i < beats; i++) { + const t = Math.pow((i + 1) / beats, 1.4); + centers.push({ c: Math.max(0.05, t - 0.08), w: 0.03, a: (i + 1) / beats }); + } + return (k) => { + if (k <= 0 || k >= 1) return 0; + let sum = 0; + for (const { c, w, a } of centers) { + sum += a * Math.exp(-((k - c) ** 2) / (2 * w * w)); + } + return sum; + }; +}; + +// DunDunDun:悬疑递进——3 击幅度递增,末击更宽形成持续感 +const rhythmDunDunDun = () => { + const bell = (t, c, w) => Math.exp(-((t - c) ** 2) / (2 * w * w)); + return (k) => { + if (k <= 0 || k >= 1) return 0; + return 0.3 * bell(k, 0.15, 0.025) + + 0.6 * bell(k, 0.35, 0.03) + + 1.0 * bell(k, 0.68, 0.09); + }; +}; + +// BellToll:钟声——瞬间起振 + 指数衰减调幅的余弦振荡 +const rhythmBellToll = (decay = 3, freq = 8) => { + const strike = 0.05; + return (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < strike) return k / strike; + const t = k - strike; + return Math.exp(-decay * t) * Math.cos(freq * Math.PI * t); + }; +}; + +const Rhythm = Object.freeze({ + BassDrop: rhythmBassDrop(), + PunchCombo: rhythmPunchCombo(), + Staccato: rhythmStaccato(), + Kick: rhythmKick(), + Crescendo: rhythmCrescendo(), + DunDunDun: rhythmDunDunDun(), + BellToll: rhythmBellToll(), +}); + +// ─── §17 UI 反馈 ─────────────────────────────────────────────────────────── + +// ClickSnap:按钮点击——压下(负偏移)→ 回弹微过冲 → 归零 +const uiClickSnap = (pressDepth = 0.3, reboundPeak = 0.1) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < 0.2) { + const t = k / 0.2; + return -pressDepth * Math.sin(t * Math.PI / 2); + } + if (k < 0.5) { + const t = (k - 0.2) / 0.3; + return -pressDepth + (pressDepth + reboundPeak) * (1 - Math.pow(1 - t, 3)); + } + const t = (k - 0.5) / 0.5; + return reboundPeak * Math.exp(-4 * t) * Math.cos(t * Math.PI * 3); +}; + +// HoverBloom:悬停高亮——梯形包络(快升 → plateau → 快降) +const uiHoverBloom = (riseRatio = 0.2, fallRatio = 0.3) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < riseRatio) { + const t = k / riseRatio; + return 1 - Math.pow(1 - t, 3); + } + if (k < 1 - fallRatio) return 1; + const t = (k - (1 - fallRatio)) / fallRatio; + return Math.pow(1 - t, 3); +}; + +// ErrorShake:错误反馈——方波化高频 shake +const uiErrorShake = (amplitude = 0.15, count = 5) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = 1 - k; + const raw = Math.sin(k * Math.PI * 2 * count); + const clipped = Math.sign(raw) * Math.min(1, Math.abs(raw) * 1.8); + return amplitude * env * clipped; +}; + +// SuccessPop:成功庆祝——瞬速 scale 到 1.2 → 阻尼余弦回到 1 +const uiSuccessPop = (overshoot = 0.2) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.4) { + const t = k / 0.4; + return (1 + overshoot) * (1 - Math.pow(1 - t, 2)); + } + const t = (k - 0.4) / 0.6; + return 1 + overshoot * Math.exp(-5 * t) * Math.cos(t * Math.PI * 3); +}; + +// RippleOut:Material 点击涟漪——早峰后淡出 +const uiRippleOut = () => (k) => { + if (k <= 0 || k >= 1) return 0; + return 6.75 * k * Math.pow(1 - k, 2); +}; + +const UI = Object.freeze({ + ClickSnap: uiClickSnap(), + HoverBloom: uiHoverBloom(), + ErrorShake: uiErrorShake(), + SuccessPop: uiSuccessPop(), + RippleOut: uiRippleOut(), +}); + +// ─── §18 Magic 能量 / 魔法 ───────────────────────────────────────────────── + +// ManaCharge:魔法蓄能——指数积蓄 + 高频 pulses +const magicManaCharge = () => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + const base = (Math.exp(3 * k) - 1) / (Math.exp(3) - 1); + const pulse = 0.04 * Math.sin(k * Math.PI * 8) * k; + return base + pulse; +}; + +// SpellCast:施法——蓄能 + 瞬冲 1 + 拖尾衰减 +const magicSpellCast = (chargeEnd = 0.4) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < chargeEnd) { + const t = k / chargeEnd; + return 0.3 * Math.pow(t, 2) * (1 + 0.2 * Math.sin(t * Math.PI * 6)); + } + if (k < chargeEnd + 0.1) { + const t = (k - chargeEnd) / 0.1; + return 0.3 + 0.7 * t; + } + const t = (k - chargeEnd - 0.1) / (1 - chargeEnd - 0.1); + return Math.exp(-2 * t) * (1 + 0.1 * Math.cos(t * Math.PI * 4)); +}; + +// Teleport:瞬移——加速压缩 → 完全消失(平顶 1)→ 加速重现 +const magicTeleport = () => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < 0.45) { + const t = k / 0.45; + return t * t * t; + } + if (k < 0.55) return 1; + const t = (k - 0.55) / 0.45; + return Math.pow(1 - t, 3); +}; + +// Shield:护盾——波纹扩散过冲到 1.2 → 稳定到 1 → 微脉动 +const magicShield = () => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.3) { + const t = k / 0.3; + return 1.2 * (1 - Math.pow(1 - t, 2)); + } + if (k < 0.6) { + const t = (k - 0.3) / 0.3; + return 1.2 - 0.2 * t; + } + const t = (k - 0.6) / 0.4; + return 1 + 0.03 * Math.sin(t * Math.PI * 3); +}; + +// MagicAura:魔法光环——基频 + 2 次谐波 + 3 次泛音的正弦叠加 +const magicAura = (peak = 0.15) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const fundamental = 0.6 * Math.sin(k * Math.PI * 2); + const harmonic = 0.3 * Math.sin(k * Math.PI * 4 + 1); + const overtone = 0.1 * Math.sin(k * Math.PI * 6 + 2); + return peak * env * (fundamental + harmonic + overtone); +}; + +const Magic = Object.freeze({ + ManaCharge: magicManaCharge(), + SpellCast: magicSpellCast(), + Teleport: magicTeleport(), + Shield: magicShield(), + MagicAura: magicAura(), +}); + +// ─── §19 Animal 动物动作 ─────────────────────────────────────────────────── + +// CatPounce:猫扑击——蹲伏蓄力 + 起跳 + 空中抛物线 + 落地微压 +const animalCatPounce = () => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.2) { + const t = k / 0.2; + return -0.2 * Math.sin(t * Math.PI); + } + if (k < 0.3) { + const t = (k - 0.2) / 0.1; + return 0.5 * t * t; + } + if (k < 0.8) { + const t = (k - 0.3) / 0.5; + return 0.5 + 0.5 * t + 0.2 * Math.sin(t * Math.PI); + } + const t = (k - 0.8) / 0.2; + return 1 + 0.05 * Math.sin(t * Math.PI); +}; + +// BirdFlap:翅膀拍打——不对称基波(下扑快、上挥慢)+ sin 包络 +const animalBirdFlap = (flaps = 4) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const phase = k * Math.PI * 2 * flaps; + const wave = Math.sin(phase) - 0.3 * Math.sin(phase * 2); + return 0.2 * env * wave; +}; + +// SnakeSlither:蛇蜿蜒——连续 S 波 +const animalSnakeSlither = (waves = 3) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const wave = Math.sin(k * Math.PI * 2 * waves); + return 0.2 * env * wave; +}; + +// ButterflyFlit:蝴蝶乱飞——seed 可复现的随机采样 + cubic 平滑插值 +const animalButterflyFlit = (seed = 13) => { + let s = seed; + const rand = () => { s = (s * 9301 + 49297) % 233280; return s / 233280; }; + const samples = []; + for (let i = 0; i <= 26; i++) samples.push(rand() - 0.5); + return (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const pos = k * 25; + const idx = Math.floor(pos); + const t = pos - idx; + const smooth = t * t * (3 - 2 * t); + const interp = samples[idx] + (samples[idx + 1] - samples[idx]) * smooth; + return 0.3 * env * interp; + }; +}; + +// HorseGallop:马奔驰——每周期 4 蹄击地 + 空中相位间隙 +const animalHorseGallop = (cycles = 3) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const cyclePos = (k * cycles) - Math.floor(k * cycles); + const bell = (c, w = 0.04) => Math.exp(-((cyclePos - c) ** 2) / (2 * w * w)); + return 0.25 * env * (bell(0.0) + bell(0.18) + bell(0.36) + bell(0.54)); +}; + +const Animal = Object.freeze({ + CatPounce: animalCatPounce(), + BirdFlap: animalBirdFlap(), + SnakeSlither: animalSnakeSlither(), + ButterflyFlit: animalButterflyFlit(), + HorseGallop: animalHorseGallop(), +}); + +// ─── 导出(形态分类:Progress / Pulse / Wave) ───────────────────────────── +// +// 上方各主题常量(Physics / Motion / Step / Attention / Breath / Heart / +// MathExt / Explosion / Nature / Impact / Rhythm / UI / Magic / Animal) +// 及业界库 factory(libSpring / libSteps / libHeartBeat)仅作为 +// "源池"使用,不再作为顶层导出;由下列 Progress / Pulse / Wave 三个按形态 +// 分类的命名空间统一暴露。 +// +// 通用 UI 柔化(Smooth / Bezier 两组共 6 条命名曲线)已整组移除——数值上 +// 与原生 Sinusoidal/Quadratic/Cubic 等价;需定制贝塞尔请直接调用顶层 +// cubicBezier('Material.Standard' | x1,y1,x2,y2) 工厂。 + +// Progress —— 单调或衰减至 1 的曲线(A→B 过渡) +const Progress = Object.freeze({ + // Physics:原生 + Spring(Framer Motion 参数化弹簧) + Physics: Object.freeze({ + ...Physics, // SpringSoft / SpringStiff / DampedOscillation + Spring: libSpring(), // Framer Motion 风格默认弹簧 + }), + Motion, // Anticipate / Overshoot110 / Overshoot125 / SnapBack / Swing + // Step:固定段数实例 —— Steps4/6/8/12End 覆盖实用区间,无任意段数工厂 + Step: Object.freeze({ + ...Step, // Steps4End / Steps8End / Steps12End + Steps6: libSteps(), + }), + Math: Object.freeze({ + Tremor: MathExt.Tremor, + }), + Impact: Object.freeze({ + Rain: Impact.Rain, + Hammer: Impact.Hammer, + BounceDrop: Impact.BounceDrop, + ArrowHit: Impact.ArrowHit, + Shatter: Impact.Shatter, + }), + Rhythm: Object.freeze({ + BassDrop: Rhythm.BassDrop, + }), + UI: Object.freeze({ + SuccessPop: UI.SuccessPop, + }), + Magic: Object.freeze({ + ManaCharge: Magic.ManaCharge, + Shield: Magic.Shield, + }), + Animal: Object.freeze({ + CatPounce: Animal.CatPounce, + }), +}); + +// Pulse —— 单次返零脉冲(f(0)=f(1)=0, 单主峰;reversals ≤ 2 为主) +const Pulse = Object.freeze({ + Attention: Object.freeze({ + Ping: Attention.Ping, + }), + Breath: Object.freeze({ + Deep: Breath.Deep, + Sigh: Breath.Sigh, + }), + Heart: Object.freeze({ + Calm: Heart.Calm, + }), + Math: Object.freeze({ + JumpArc: MathExt.JumpArc, // 对称抛物 4k(1-k) + BoomerangSharp: mathBoomerang(E.Cubic.In), // 尖峰回程:缓→冲到峰→缓回(峰值锐利) + BoomerangSoft: mathBoomerang(E.Cubic.Out), // 平顶回程:快→在峰上停留→快回(峰值平滑) + }), + Explosion: Object.freeze({ + Impulse: Explosion.Impulse, + Flash: Explosion.Flash, + Recoil: Explosion.Recoil, + Implosion: Explosion.Implosion, + }), + Impact: Object.freeze({ + Slap: Impact.Slap, + }), + Rhythm: Object.freeze({ + Kick: Rhythm.Kick, + }), + UI: Object.freeze({ + ClickSnap: UI.ClickSnap, + HoverBloom: UI.HoverBloom, + RippleOut: UI.RippleOut, + }), + Magic: Object.freeze({ + SpellCast: Magic.SpellCast, + Teleport: Magic.Teleport, + }), +}); + +// Wave —— 周期多峰振荡(f(0)=f(1)=0, 多次反转) +const Wave = Object.freeze({ + Attention: Object.freeze({ + Wiggle: Attention.Wiggle, + Strum: Attention.Strum, + }), + Breath: Object.freeze({ + Normal: Breath.Normal, + Panting: Breath.Panting, + }), + Heart: Object.freeze({ + Excited: Heart.Excited, + LubDub: Heart.LubDub, + Beat: libHeartBeat(), // 迁移自 Lib.HeartBeat + }), + Math: Object.freeze({ + Pendulum: MathExt.Pendulum, + }), + Nature, // Wave / Flicker / Gust + Rhythm: Object.freeze({ + PunchCombo: Rhythm.PunchCombo, + Staccato: Rhythm.Staccato, + Crescendo: Rhythm.Crescendo, + DunDunDun: Rhythm.DunDunDun, + BellToll: Rhythm.BellToll, + }), + UI: Object.freeze({ + ErrorShake: UI.ErrorShake, + }), + Magic: Object.freeze({ + MagicAura: Magic.MagicAura, + }), + Animal: Object.freeze({ + BirdFlap: Animal.BirdFlap, + SnakeSlither: Animal.SnakeSlither, + ButterflyFlit: Animal.ButterflyFlit, + HorseGallop: Animal.HorseGallop, + }), +}); + +const customEasings = Object.freeze({ + makeOutIn, + OutIn, + Progress, + Pulse, + Wave, + cubicBezier, +}); + +exports.customEasings = customEasings; +exports.default = customEasings; diff --git a/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/scriptScene.js b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/scriptScene.js new file mode 100644 index 0000000000000000000000000000000000000000..8642c5b96e62ccd27ab63ba9d26170c4e3bf2d07 --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/scriptScene.js @@ -0,0 +1,800 @@ +/** + * 场景核心模块 + * + * 包含Three.js核心对象的创建和管理 + * 提供场景管理的核心功能:初始化、配置和更新 + */ + +// ThreeJS Env +// 导入TWEEN库 +// const TWEEN = require('../lib/tween'); +// 导入Three.js库 +// const THREE = require('three'); + + +// Effect Env +// 导入TWEEN库 +const TWEEN = require('./tween'); +// 导入自定义缓动函数库(OutIn 模式等官方未提供的组合) +const customEasings = require('./customEasings').customEasings; +// 导入Three.js 的 wrapper库 +const THREE = require('./three-amg-wrapper').THREE; +const { ShaderPass } = require('./ShaderPass.js'); +/** + * ScriptScene类 - 3D场景管理器 + * 负责创建和管理Three.js场景、相机、渲染器及场景对象 + */ +class ScriptScene { + /** + * 构造函数,创建场景管理器 + * @param {effect.Amaz.Scene} [amgScene] - AMG场景对象,可选参数 + * @param {HTMLElement} [container] - 放置渲染器的DOM容器,可选参数 + */ + 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(0x333333); + 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(); + + // 移除渲染器的DOM元素 + 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); + } + + // 清理TWEEN动画 + if (this.sceneObjects && this.sceneObjects.tweens) { + this.sceneObjects.tweens.forEach(tween => { + if (tween && typeof tween.stop === 'function') { + tween.stop(); + } + }); + this.sceneObjects.tweens = []; + } + + // 清理多pass + 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; + } + + /** + * 初始化Three.js核心对象 + * 包括场景、相机和渲染器 + */ + 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, // 纵横比 + 0.1, // 近平面 + 10000 // 远平面 + ); + this.camera.position.z = 10; // 设置默认相机位置 + this.scene.add(this.camera); + + // 创建渲染器,启用抗锯齿 + // 当amgScene为null时,创建渲染器 + 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 = {}; + + // 创建TWEEN实例 + this.TWEEN = TWEEN; + // 自定义缓动函数库:使用方式 this.customEasings.OutIn.Back 等 + this.customEasings = customEasings; + + // 时长 毫秒 + this.Duration = 2000; + } + + /** + * 添加ShaderPass + * @param {Array} shaderPassConfigs - ShaderPass配置数组 + * @return {void} + */ + 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); + // console.log('ShaderPass created:', shaderPass, className); + this.composer.addPass(shaderPass); + this.shaderPasses.push(shaderPass); + }); + } + + /** + * 设置后处理 + * @param {Array} shaderPassConfigs - ShaderPass配置数组 + * @return {void} + */ + 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); + } + +//===begin_pp=== +initPostProcessing() {} +//===end_pp=== + + /** + * 初始化场景 + * 设置基本的Three.js环境,添加渲染器到DOM + * @param {HTMLElement} container - 放置渲染器的DOM容器 + */ + 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()); + } + } + + /** + * 开始场景动画循环 + * @param {Function} updateCallback - 每帧调用的更新函数 + */ + start(updateCallback) { + if (this.isAnimating) return; + + this.isAnimating = true; + + // 如果提供了更新回调,使用requestAnimationFrame + if (updateCallback) { + const animateFrame = () => { + if (!this.isAnimating) return; + updateCallback(); + this.animationFrameId = requestAnimationFrame(animateFrame); + }; + + animateFrame(); + } else { + // 否则使用Three.js的setAnimationLoop,直接调用update渲染场景 + this.renderer.setAnimationLoop(() => { + this.update(); + }); + } + } + + + + /** + * 更新场景(由外部动画循环调用) + * @param {number} timestamp - 当前时间戳 + */ + updateScene(timestamp) { + // 标记动画开始 + if (!this.isAnimating) { + this.isAnimating = true; + } + + // 直接调用默认更新函数,传入时间戳 + this.defaultUpdate(timestamp); + } + + /** + * 更新并渲染场景 + * 在每一帧调用,将当前场景通过渲染器绘制到屏幕 + */ + update() { + if (this.usePostProcessing && this.composer) { + // 确保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.composer) { + // this.composer.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); + } + } + + /** + * 根据时间直接设置动画状态(用于时间跳转) + * @param {number} time - 动画时间(毫秒) + */ + seekToTime(time) { + // 标记动画开始 + if (!this.isAnimating) { + this.isAnimating = true; + } + + // 限制时间范围 + const clampedTime = Math.max(0, Math.min(time, this.Duration)); + + // seek ShaderPass后处理逻辑,该函数已预先定义,无需生成_predef_seekShaderPass实现 + if (this._predef_seekShaderPass) + { + this._predef_seekShaderPass(clampedTime); + } + + if (!this.sceneObjects.tweens || this.sceneObjects.tweens.length === 0) { + return; + } + + // 使用逆序遍历 TWEEN,确保正确的属性覆盖优先级 + // 逆序处理:让开始时间晚的tween先处理,开始时间早的tween后处理并覆盖 + + 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; + + // 将tween分为三种,未开始,进行中,已结束 + // 分到3个列表中 + + 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(); + } + +//===begin=== +//===滑竿begin=== +//===滑竿end=== +/** + * 初始化滑竿 + */ +setupSliders(){ +} + +/** + * 更新滑竿 + */ +updateSliders(){ +} + +/** + * 初始化一个完整的基本场景(不包含动画循环) + * 包括相机、场景对象的创建和特效材质 + * @returns {Object} 场景中的对象引用 + */ +setupScene() { + // 初始化场景对象容器 + this.initSceneObjects(); + + // 更新滑竿 + this.setupSliders(); + this.updateSliders(); + + // 设置场景背景为黑色 + this.scene.background = new THREE.Color(0x000000); + + // 创建效果平面 + this.createPlane(); + + // 设置动画 + this.setupAnimation(); + + return this.sceneObjects; +} + +/** + * 初始化场景对象容器 + */ +initSceneObjects() { + this.sceneObjects = { + plane: null, // 主平面对象 + material: null, // 效果材质 + tweens: [] // 动画对象数组 + }; +} + +/** + * 创建效果平面 + */ +createPlane() { + // 创建平面几何体,宽高比为1:1 + 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); +} + +/** + * 创建效果平面的着色器材质 + * @returns {THREE.ShaderMaterial} 效果平面着色器材质 + */ +createMaterial() { + // 确保纹理已加载 + if (!this.texture1 || !this.texture2) { + console.error("纹理未加载!"); + return new THREE.MeshBasicMaterial({ color: 0xff0000 }); + } + + // 为纹理设置适当的参数 + 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 = []; + + // 创建从0到1的动画 + const tween1 = new TWEEN.Tween({ intensity: 0, progress: 0 }) + .to({ intensity: 1, progress: 0.5 }, duration * 0.35) + .delay(duration * 0.15) + .easing(TWEEN.Easing.Linear.None) + .onUpdate((obj) => { + // 遍历obj中的所有属性,自动设置参数 + for (const key in obj) { + this.shaderPass.setParameter(key, obj[key]); + } + }); + + // 创建从1到0的动画 + const tween2 = new TWEEN.Tween({ intensity: 1, progress: 0.5 }) + .to({ intensity: 0, progress: 1 }, duration * 0.35) + .delay(duration * 0.5) + .easing(TWEEN.Easing.Linear.None) + .onUpdate((obj) => { + // 遍历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); + } +} +//===end=== + + /** + * 默认的场景更新函数,实现轨道交错转场动画 + */ + defaultUpdate(timestamp) { + // 更新所有TWEEN动画 + 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(); + } + + //===Predefined Function Begin=== +_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); + + // center + 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); + + // top + 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 * 0.5 + scaleYTop * 10 * 0.5, parentPosition.z + offset.z); + planeTop.scale.set(scaleXTop, scaleYTop, 1); + + this.scene.add(planeTop); + parent.attach(planeTop); + + // bottom + 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 * 0.5 - scaleYBottom * 10 * 0.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.play(); + video.load(); + + // video.style.position = 'absolute'; + // video.style.top = '400px'; + // video.style.left = '0px'; + // video.style.width = '480px'; + // video.style.height = '360px'; + // video.style.zIndex = '100'; + // document.body.appendChild(video); + + 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 / 1000 * 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); + } + } + } + }) +}//===Predefined Function End=== +} + +// 导入Three.js库 +// module.exports = ScriptScene; + +// 导入Three.js 的 wrapper库 +exports.ScriptScene = ScriptScene; diff --git a/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/three-amg-wrapper.js b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/three-amg-wrapper.js new file mode 100644 index 0000000000000000000000000000000000000000..a5fd4883bac974897a1c16105d092d5a770bfa4c --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/three-amg-wrapper.js @@ -0,0 +1,399 @@ +/** + * ThreeJS 到 AMG 的包装器 + * 让基于ThreeJS开发的应用能够在AMG引擎上运行 + * 此包装器将ThreeJS的API转换为AMG引擎的调用,实现无缝迁移 + */ + +// 获取AMG引擎API +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'); + +// 模拟浏览器环境中的window对象,使ThreeJS代码能在非浏览器环境中运行 +if (typeof window === 'undefined') { + // 定义模拟的window对象 + const mockWindow = { + innerWidth: 720, + innerHeight: 1280, + devicePixelRatio: 1, + addEventListener: function(event, callback) { + // 空函数,模拟事件监听 + }, + requestAnimationFrame: function(callback) { + // 空实现 + // 在实际环境中应该取消动画帧请求 + }, + cancelAnimationFrame: function(id) { + // 空实现 + // 在实际环境中应该取消动画帧请求 + }, + removeEventListener: function(event, callback) { + // 空实现 + // 在实际环境中应该取消事件监听 + } + }; + + // 定义模拟的document对象 + 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; +} + +// 定义命名空间对象,类似于THREE +const THREE = {}; + +// 常量定义(从 wrapper/Constants 统一导入,避免重复定义) +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._amgScene = new Amaz.Scene(); + this._objects = []; + + // 将场景添加到AMG管理器 + // effect.Amaz.AmazingManager.addScene(this._amgScene); + + // 设置全局场景实例 + setCurrentScene(this); + + console.log('AMG scene created'); + } + + /** + * 添加对象到场景 + * 支持一次添加多个对象,如: scene.add(obj1, obj2, obj3) + * @param {...Object} objects - 要添加的对象(可变参数) + */ + 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属性'); + } + } + } + + /** + * 从场景中移除对象,不删除AMG实体 + * @param {Object} object - 要移除的对象 + */ + 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.'); + } + } + + /** + * 从场景中删除对象,删除AMG实体 + */ + 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)); + } + + /** + * 析构函数,清理场景资源 + * 在不再需要场景时调用,确保释放所有资源并从AMG管理器中移除 + */ + dispose() { + console.log('Scene: 开始清理场景资源'); + + // 清理所有对象 + while (this._objects.length > 0) { + const object = this._objects[0]; + this.delete(object); + + // 如果对象有自己的dispose方法,调用它 + 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(); + } + } + } + + // 从AMG管理器中移除场景 + 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) { + // 二次贝塞尔曲线公式: B(t) = (1-t)²P₀ + 2(1-t)tP₁ + t²P₂ + 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; + } +} + + +/** #region 基础数学与类型 */ +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; +/** #endregion 基础数学与类型 */ + +/** #region 场景与相机 */ +THREE.Scene = Scene; +/** #endregion 场景与相机 */ + +/** #region 渲染器 */ +THREE.WebGLRenderer = WebGLRenderer; +/** #endregion 渲染器 */ + +/** #region 几何体与属性 */ +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; +/** #endregion 几何体与属性 */ + +/** #region 材质与着色 */ +THREE.Material = Material; +THREE.MeshBasicMaterial = MeshBasicMaterial; +THREE.ShaderMaterial = ShaderMaterial; +/** #endregion 材质与着色 */ + +/** #region 纹理相关 */ +THREE.Texture = Texture; +THREE.VideoTexture = VideoTexture; +THREE.TextureLoader = TextureLoader; +/** #endregion 纹理相关 */ + +/** #region 物体与层级 */ +THREE.Object3D = Group; +THREE.Group = Group; +THREE.Mesh = Mesh; +THREE.PerspectiveCamera = PerspectiveCamera; +/** #endregion 物体与层级 */ + +// 导出THREE命名空间和工具函数 +exports.THREE = THREE; +exports.getCurrentScene = getCurrentScene; \ No newline at end of file diff --git a/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/tween.js b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/tween.js new file mode 100644 index 0000000000000000000000000000000000000000..e66c48c1214e9291408c0279764dfea2a447c79c --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/tween.js @@ -0,0 +1,1455 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +/** + * The Ease class provides a collection of easing functions for use with tween.js. + */ +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 0.5 * amount * amount; + } + return -0.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 0.5 * amount * amount * amount; + } + return 0.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 0.5 * amount * amount * amount * amount; + } + return -0.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 0.5 * amount * amount * amount * amount * amount; + } + return 0.5 * ((amount -= 2) * amount * amount * amount * amount + 2); + }, + }), + Sinusoidal: Object.freeze({ + In: function (amount) { + return 1 - Math.sin(((1.0 - amount) * Math.PI) / 2); + }, + Out: function (amount) { + return Math.sin((amount * Math.PI) / 2); + }, + InOut: function (amount) { + return 0.5 * (1 - Math.sin(Math.PI * (0.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 0.5 * Math.pow(1024, amount - 1); + } + return 0.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 -0.5 * (Math.sqrt(1 - amount * amount) - 1); + } + return 0.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 - 0.1) * 5 * Math.PI) + 1; + }, + InOut: function (amount) { + if (amount === 0) { + return 0; + } + if (amount === 1) { + return 1; + } + amount *= 2; + if (amount < 1) { + return -0.5 * Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI); + } + return 0.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 0.5 * (amount * amount * ((s + 1) * amount - s)); + } + return 0.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 + 0.75; + } + else if (amount < 2.5 / 2.75) { + return 7.5625 * (amount -= 2.25 / 2.75) * amount + 0.9375; + } + else { + return 7.5625 * (amount -= 2.625 / 2.75) * amount + 0.984375; + } + }, + InOut: function (amount) { + if (amount < 0.5) { + return Easing.Bounce.In(amount * 2) * 0.5; + } + return Easing.Bounce.Out(amount * 2 - 1) * 0.5 + 0.5; + }, + }), + generatePow: function (power) { + if (power === void 0) { power = 4; } + power = power < Number.EPSILON ? Number.EPSILON : power; + power = power > 10000 ? 10000 : 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 < 0.5) { + return Math.pow((amount * 2), power) / 2; + } + return (1 - Math.pow((2 - amount * 2), power)) / 2 + 0.5; + }, + }; + }, +}); + +var now = function () { + // 优先使用原生performance.now() + // if (typeof performance !== 'undefined' && performance.now) { + // return performance.now(); + // } + + // Node.js环境:使用高精度时间 + if (typeof process !== 'undefined' && process.hrtime) { + if (!now._nodeStartTime) { + now._nodeStartTime = process.hrtime(); + } + var hrTime = process.hrtime(now._nodeStartTime); + return hrTime[0] * 1000 + hrTime[1] / 1000000; + } + + // 浏览器兜底:模拟performance.now()行为 + if (typeof now._startTime === 'undefined') { + now._startTime = Date.now(); + now._lastReturned = 0; + } + + var elapsed = Date.now() - now._startTime; + + // 确保时间单调递增,同时添加微小递增来模拟高精度 + if (elapsed <= now._lastReturned) { + now._lastReturned += 0.001; + } else { + now._lastReturned = elapsed; + } + + return now._lastReturned; +}; +function setNow(nowFunction) { + _nowFunc = nowFunction; +} + +/** + * Controlling groups of tweens + * + * Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components. + * In these cases, you may want to create your own smaller groups of tween + */ +var Group = /** @class */ (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]; + // Remove from any other group first, a tween can only be in one group at a time. + // @ts-expect-error library internal access + (_a = tween._group) === null || _a === void 0 ? void 0 : _a.remove(tween); + // @ts-expect-error library internal access + 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]; + // @ts-expect-error library internal access + tween._group = undefined; + delete this._tweens[tween.getId()]; + delete this._tweensAddedDuringUpdate[tween.getId()]; + } + }; + /** Return true if all tweens in the group are not paused or playing. */ + 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; + // Tweens are updated in "batches". If you add a new tween during an + // update, then the new tween will be updated in the next batch. + // If you remove a tween during an update, it may or may not be updated. + // However, if the removed tween was added during the current batch, + // then it will not be updated. + 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); + // After the onComplete callback completes, _isPlaying is updated to false, so if the total number of completed tweens is -1, then they are all complete. + 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) * 0.5; + var v1 = (p3 - p1) * 0.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; + }, + }, +}; + +/** + * Utils + */ +var Sequence = /** @class */ (function () { + function Sequence() { + } + Sequence.nextId = function () { + return Sequence._nextId++; + }; + Sequence._nextId = 0; + return Sequence; +}()); + +var mainGroup = new Group(); + +/** + * Tween.js - Licensed under the MIT license + * https://github.com/tweenjs/tween.js + * ---------------------------------------------- + * + * See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors. + * Thank you all, you're awesome! + */ +var Tween = /** @class */ (function () { + function Tween(object, group) { + this._isPaused = false; + this._pauseStart = 0; + this._valuesStart = {}; + this._valuesEnd = {}; + this._valuesStartRepeat = {}; + this._duration = 1000; + 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; + // eslint-disable-next-line + 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); + } + // Use "true" to restore old behavior (will be removed in future release). + 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 = 1000; } + 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 = 1000; } + 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) { + // If we were reversed (f.e. using the yoyo feature) then we need to + // flip the tween direction back to forward. + 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 dynamic is not enabled, clone the end values instead of using the passed-in end values. + 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 `to()` specifies a property that doesn't exist in the source object, + // we should not set that property in the object + if (propType === 'undefined' || propType === 'function') { + continue; + } + // Check if an Array was provided as property value + if (isInterpolationList) { + var endValues = _valuesEnd[property]; + if (endValues.length === 0) { + continue; + } + // Handle an array of relative values. + // Creates a local copy of the Array with the start value at the front + 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) { + // if (_valuesStart[property] === undefined) { // handle end values only the first time. NOT NEEDED? setupProperties is now guarded by _propertiesAreSetUp. + _valuesEnd[property] = temp; + // } + } + } + // handle the deepness of the values + if ((propType === 'object' || startValueIsArray) && startValue && !isInterpolationList) { + _valuesStart[property] = startValueIsArray ? [] : {}; + var nestedObject = startValue; + for (var prop in nestedObject) { + _valuesStart[property][prop] = nestedObject[prop]; + } + // TODO? repeat nested values? And yoyo? And array values? + _valuesStartRepeat[property] = startValueIsArray ? [] : {}; + var endValues = _valuesEnd[property]; + // If dynamic is not enabled, clone the end values instead of using the passed-in end values. + 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 { + // Save the starting value, but only once unless override is requested. + if (typeof _valuesStart[property] === 'undefined' || overrideStartingValues) { + _valuesStart[property] = startValue; + } + if (!startValueIsArray) { + // eslint-disable-next-line + // @ts-ignore FIXME? + _valuesStart[property] *= 1.0; // Ensures we're using numbers, not strings + } + if (isInterpolationList) { + // eslint-disable-next-line + // @ts-ignore FIXME? + _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; + }; + /** + * Removes the tween from whichever group it is in. + */ + 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; + }; + // eslint-disable-next-line + 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; + }; + /** + * @returns true if the tween is still playing after the update, false + * otherwise (calling update on a paused tween still returns true because + * it is still playing, just paused). + * + * @param autoStart - When true, calling update will implicitly call start() + * as well. Note, if you stop() or end() the tween, but are still calling + * update(), it will start again! + */ + 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; + // TODO use %? + // const timeIntoCurrentRepeat = elapsedTime % 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); + // properties transformations + 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; + } + // Reassign starting values, restart by making startTime = now + for (property in this._valuesStartRepeat) { + if (!this._yoyo && typeof this._valuesEnd[property] === 'string') { + this._valuesStartRepeat[property] = + // eslint-disable-next-line + // @ts-ignore FIXME? + 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++) { + // Make the chained tweens start exactly at the time they should, + // even if the `update()` method was called way past the duration of the tween + 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) { + // Don't update properties that do not exist in the source object + 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) { + // eslint-disable-next-line + // @ts-ignore FIXME? + this._updateProperties(_object[property], start, end, value); + } + else { + // Parses relative end values with start as base (e.g.: +10, -3) + end = this._handleRelativeValue(start, end); + // Protect against non numeric properties. + if (typeof end === 'number') { + // eslint-disable-next-line + // @ts-ignore FIXME? + _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'; + +/** + * Tween.js - Licensed under the MIT license + * https://github.com/tweenjs/tween.js + * ---------------------------------------------- + * + * See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors. + * Thank you all, you're awesome! + */ +var nextId = Sequence.nextId; +/** + * Controlling groups of tweens + * + * Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components. + * In these cases, you may want to create your own smaller groups of tweens. + */ +var TWEEN = mainGroup; +// This is the best way to export things in a way that's compatible with both ES +// Modules and CommonJS, without build hacks, and so as not to break the +// existing API. +// https://github.com/rollup/rollup/issues/1961#issuecomment-423037881 +/** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ +var getAll = TWEEN.getAll.bind(TWEEN); +/** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ +var removeAll = TWEEN.removeAll.bind(TWEEN); +/** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ +var add = TWEEN.add.bind(TWEEN); +/** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ +var remove = TWEEN.remove.bind(TWEEN); +/** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ +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, + /** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ + getAll: getAll, + /** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ + removeAll: removeAll, + /** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ + add: add, + /** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ + remove: remove, + /** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ + 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; \ No newline at end of file diff --git a/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Box2.js b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Box2.js new file mode 100644 index 0000000000000000000000000000000000000000..eb886973d02e86c0cb5201c6f1d953ce3c587e74 --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Box2.js @@ -0,0 +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.xthis.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;ithis.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.xthis.max.x||box.max.ythis.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; \ No newline at end of file diff --git a/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Box3.js b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Box3.js new file mode 100644 index 0000000000000000000000000000000000000000..4100dc7442d3a622827c8a415e24557f68c491f1 --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Box3.js @@ -0,0 +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=3?array[offset+2]:0;if(xthis.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=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.xthis.max.x||box.max.ythis.max.y||box.max.zthis.max.z)}}exports.Box3=Box3; \ No newline at end of file diff --git a/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..be3b8b1334a62f5e88c45feee098063a199fca55 --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js @@ -0,0 +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=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; \ No newline at end of file diff --git a/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..af9a8a13a46500e78f082a35e18d0b5932061234 --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js @@ -0,0 +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;iObject.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;i1?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; \ No newline at end of file diff --git a/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Constants.js b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Constants.js new file mode 100644 index 0000000000000000000000000000000000000000..6b8adda19a4d67236719804f5170889b39fd4582 --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Constants.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js new file mode 100644 index 0000000000000000000000000000000000000000..29b0aad5599401be17f967ba1d48851acb70c2ac --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js @@ -0,0 +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;i0||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;i0?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;imaxX)maxX=p.x;if(p.ymaxY)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; \ No newline at end of file diff --git a/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..f3dee08bf1c089e040fcfef228902ab9a39c93cb --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Earcut.js b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Earcut.js new file mode 100644 index 0000000000000000000000000000000000000000..953abffdf38c2def26df73fed180eff8c7644ced --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Earcut.js @@ -0,0 +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;imaxX)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=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=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.x&&p.x>=mx&&hx!==p.x&&pointInTriangle(hym.x||p.x===m.x&§orContainsSector(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.xb.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;i0||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=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;i0){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;imaxX)maxX=contour[i].x;if(contour[i].ymaxY)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;layerIdx0?-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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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; \ No newline at end of file diff --git a/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Group.js b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Group.js new file mode 100644 index 0000000000000000000000000000000000000000..90c4dbef65aa04d7a3bb6b6d76ec3317ea65a228 --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Group.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");class Group extends Object3D{constructor(name="Group_w"){super(name)}dispose(){super.dispose()}}exports.Group=Group; \ No newline at end of file diff --git a/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Material.js b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Material.js new file mode 100644 index 0000000000000000000000000000000000000000..81b97053ad9d1e4b1ef05d5ac6ed992487b2ca8e --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Material.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..dcf34d4cffb9de0869382a24690f78f60dda6049 --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js new file mode 100644 index 0000000000000000000000000000000000000000..41e6cd0a0eee7dd7bc497be5deac584806b68dc3 --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Mesh.js b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Mesh.js new file mode 100644 index 0000000000000000000000000000000000000000..254d69b074e797dd34c16d7dad723bbcc3b4895d --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Mesh.js @@ -0,0 +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;imaterial,set:value=>{material=value;if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;im.dispose&&m.dispose());else if(this.material.dispose)this.material.dispose()}}}exports.MeshWrapper=MeshWrapper; \ No newline at end of file diff --git a/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..ac394f66efc4e113a7127ee0f50ec672e4c5e9eb --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Object3D.js b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Object3D.js new file mode 100644 index 0000000000000000000000000000000000000000..8532c6122f839460aab34fe88957802ff523318b --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Object3D.js @@ -0,0 +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{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&¤tScene._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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js new file mode 100644 index 0000000000000000000000000000000000000000..ba39801de50d38ec04424f3c2ebfa2ff5d28fded --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js @@ -0,0 +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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..bc595fb80ad9e7c2f4d8360c67dbef556f3d6cbe --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js @@ -0,0 +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;iy0){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; \ No newline at end of file diff --git a/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..02dc1be955bc766de744222a7e75c65bf147bb61 --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js @@ -0,0 +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&¶meters.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{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=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=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=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; \ No newline at end of file diff --git a/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Shape.js b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Shape.js new file mode 100644 index 0000000000000000000000000000000000000000..ecde48b5ceb30812c922aa5c7cfe2aa7b50cabe4 --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Shape.js @@ -0,0 +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;i0){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;i0||(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;imaxX)maxX=p.x;if(p.ymaxY)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;i0?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;ipoints.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;itwoPi)deltaAngle-=twoPi;if(deltaAngle>4;uuid[i]=chars[i===19?r&3|8:r]}}return uuid.join("")}exports.Shape=Shape; \ No newline at end of file diff --git a/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..3786abc7d64ed80b56101c4ac9d30ce9fcb8f941 --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js @@ -0,0 +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;i0){const bounds=calculateBounds(flatVertices);const vertexOffset=vertices.length/3;for(let j=0;j0){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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}function calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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; \ No newline at end of file diff --git a/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..1ea27a55fbce9fc3771c66840c068e5ff6347092 --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Texture.js b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Texture.js new file mode 100644 index 0000000000000000000000000000000000000000..35bff49d732c9884e07bfcb5682f18a860485e1f --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Texture.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Vector2.js b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Vector2.js new file mode 100644 index 0000000000000000000000000000000000000000..a30a2431264ee62cec937714dfa9e50932ddedeb --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/js/ThreeJS/wrapper/Vector2.js @@ -0,0 +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)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)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)= 1.0) return texel2; + + float p = smoothstep(0.0, 1.0, progress); + float pulse = p * (1.0 - p); + + vec2 uv = vUv; + vec2 centered = uv - 0.5; + centered.x *= ratio; + + float radial = length(centered); + float angle = atan(centered.y, centered.x); + + float n1 = fbm(centered * splashScale + vec2(0.0, p * 2.3)); + float n2 = fbm(centered * (splashScale * 1.7) + vec2(3.1, -p * 1.7)); + float swirl = sin(angle * 7.0 + radial * 20.0 - p * 11.0 + n1 * 4.0) * 0.5 + 0.5; + + float fluidShape = mix(n1, n2, 0.4) * 0.6 + swirl * 0.4; + float boundary = mix(-0.22, 1.55, p); + float distField = radial + (fluidShape - 0.5) * 0.35 * swirlStrength; + + float mask = 1.0 - smoothstep(boundary - edgeSoftness, boundary + edgeSoftness, distField); + + vec2 dir = (radial > 1e-5) ? centered / radial : vec2(0.0, 0.0); + vec2 flow = vec2(-dir.y, dir.x) * (n2 - 0.5) + dir * (n1 - 0.5); + flow *= 0.05 * swirlStrength * pulse; + + vec2 uv1 = clamp(uv + flow, 0.0, 1.0); + vec2 uv2 = clamp(uv - flow * 1.2, 0.0, 1.0); + + vec4 src = texture2D(tDiffuse, uv1); + vec4 dst = texture2D(tDiffuse1, uv2); + + vec4 mixedColor = mix(src, dst, mask); + + float edgeBand = 1.0 - smoothstep(0.0, edgeSoftness * 1.5, abs(distField - boundary)); + float foam = edgeBand * pulse * (0.55 + 0.45 * fluidShape); + + mixedColor.rgb = mix(mixedColor.rgb, foamColor, clamp(foam * 0.35, 0.0, 1.0)); + mixedColor.rgb = clamp(mixedColor.rgb, 0.0, 1.0); + + return mixedColor; +} + +void main() { + // Get the pixel color from both textures + vec4 texel1 = texture2D(tDiffuse, vUv); + vec4 texel2 = texture2D(tDiffuse1, vUv); + + // --- Transition Configuration --- + const float fadeInEnd = 0.1; + const float fadeOutStart = 0.9; + + // 1. Calculate the transition's own progress. + float transitionProgress = clamp((progress - fadeInEnd) / (fadeOutStart - fadeInEnd), 0.0, 1.0); + vec4 transitionColor = transition(texel1, texel2, transitionProgress); + + // 2. Calculate smooth blending factors for the start and end zones. + float blendInFactor = smoothstep(0.0, fadeInEnd, progress); + float blendOutFactor = smoothstep(fadeOutStart, 1.0, progress); + + // 3. Apply the blending. + vec4 finalColor = mix(texel1, transitionColor, blendInFactor); + finalColor = mix(finalColor, texel2, blendOutFactor); + + gl_FragColor = finalColor; +} +//===end_frag_code=== +`; \ No newline at end of file diff --git a/scripts/7681319861905001746/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js b/scripts/7681319861905001746/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js new file mode 100644 index 0000000000000000000000000000000000000000..2c87ab8ca97aecc86f650141dcf51ecc1ee7f46e --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js @@ -0,0 +1,8 @@ +exports.source=` +varying vec2 vUv; + +void main() { + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); +} +`; \ No newline at end of file diff --git a/scripts/7681319861905001746/AmazingFeature/xshader/Unlit.frag b/scripts/7681319861905001746/AmazingFeature/xshader/Unlit.frag new file mode 100644 index 0000000000000000000000000000000000000000..2b8ef6c235afd5362d14d87961e5b7fa2fe044b1 --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/xshader/Unlit.frag @@ -0,0 +1,25 @@ +precision highp float; +uniform sampler2D u_AlbedoTexture; +uniform vec4 u_AlbedoColor; +uniform vec2 u_Repeat; +uniform vec2 u_Offset; +uniform float u_Translucency; +uniform float u_Opacity; +varying vec2 g_vary_uv0; +void main () +{ + vec2 uv_1; + uv_1.x = g_vary_uv0.x; + uv_1.y = (g_vary_uv0.y); + lowp vec4 tmpvar_2; + tmpvar_2 = texture2D (u_AlbedoTexture, (uv_1 * u_Repeat + u_Offset)); + lowp vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2.xyz * u_AlbedoColor.xyz); + lowp float tmpvar_4; + tmpvar_4 = (tmpvar_2.w * u_Translucency); + mediump vec4 tmpvar_5; + tmpvar_5.xyz = tmpvar_3; + tmpvar_5.w = tmpvar_4; + gl_FragColor = vec4(tmpvar_5.xyz * u_Opacity, tmpvar_5.w * u_Opacity); +} + diff --git a/scripts/7681319861905001746/AmazingFeature/xshader/Unlit.vert b/scripts/7681319861905001746/AmazingFeature/xshader/Unlit.vert new file mode 100644 index 0000000000000000000000000000000000000000..64a27d816e6146a0fb85643a9991207e5fda2acb --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/xshader/Unlit.vert @@ -0,0 +1,35 @@ +precision highp float; +attribute vec3 attPosition; +attribute vec2 attTexcoord0; + +//#define AMAZING_USE_BONES + +#ifdef AMAZING_USE_BONES +attribute vec4 attBoneIds; +attribute vec4 attWeights; +const int MAX_BONES = 50; +uniform mat4 u_Palatte[MAX_BONES]; +#endif + +uniform mat4 u_Model; +uniform mat4 u_MVP; +varying vec2 g_vary_uv0; + + + +void main () +{ + vec3 modelPostiton = attPosition; + vec4 homogeneous_pos = vec4(attPosition, 1.0); + g_vary_uv0 = attTexcoord0; + +#ifdef AMAZING_USE_BONES + mat4 boneTransform = u_Palatte[int(attBoneIds.x)] * attWeights.x; + boneTransform += u_Palatte[int(attBoneIds.y)] * attWeights.y; + boneTransform += u_Palatte[int(attBoneIds.z)] * attWeights.z; + boneTransform += u_Palatte[int(attBoneIds.w)] * attWeights.w; + gl_Position = u_MVP * boneTransform * homogeneous_pos; +#else + gl_Position = u_MVP * homogeneous_pos; +#endif +} diff --git a/scripts/7681319861905001746/AmazingFeature/xshader/noface.frag b/scripts/7681319861905001746/AmazingFeature/xshader/noface.frag new file mode 100644 index 0000000000000000000000000000000000000000..88e9ec343761b2395bae9430e6e55466b0367d67 --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/xshader/noface.frag @@ -0,0 +1,7 @@ +precision lowp float; +varying highp vec2 uv0; +uniform sampler2D u_albedo; +void main() +{ + gl_FragColor = texture2D(u_albedo, uv0); +} diff --git a/scripts/7681319861905001746/AmazingFeature/xshader/noface.vert b/scripts/7681319861905001746/AmazingFeature/xshader/noface.vert new file mode 100644 index 0000000000000000000000000000000000000000..16450a4b5880cf8d83528ea1ae0f47d10b2ab1d8 --- /dev/null +++ b/scripts/7681319861905001746/AmazingFeature/xshader/noface.vert @@ -0,0 +1,12 @@ +precision highp float; + +attribute vec2 position; +attribute vec2 texcoord0; +varying vec2 uv0; +//uniform mat4 u_MVP; +void main() +{ + //gl_Position = u_MVP * position; + gl_Position = sign(vec4(position.xy, 0.0, 1.0)); + uv0 = texcoord0; +} diff --git a/scripts/7681319861905001746/config.json b/scripts/7681319861905001746/config.json new file mode 100644 index 0000000000000000000000000000000000000000..557ff9895b4c8c8a7d91baae310b40001cd6c20d --- /dev/null +++ b/scripts/7681319861905001746/config.json @@ -0,0 +1,16 @@ +{ + "ae_tool": "AmazingEditor", + "bALG_BACH_CONFIG": false, + "effect": { + "Link": [ + { + "path": "AmazingFeature/", + "type": "AmazingFeature", + "zorder": 8011 + } + ] + }, + "name": "AlgorithmGraph_7bdbHcdcscQkbEdcc9cIlcNdvTdtb", + "version": "13.4.0", + "item_source": "user_post_pc_lumi_ai" +} \ No newline at end of file diff --git a/scripts/7681319861905001746/extra.json b/scripts/7681319861905001746/extra.json new file mode 100644 index 0000000000000000000000000000000000000000..36a38cb82f462004af687b21cde50e823f3b4a7e --- /dev/null +++ b/scripts/7681319861905001746/extra.json @@ -0,0 +1,53 @@ +{ + "transition": { + "defaultDura": 2.0, + "isOverlap": true + }, + "External_Producer": true, + "setting": { + "lumiai_material_properties": [ + { + "effect_key": "progress", + "effect_key_cn": "\u6548\u679c\u8fdb\u5ea6", + "type": "float", + "default": 0, + "min": 0, + "max": 1 + }, + { + "effect_key": "splashScale", + "effect_key_cn": "splash", + "type": "float", + "default": 3.2, + "min": 0.5, + "max": 8 + }, + { + "effect_key": "swirlStrength", + "effect_key_cn": "swirl ", + "type": "float", + "default": 0.7, + "min": 0, + "max": 2 + }, + { + "effect_key": "edgeSoftness", + "effect_key_cn": "edge S", + "type": "float", + "default": 0.08, + "min": 0.01, + "max": 0.25 + }, + { + "effect_key": "foamColor", + "effect_key_cn": "foam C", + "type": "color", + "default": [ + 0.92, + 0.97, + 1 + ] + } + ] + } +} \ No newline at end of file diff --git a/scripts/7681369931505470738/AmazingFeature/content.json b/scripts/7681369931505470738/AmazingFeature/content.json new file mode 100644 index 0000000000000000000000000000000000000000..df43720515b1b6981b24c4268c902195fa613d43 --- /dev/null +++ b/scripts/7681369931505470738/AmazingFeature/content.json @@ -0,0 +1,7 @@ +{ + "ae_tool" : "AmazingEditor", + "content" : {}, + "needblend" : false, + "tag" : "AMG_1515088281693380358513659446614427937212", + "version" : "1.0" +} \ No newline at end of file diff --git a/scripts/7681369931505470738/AmazingFeature/js/JSSys.js b/scripts/7681369931505470738/AmazingFeature/js/JSSys.js new file mode 100644 index 0000000000000000000000000000000000000000..bbcbf36f0f75c1beebe88c33dd0464bb4477158e --- /dev/null +++ b/scripts/7681369931505470738/AmazingFeature/js/JSSys.js @@ -0,0 +1,89 @@ +const effect_api = "undefined" != typeof effect ? effect : "undefined" != typeof tt ? tt : "undefined" != typeof lynx ? lynx : {}; +const Amaz = effect_api.getAmaz(); + +const { ScriptScene } = require('./ThreeJS/scriptScene'); +const THREE = require('./ThreeJS/three-amg-wrapper').THREE; + +class JSSys { + constructor() { + this.name = "JSSys"; + this.comps = {} + this.compsdirty = true + } + + onComponentAdded(comp) { + // console.log("running:JSSys:onComponentAdded"); + } + onComponentRemoved(comp) { + // console.log("running:JSSys:onComponentRemoved"); + } + + onStart() { + console.log("running:JSSys:onStart"); + + this.renderTexture = this.scene.assetMgr.SyncLoad('rt/outputTex.rt'); + + // 添加光源到场景 + console.log('JSSys: 创建ScriptScene实例'); + this.scriptScene = new ScriptScene(this.scene); + + this.input = Amaz.AmazingManager.getSingleton("Input"); + const builtinObject = Amaz.AmazingManager.getSingleton("BuiltinObject"); + + if (builtinObject.getUserTexture("#TransitionInput0") && builtinObject.getUserTexture("#TransitionInput1")) { + this.scriptScene.texture1 = new THREE.Texture(); + this.scriptScene.texture1.setImage(builtinObject.getUserTexture("#TransitionInput0")); + this.scriptScene.texture2 = new THREE.Texture(); + this.scriptScene.texture2.setImage(builtinObject.getUserTexture("#TransitionInput1")); + console.log("JSSys: 获取到纹理"); + } + else + { + this.scriptScene.texture1 = new THREE.Texture(); + this.scriptScene.texture1.setImage(this.scene.assetMgr.SyncLoad('image/Sample1.jpg')); + this.scriptScene.texture2 = new THREE.Texture(); + this.scriptScene.texture2.setImage(this.scene.assetMgr.SyncLoad('image/Sample2.jpg')); + console.log("JSSys: 未获取到纹理,使用默认纹理"); + } + + this.scriptScene.setupScene(); + // 初始化后处理效果 + if (this.scriptScene.initPostProcessing != null) { + this.scriptScene.initPostProcessing(); + } + } + + onUpdate(deltaTime) { + this.time = this.input.getFrameTimestamp(); + // this.time = this.time % 2; + // this.time = this.time / 2.0; + this.scriptScene.seekToTime(this.time * this.scriptScene.Duration); + // this.scriptScene.updateScene(); + } + onLateUpdate(deltaTime) { + // console.log("running:JSSys:onLateUpdate"); + this.scriptScene.scene.seekToTime(this.time * this.scriptScene.Duration); + } + + onEvent(event) { + console.log("running:JSSys:onEvent"); + if (event.type == Amaz.EventType.VIEWER) { + // console.log("JSSys: 窗口大小改变"); + console.log("renderTexture.width",this.renderTexture.width); + console.log("renderTexture.height",this.renderTexture.height); + + window.innerWidth = this.renderTexture.width; + window.innerHeight = this.renderTexture.height; + // console.log("JSSys: 窗口大小改变"); + this.scriptScene.handleResize(); + } + } + + onDestroy() { + // console.log("running:JSSys:onDestroy"); + this.scriptScene.destroy(); + } +} + +exports.JSSys = JSSys; + diff --git a/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/EffectComposer.js b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/EffectComposer.js new file mode 100644 index 0000000000000000000000000000000000000000..e7d8fd7a3f3978d9da1a9bf29af1854806f60014 --- /dev/null +++ b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/EffectComposer.js @@ -0,0 +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{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-6*k)*Math.cos(12*k)};const springStiff=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(18*k)};const dampedOscillation=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(10*k)};const Physics=Object.freeze({SpringSoft:springSoft,SpringStiff:springStiff,DampedOscillation:dampedOscillation});const anticipate=k=>{if(k<=0)return 0;if(k>=1)return 1;const pullback=.1;if(k<.3){const p=k/.3;return-pullback*p*(2-p)}const p=(k-.3)/.7;return-pullback+(1+pullback)*p*p*(3-2*p)};const overshootFactory=peak=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return peak*p*(2-p)}const p=(k-.6)/.4;return peak+(1-peak)*(1-Math.pow(1-p,3))};const overshoot110=overshootFactory(1.1);const overshoot125=overshootFactory(1.25);const snapBack=k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return 1.05*(1-Math.pow(1-p,3))}const p=(k-.6)/.4;return 1.05-.05*p*p*(3-2*p)};const swing=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.cos(1.5*Math.PI*k)*Math.exp(-2.5*k)};const Motion=Object.freeze({Anticipate:anticipate,Overshoot110:overshoot110,Overshoot125:overshoot125,SnapBack:snapBack,Swing:swing});const makeStep=(n,jumpTerm="end")=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(jumpTerm==="start")return Math.ceil(k*n)/n;return Math.floor(k*n)/n};const Step=Object.freeze({Steps4End:makeStep(4,"end"),Steps8End:makeStep(8,"end"),Steps12End:makeStep(12,"end")});function buildCubicBezier(x1,y1,x2,y2){const cx=3*x1,bx=3*(x2-x1)-cx,ax=1-cx-bx;const cy=3*y1,by=3*(y2-y1)-cy,ay=1-cy-by;const sampleX=s=>((ax*s+bx)*s+cx)*s;const sampleY=s=>((ay*s+by)*s+cy)*s;const sampleDX=s=>(3*ax*s+2*bx)*s+cx;const solveS=x=>{let s=x;for(let i=0;i<8;i++){const cur=sampleX(s)-x;if(Math.abs(cur)<1e-6)return s;const d=sampleDX(s);if(Math.abs(d)<1e-6)break;s-=cur/d;if(s<0)s=0;if(s>1)s=1}let lo=0,hi=1;for(let i=0;i<32&&hi-lo>1e-6;i++){const mid=(lo+hi)/2;if(sampleX(mid){if(k<=0)return 0;if(k>=1)return 1;return sampleY(solveS(k))}}const BEZIER_PRESETS=Object.freeze({"Material.Standard":[.4,0,.2,1],"Material.Accelerate":[.4,0,1,1],"Material.Decelerate":[0,0,.2,1],"CSS.Ease":[.25,.1,.25,1]});const _bezierCache=new Map;function _cachedBezier(x1,y1,x2,y2){const key=x1+","+y1+","+x2+","+y2;let fn=_bezierCache.get(key);if(!fn){fn=buildCubicBezier(x1,y1,x2,y2);_bezierCache.set(key,fn)}return fn}function cubicBezier(a,b,c,d){if(typeof a==="string"){let preset=BEZIER_PRESETS[a];if(!preset){console.warn("[customEasings.cubicBezier] unknown preset, falling back to Material.Standard:",a);preset=BEZIER_PRESETS["Material.Standard"]}return _cachedBezier(preset[0],preset[1],preset[2],preset[3])}const clamp=(v,lo,hi)=>Math.max(lo,Math.min(hi,v));const x1=clamp(a,0,1);const y1=clamp(b,-.5,1.5);const x2=clamp(c,0,1);const y2=clamp(d,-.5,1.5);return _cachedBezier(x1,y1,x2,y2)}const libSpring=({stiffness=180,damping=12,mass=1}={})=>{const DT=1/240;const T=1.5;let x=0,v=0;const samples=[];for(let t=0;t<=T;t+=DT){const force=-stiffness*(x-1)-damping*v;v+=force/mass*DT;x+=v*DT;samples.push({t:t,x:x})}let T_end=T;for(let i=samples.length-1;i>=0;i--){if(Math.abs(samples[i].x-1)>.01){T_end=samples[i].t;break}}return k=>{if(k<=0)return 0;if(k>=1)return 1;const t=k*T_end;const idx=Math.min(samples.length-1,Math.floor(t/DT));return samples[idx].x}};const libHeartBeat=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c)=>Math.exp(-((t-c)**2)/(2*.07*.07));return peak*(bell(k,.2)+bell(k,.5))};const libSteps=(n=6)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return Math.floor(k*n)/n};const attentionPing=(peak=.35,decay=2)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(Math.PI*k)*Math.exp(-decay*k)};const attentionWiggle=(count=4,amplitude=.25)=>k=>{if(k<=0||k>=1)return 0;const env=1-k;return amplitude*env*Math.sin(k*Math.PI*2*count)};const attentionStrum=(notes=4,peak=.4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*.05*.05))}return peak*sum}};const Attention=Object.freeze({Ping:attentionPing(),Wiggle:attentionWiggle(),Strum:attentionStrum()});const breathNormal=(cycles=2,peak=.15)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(k*Math.PI*2*cycles)*Math.sin(k*Math.PI)};const breathDeep=(peak=.3,riseRatio=.35,holdRatio=.15)=>{const holdEnd=riseRatio+holdRatio;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const envelope=Math.sin(k*Math.PI);const wave=.5+.5*Math.sin(k*Math.PI*2*cycles-Math.PI/2);return peak*envelope*wave};const breathSigh=(peak=.25,riseRatio=.2)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return peak*Math.exp(-((k-center)**2)/(2*width*width))};const heartExcited=(beats=4,peak=.3,width=.04)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*width*width))}return peak*sum}};const heartLubDub=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return peak*(bell(k,.25,.045)+.6*bell(k,.42,.03))};const Heart=Object.freeze({Calm:heartCalm(),Excited:heartExcited(),LubDub:heartLubDub()});const mathJumpArc=()=>k=>{if(k<=0||k>=1)return 0;return 4*k*(1-k)};const mathPendulum=(damping=3,freq=2.5)=>k=>{if(k<=0||k>=1)return 0;return Math.sin(k*Math.PI)*Math.exp(-damping*k)*Math.cos(freq*Math.PI*k)};const mathTremor=(amplitude=.04,freq=22)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return k+amplitude*Math.sin(k*Math.PI*2*freq)};const mathBoomerang=fn=>k=>{if(k<=0||k>=1)return 0;return k<.5?fn(k*2):fn(2-k*2)};const MathExt=Object.freeze({JumpArc:mathJumpArc(),Pendulum:mathPendulum(),Tremor:mathTremor()});const explosionImpulse=(sharpness=6)=>{const tail=sharpness*Math.exp(1-sharpness);return k=>{if(k<=0||k>=1)return 0;const h=sharpness*k;return h*Math.exp(1-h)-tail*k}};const explosionFlash=(rise=.05,decay=5)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return-Math.exp(-decay*k)*Math.cos(freq*Math.PI*k)};const explosionImplosion=(charge=.3,depth=.4,burstPeak=1.2)=>{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const w=Math.sin(k*Math.PI*2*cycles)+.5*Math.sin(k*Math.PI*2*cycles*1.5+1.2)+.25*Math.sin(k*Math.PI*2*cycles*3+2.4);return amplitude*env*w*.6};const natureFlicker=(rate=15,intensity=.2,seed=7)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=rate+1;i++)samples.push(rand());return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*rate;const idx=Math.floor(pos);const t=pos-idx;const a=samples[idx];const b=samples[idx+1];const interp=a+(b-a)*t;return intensity*env*(interp-.5)*2}};const natureGust=(gusts=3,peak=.25)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*.08*.08))}return peak*sum/gusts*1.8}};const Nature=Object.freeze({Wave:natureWave(),Flicker:natureFlicker(),Gust:natureGust()});const impactRain=(impactAt=.7,rippleAmp=.08)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const liftEnd=.35,strikeEnd=.6;return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return t*t}const t=(k-.4)/.6;const env=Math.exp(-2.5*t);const wave=Math.abs(Math.sin(t*Math.PI*bounces));return 1-env*wave*rebound};const impactSlap=(contactAt=.3,holdRatio=.1)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return.4*Math.pow(t,2.5)}if(k<.48){const t=(k-.4)/.08;return.4-.2*t}if(k<.52){const t=(k-.48)/.04;return.2+.8*t}const t=(k-.52)/.48;return 1-.04*Math.sin(t*Math.PI*8)*(1-t)};const rhythmPunchCombo=(peak=.4)=>{const pattern=[{c:.15,w:.04,a:.75},{c:.35,w:.04,a:.75},{c:.7,w:.055,a:1}];return k=>{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of pattern){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return peak*sum}};const rhythmStaccato=(beats=4,duty=.3)=>k=>{if(k<=0||k>=1)return 0;const beatLen=1/beats;const phase=k/beatLen-Math.floor(k/beatLen);if(phase>duty)return 0;const t=phase/duty;return Math.sin(t*Math.PI)};const rhythmKick=(peak=1.2)=>k=>{if(k<=0||k>=1)return 0;if(k<.05)return peak*k/.05;const t=(k-.05)/.95;return peak*Math.exp(-4*t)};const rhythmCrescendo=(beats=4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return sum}};const rhythmDunDunDun=()=>{const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return k=>{if(k<=0||k>=1)return 0;return.3*bell(k,.15,.025)+.6*bell(k,.35,.03)+1*bell(k,.68,.09)}};const rhythmBellToll=(decay=3,freq=8)=>{const strike=.05;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.2){const t=k/.2;return-pressDepth*Math.sin(t*Math.PI/2)}if(k<.5){const t=(k-.2)/.3;return-pressDepth+(pressDepth+reboundPeak)*(1-Math.pow(1-t,3))}const t=(k-.5)/.5;return reboundPeak*Math.exp(-4*t)*Math.cos(t*Math.PI*3)};const uiHoverBloom=(riseRatio=.2,fallRatio=.3)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=1-k;const raw=Math.sin(k*Math.PI*2*count);const clipped=Math.sign(raw)*Math.min(1,Math.abs(raw)*1.8);return amplitude*env*clipped};const uiSuccessPop=(overshoot=.2)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return(1+overshoot)*(1-Math.pow(1-t,2))}const t=(k-.4)/.6;return 1+overshoot*Math.exp(-5*t)*Math.cos(t*Math.PI*3)};const uiRippleOut=()=>k=>{if(k<=0||k>=1)return 0;return 6.75*k*Math.pow(1-k,2)};const UI=Object.freeze({ClickSnap:uiClickSnap(),HoverBloom:uiHoverBloom(),ErrorShake:uiErrorShake(),SuccessPop:uiSuccessPop(),RippleOut:uiRippleOut()});const magicManaCharge=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;const base=(Math.exp(3*k)-1)/(Math.exp(3)-1);const pulse=.04*Math.sin(k*Math.PI*8)*k;return base+pulse};const magicSpellCast=(chargeEnd=.4)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.45){const t=k/.45;return t*t*t}if(k<.55)return 1;const t=(k-.55)/.45;return Math.pow(1-t,3)};const magicShield=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.3){const t=k/.3;return 1.2*(1-Math.pow(1-t,2))}if(k<.6){const t=(k-.3)/.3;return 1.2-.2*t}const t=(k-.6)/.4;return 1+.03*Math.sin(t*Math.PI*3)};const magicAura=(peak=.15)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const fundamental=.6*Math.sin(k*Math.PI*2);const harmonic=.3*Math.sin(k*Math.PI*4+1);const overtone=.1*Math.sin(k*Math.PI*6+2);return peak*env*(fundamental+harmonic+overtone)};const Magic=Object.freeze({ManaCharge:magicManaCharge(),SpellCast:magicSpellCast(),Teleport:magicTeleport(),Shield:magicShield(),MagicAura:magicAura()});const animalCatPounce=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.2){const t=k/.2;return-.2*Math.sin(t*Math.PI)}if(k<.3){const t=(k-.2)/.1;return.5*t*t}if(k<.8){const t=(k-.3)/.5;return.5+.5*t+.2*Math.sin(t*Math.PI)}const t=(k-.8)/.2;return 1+.05*Math.sin(t*Math.PI)};const animalBirdFlap=(flaps=4)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const phase=k*Math.PI*2*flaps;const wave=Math.sin(phase)-.3*Math.sin(phase*2);return.2*env*wave};const animalSnakeSlither=(waves=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const wave=Math.sin(k*Math.PI*2*waves);return.2*env*wave};const animalButterflyFlit=(seed=13)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=26;i++)samples.push(rand()-.5);return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*25;const idx=Math.floor(pos);const t=pos-idx;const smooth=t*t*(3-2*t);const interp=samples[idx]+(samples[idx+1]-samples[idx])*smooth;return.3*env*interp}};const animalHorseGallop=(cycles=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const cyclePos=k*cycles-Math.floor(k*cycles);const bell=(c,w=.04)=>Math.exp(-((cyclePos-c)**2)/(2*w*w));return.25*env*(bell(0)+bell(.18)+bell(.36)+bell(.54))};const Animal=Object.freeze({CatPounce:animalCatPounce(),BirdFlap:animalBirdFlap(),SnakeSlither:animalSnakeSlither(),ButterflyFlit:animalButterflyFlit(),HorseGallop:animalHorseGallop()});const Progress=Object.freeze({Physics:Object.freeze({...Physics,Spring:libSpring()}),Motion:Motion,Step:Object.freeze({...Step,Steps6:libSteps()}),Math:Object.freeze({Tremor:MathExt.Tremor}),Impact:Object.freeze({Rain:Impact.Rain,Hammer:Impact.Hammer,BounceDrop:Impact.BounceDrop,ArrowHit:Impact.ArrowHit,Shatter:Impact.Shatter}),Rhythm:Object.freeze({BassDrop:Rhythm.BassDrop}),UI:Object.freeze({SuccessPop:UI.SuccessPop}),Magic:Object.freeze({ManaCharge:Magic.ManaCharge,Shield:Magic.Shield}),Animal:Object.freeze({CatPounce:Animal.CatPounce})});const Pulse=Object.freeze({Attention:Object.freeze({Ping:Attention.Ping}),Breath:Object.freeze({Deep:Breath.Deep,Sigh:Breath.Sigh}),Heart:Object.freeze({Calm:Heart.Calm}),Math:Object.freeze({JumpArc:MathExt.JumpArc,BoomerangSharp:mathBoomerang(E.Cubic.In),BoomerangSoft:mathBoomerang(E.Cubic.Out)}),Explosion:Object.freeze({Impulse:Explosion.Impulse,Flash:Explosion.Flash,Recoil:Explosion.Recoil,Implosion:Explosion.Implosion}),Impact:Object.freeze({Slap:Impact.Slap}),Rhythm:Object.freeze({Kick:Rhythm.Kick}),UI:Object.freeze({ClickSnap:UI.ClickSnap,HoverBloom:UI.HoverBloom,RippleOut:UI.RippleOut}),Magic:Object.freeze({SpellCast:Magic.SpellCast,Teleport:Magic.Teleport})});const Wave=Object.freeze({Attention:Object.freeze({Wiggle:Attention.Wiggle,Strum:Attention.Strum}),Breath:Object.freeze({Normal:Breath.Normal,Panting:Breath.Panting}),Heart:Object.freeze({Excited:Heart.Excited,LubDub:Heart.LubDub,Beat:libHeartBeat()}),Math:Object.freeze({Pendulum:MathExt.Pendulum}),Nature:Nature,Rhythm:Object.freeze({PunchCombo:Rhythm.PunchCombo,Staccato:Rhythm.Staccato,Crescendo:Rhythm.Crescendo,DunDunDun:Rhythm.DunDunDun,BellToll:Rhythm.BellToll}),UI:Object.freeze({ErrorShake:UI.ErrorShake}),Magic:Object.freeze({MagicAura:Magic.MagicAura}),Animal:Object.freeze({BirdFlap:Animal.BirdFlap,SnakeSlither:Animal.SnakeSlither,ButterflyFlit:Animal.ButterflyFlit,HorseGallop:Animal.HorseGallop})});const customEasings=Object.freeze({makeOutIn:makeOutIn,OutIn:OutIn,Progress:Progress,Pulse:Pulse,Wave:Wave,cubicBezier:cubicBezier});exports.customEasings=customEasings;exports.default=customEasings; \ No newline at end of file diff --git a/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/scriptScene.js b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/scriptScene.js new file mode 100644 index 0000000000000000000000000000000000000000..5d5f0a8bde54f7efa0912b77bb0a8298e3fb04e9 --- /dev/null +++ b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/scriptScene.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/three-amg-wrapper.js b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/three-amg-wrapper.js new file mode 100644 index 0000000000000000000000000000000000000000..c2037e314e032c4d36912923d4cc1258cba3ab19 --- /dev/null +++ b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/three-amg-wrapper.js @@ -0,0 +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;iobj.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; \ No newline at end of file diff --git a/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/tween.js b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/tween.js new file mode 100644 index 0000000000000000000000000000000000000000..690fb9e4284728629129deed5a5a3f4bcec291ed --- /dev/null +++ b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/tween.js @@ -0,0 +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=power1e4?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;_i0){this._tweensAddedDuringUpdate={};for(var i=0;i1){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[m1;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;itotalTime){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;ithis.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;ithis.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.xthis.max.x||box.max.ythis.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; \ No newline at end of file diff --git a/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Box3.js b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Box3.js new file mode 100644 index 0000000000000000000000000000000000000000..4100dc7442d3a622827c8a415e24557f68c491f1 --- /dev/null +++ b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Box3.js @@ -0,0 +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=3?array[offset+2]:0;if(xthis.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=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.xthis.max.x||box.max.ythis.max.y||box.max.zthis.max.z)}}exports.Box3=Box3; \ No newline at end of file diff --git a/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..be3b8b1334a62f5e88c45feee098063a199fca55 --- /dev/null +++ b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js @@ -0,0 +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=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; \ No newline at end of file diff --git a/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..af9a8a13a46500e78f082a35e18d0b5932061234 --- /dev/null +++ b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js @@ -0,0 +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;iObject.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;i1?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; \ No newline at end of file diff --git a/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Constants.js b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Constants.js new file mode 100644 index 0000000000000000000000000000000000000000..6b8adda19a4d67236719804f5170889b39fd4582 --- /dev/null +++ b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Constants.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js new file mode 100644 index 0000000000000000000000000000000000000000..29b0aad5599401be17f967ba1d48851acb70c2ac --- /dev/null +++ b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js @@ -0,0 +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;i0||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;i0?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;imaxX)maxX=p.x;if(p.ymaxY)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; \ No newline at end of file diff --git a/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..f3dee08bf1c089e040fcfef228902ab9a39c93cb --- /dev/null +++ b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Earcut.js b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Earcut.js new file mode 100644 index 0000000000000000000000000000000000000000..953abffdf38c2def26df73fed180eff8c7644ced --- /dev/null +++ b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Earcut.js @@ -0,0 +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;imaxX)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=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=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.x&&p.x>=mx&&hx!==p.x&&pointInTriangle(hym.x||p.x===m.x&§orContainsSector(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.xb.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;i0||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=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;i0){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;imaxX)maxX=contour[i].x;if(contour[i].ymaxY)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;layerIdx0?-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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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; \ No newline at end of file diff --git a/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Group.js b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Group.js new file mode 100644 index 0000000000000000000000000000000000000000..90c4dbef65aa04d7a3bb6b6d76ec3317ea65a228 --- /dev/null +++ b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Group.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");class Group extends Object3D{constructor(name="Group_w"){super(name)}dispose(){super.dispose()}}exports.Group=Group; \ No newline at end of file diff --git a/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Material.js b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Material.js new file mode 100644 index 0000000000000000000000000000000000000000..81b97053ad9d1e4b1ef05d5ac6ed992487b2ca8e --- /dev/null +++ b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Material.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..dcf34d4cffb9de0869382a24690f78f60dda6049 --- /dev/null +++ b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js new file mode 100644 index 0000000000000000000000000000000000000000..41e6cd0a0eee7dd7bc497be5deac584806b68dc3 --- /dev/null +++ b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Mesh.js b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Mesh.js new file mode 100644 index 0000000000000000000000000000000000000000..254d69b074e797dd34c16d7dad723bbcc3b4895d --- /dev/null +++ b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Mesh.js @@ -0,0 +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;imaterial,set:value=>{material=value;if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;im.dispose&&m.dispose());else if(this.material.dispose)this.material.dispose()}}}exports.MeshWrapper=MeshWrapper; \ No newline at end of file diff --git a/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..ac394f66efc4e113a7127ee0f50ec672e4c5e9eb --- /dev/null +++ b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Object3D.js b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Object3D.js new file mode 100644 index 0000000000000000000000000000000000000000..8532c6122f839460aab34fe88957802ff523318b --- /dev/null +++ b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Object3D.js @@ -0,0 +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{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&¤tScene._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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js new file mode 100644 index 0000000000000000000000000000000000000000..ba39801de50d38ec04424f3c2ebfa2ff5d28fded --- /dev/null +++ b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js @@ -0,0 +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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..bc595fb80ad9e7c2f4d8360c67dbef556f3d6cbe --- /dev/null +++ b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js @@ -0,0 +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;iy0){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; \ No newline at end of file diff --git a/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..02dc1be955bc766de744222a7e75c65bf147bb61 --- /dev/null +++ b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js @@ -0,0 +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&¶meters.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{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=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=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=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; \ No newline at end of file diff --git a/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Shape.js b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Shape.js new file mode 100644 index 0000000000000000000000000000000000000000..ecde48b5ceb30812c922aa5c7cfe2aa7b50cabe4 --- /dev/null +++ b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Shape.js @@ -0,0 +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;i0){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;i0||(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;imaxX)maxX=p.x;if(p.ymaxY)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;i0?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;ipoints.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;itwoPi)deltaAngle-=twoPi;if(deltaAngle>4;uuid[i]=chars[i===19?r&3|8:r]}}return uuid.join("")}exports.Shape=Shape; \ No newline at end of file diff --git a/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..3786abc7d64ed80b56101c4ac9d30ce9fcb8f941 --- /dev/null +++ b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js @@ -0,0 +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;i0){const bounds=calculateBounds(flatVertices);const vertexOffset=vertices.length/3;for(let j=0;j0){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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}function calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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; \ No newline at end of file diff --git a/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..1ea27a55fbce9fc3771c66840c068e5ff6347092 --- /dev/null +++ b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Texture.js b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Texture.js new file mode 100644 index 0000000000000000000000000000000000000000..35bff49d732c9884e07bfcb5682f18a860485e1f --- /dev/null +++ b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Texture.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Vector2.js b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Vector2.js new file mode 100644 index 0000000000000000000000000000000000000000..a30a2431264ee62cec937714dfa9e50932ddedeb --- /dev/null +++ b/scripts/7681369931505470738/AmazingFeature/js/ThreeJS/wrapper/Vector2.js @@ -0,0 +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)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)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){if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-6*k)*Math.cos(12*k)};const springStiff=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(18*k)};const dampedOscillation=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(10*k)};const Physics=Object.freeze({SpringSoft:springSoft,SpringStiff:springStiff,DampedOscillation:dampedOscillation});const anticipate=k=>{if(k<=0)return 0;if(k>=1)return 1;const pullback=.1;if(k<.3){const p=k/.3;return-pullback*p*(2-p)}const p=(k-.3)/.7;return-pullback+(1+pullback)*p*p*(3-2*p)};const overshootFactory=peak=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return peak*p*(2-p)}const p=(k-.6)/.4;return peak+(1-peak)*(1-Math.pow(1-p,3))};const overshoot110=overshootFactory(1.1);const overshoot125=overshootFactory(1.25);const snapBack=k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return 1.05*(1-Math.pow(1-p,3))}const p=(k-.6)/.4;return 1.05-.05*p*p*(3-2*p)};const swing=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.cos(1.5*Math.PI*k)*Math.exp(-2.5*k)};const Motion=Object.freeze({Anticipate:anticipate,Overshoot110:overshoot110,Overshoot125:overshoot125,SnapBack:snapBack,Swing:swing});const makeStep=(n,jumpTerm="end")=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(jumpTerm==="start")return Math.ceil(k*n)/n;return Math.floor(k*n)/n};const Step=Object.freeze({Steps4End:makeStep(4,"end"),Steps8End:makeStep(8,"end"),Steps12End:makeStep(12,"end")});function buildCubicBezier(x1,y1,x2,y2){const cx=3*x1,bx=3*(x2-x1)-cx,ax=1-cx-bx;const cy=3*y1,by=3*(y2-y1)-cy,ay=1-cy-by;const sampleX=s=>((ax*s+bx)*s+cx)*s;const sampleY=s=>((ay*s+by)*s+cy)*s;const sampleDX=s=>(3*ax*s+2*bx)*s+cx;const solveS=x=>{let s=x;for(let i=0;i<8;i++){const cur=sampleX(s)-x;if(Math.abs(cur)<1e-6)return s;const d=sampleDX(s);if(Math.abs(d)<1e-6)break;s-=cur/d;if(s<0)s=0;if(s>1)s=1}let lo=0,hi=1;for(let i=0;i<32&&hi-lo>1e-6;i++){const mid=(lo+hi)/2;if(sampleX(mid){if(k<=0)return 0;if(k>=1)return 1;return sampleY(solveS(k))}}const BEZIER_PRESETS=Object.freeze({"Material.Standard":[.4,0,.2,1],"Material.Accelerate":[.4,0,1,1],"Material.Decelerate":[0,0,.2,1],"CSS.Ease":[.25,.1,.25,1]});const _bezierCache=new Map;function _cachedBezier(x1,y1,x2,y2){const key=x1+","+y1+","+x2+","+y2;let fn=_bezierCache.get(key);if(!fn){fn=buildCubicBezier(x1,y1,x2,y2);_bezierCache.set(key,fn)}return fn}function cubicBezier(a,b,c,d){if(typeof a==="string"){let preset=BEZIER_PRESETS[a];if(!preset){console.warn("[customEasings.cubicBezier] unknown preset, falling back to Material.Standard:",a);preset=BEZIER_PRESETS["Material.Standard"]}return _cachedBezier(preset[0],preset[1],preset[2],preset[3])}const clamp=(v,lo,hi)=>Math.max(lo,Math.min(hi,v));const x1=clamp(a,0,1);const y1=clamp(b,-.5,1.5);const x2=clamp(c,0,1);const y2=clamp(d,-.5,1.5);return _cachedBezier(x1,y1,x2,y2)}const libSpring=({stiffness=180,damping=12,mass=1}={})=>{const DT=1/240;const T=1.5;let x=0,v=0;const samples=[];for(let t=0;t<=T;t+=DT){const force=-stiffness*(x-1)-damping*v;v+=force/mass*DT;x+=v*DT;samples.push({t:t,x:x})}let T_end=T;for(let i=samples.length-1;i>=0;i--){if(Math.abs(samples[i].x-1)>.01){T_end=samples[i].t;break}}return k=>{if(k<=0)return 0;if(k>=1)return 1;const t=k*T_end;const idx=Math.min(samples.length-1,Math.floor(t/DT));return samples[idx].x}};const libHeartBeat=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c)=>Math.exp(-((t-c)**2)/(2*.07*.07));return peak*(bell(k,.2)+bell(k,.5))};const libSteps=(n=6)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return Math.floor(k*n)/n};const attentionPing=(peak=.35,decay=2)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(Math.PI*k)*Math.exp(-decay*k)};const attentionWiggle=(count=4,amplitude=.25)=>k=>{if(k<=0||k>=1)return 0;const env=1-k;return amplitude*env*Math.sin(k*Math.PI*2*count)};const attentionStrum=(notes=4,peak=.4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*.05*.05))}return peak*sum}};const Attention=Object.freeze({Ping:attentionPing(),Wiggle:attentionWiggle(),Strum:attentionStrum()});const breathNormal=(cycles=2,peak=.15)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(k*Math.PI*2*cycles)*Math.sin(k*Math.PI)};const breathDeep=(peak=.3,riseRatio=.35,holdRatio=.15)=>{const holdEnd=riseRatio+holdRatio;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const envelope=Math.sin(k*Math.PI);const wave=.5+.5*Math.sin(k*Math.PI*2*cycles-Math.PI/2);return peak*envelope*wave};const breathSigh=(peak=.25,riseRatio=.2)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return peak*Math.exp(-((k-center)**2)/(2*width*width))};const heartExcited=(beats=4,peak=.3,width=.04)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*width*width))}return peak*sum}};const heartLubDub=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return peak*(bell(k,.25,.045)+.6*bell(k,.42,.03))};const Heart=Object.freeze({Calm:heartCalm(),Excited:heartExcited(),LubDub:heartLubDub()});const mathJumpArc=()=>k=>{if(k<=0||k>=1)return 0;return 4*k*(1-k)};const mathPendulum=(damping=3,freq=2.5)=>k=>{if(k<=0||k>=1)return 0;return Math.sin(k*Math.PI)*Math.exp(-damping*k)*Math.cos(freq*Math.PI*k)};const mathTremor=(amplitude=.04,freq=22)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return k+amplitude*Math.sin(k*Math.PI*2*freq)};const mathBoomerang=fn=>k=>{if(k<=0||k>=1)return 0;return k<.5?fn(k*2):fn(2-k*2)};const MathExt=Object.freeze({JumpArc:mathJumpArc(),Pendulum:mathPendulum(),Tremor:mathTremor()});const explosionImpulse=(sharpness=6)=>{const tail=sharpness*Math.exp(1-sharpness);return k=>{if(k<=0||k>=1)return 0;const h=sharpness*k;return h*Math.exp(1-h)-tail*k}};const explosionFlash=(rise=.05,decay=5)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return-Math.exp(-decay*k)*Math.cos(freq*Math.PI*k)};const explosionImplosion=(charge=.3,depth=.4,burstPeak=1.2)=>{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const w=Math.sin(k*Math.PI*2*cycles)+.5*Math.sin(k*Math.PI*2*cycles*1.5+1.2)+.25*Math.sin(k*Math.PI*2*cycles*3+2.4);return amplitude*env*w*.6};const natureFlicker=(rate=15,intensity=.2,seed=7)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=rate+1;i++)samples.push(rand());return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*rate;const idx=Math.floor(pos);const t=pos-idx;const a=samples[idx];const b=samples[idx+1];const interp=a+(b-a)*t;return intensity*env*(interp-.5)*2}};const natureGust=(gusts=3,peak=.25)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*.08*.08))}return peak*sum/gusts*1.8}};const Nature=Object.freeze({Wave:natureWave(),Flicker:natureFlicker(),Gust:natureGust()});const impactRain=(impactAt=.7,rippleAmp=.08)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const liftEnd=.35,strikeEnd=.6;return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return t*t}const t=(k-.4)/.6;const env=Math.exp(-2.5*t);const wave=Math.abs(Math.sin(t*Math.PI*bounces));return 1-env*wave*rebound};const impactSlap=(contactAt=.3,holdRatio=.1)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return.4*Math.pow(t,2.5)}if(k<.48){const t=(k-.4)/.08;return.4-.2*t}if(k<.52){const t=(k-.48)/.04;return.2+.8*t}const t=(k-.52)/.48;return 1-.04*Math.sin(t*Math.PI*8)*(1-t)};const rhythmPunchCombo=(peak=.4)=>{const pattern=[{c:.15,w:.04,a:.75},{c:.35,w:.04,a:.75},{c:.7,w:.055,a:1}];return k=>{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of pattern){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return peak*sum}};const rhythmStaccato=(beats=4,duty=.3)=>k=>{if(k<=0||k>=1)return 0;const beatLen=1/beats;const phase=k/beatLen-Math.floor(k/beatLen);if(phase>duty)return 0;const t=phase/duty;return Math.sin(t*Math.PI)};const rhythmKick=(peak=1.2)=>k=>{if(k<=0||k>=1)return 0;if(k<.05)return peak*k/.05;const t=(k-.05)/.95;return peak*Math.exp(-4*t)};const rhythmCrescendo=(beats=4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return sum}};const rhythmDunDunDun=()=>{const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return k=>{if(k<=0||k>=1)return 0;return.3*bell(k,.15,.025)+.6*bell(k,.35,.03)+1*bell(k,.68,.09)}};const rhythmBellToll=(decay=3,freq=8)=>{const strike=.05;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.2){const t=k/.2;return-pressDepth*Math.sin(t*Math.PI/2)}if(k<.5){const t=(k-.2)/.3;return-pressDepth+(pressDepth+reboundPeak)*(1-Math.pow(1-t,3))}const t=(k-.5)/.5;return reboundPeak*Math.exp(-4*t)*Math.cos(t*Math.PI*3)};const uiHoverBloom=(riseRatio=.2,fallRatio=.3)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=1-k;const raw=Math.sin(k*Math.PI*2*count);const clipped=Math.sign(raw)*Math.min(1,Math.abs(raw)*1.8);return amplitude*env*clipped};const uiSuccessPop=(overshoot=.2)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return(1+overshoot)*(1-Math.pow(1-t,2))}const t=(k-.4)/.6;return 1+overshoot*Math.exp(-5*t)*Math.cos(t*Math.PI*3)};const uiRippleOut=()=>k=>{if(k<=0||k>=1)return 0;return 6.75*k*Math.pow(1-k,2)};const UI=Object.freeze({ClickSnap:uiClickSnap(),HoverBloom:uiHoverBloom(),ErrorShake:uiErrorShake(),SuccessPop:uiSuccessPop(),RippleOut:uiRippleOut()});const magicManaCharge=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;const base=(Math.exp(3*k)-1)/(Math.exp(3)-1);const pulse=.04*Math.sin(k*Math.PI*8)*k;return base+pulse};const magicSpellCast=(chargeEnd=.4)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.45){const t=k/.45;return t*t*t}if(k<.55)return 1;const t=(k-.55)/.45;return Math.pow(1-t,3)};const magicShield=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.3){const t=k/.3;return 1.2*(1-Math.pow(1-t,2))}if(k<.6){const t=(k-.3)/.3;return 1.2-.2*t}const t=(k-.6)/.4;return 1+.03*Math.sin(t*Math.PI*3)};const magicAura=(peak=.15)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const fundamental=.6*Math.sin(k*Math.PI*2);const harmonic=.3*Math.sin(k*Math.PI*4+1);const overtone=.1*Math.sin(k*Math.PI*6+2);return peak*env*(fundamental+harmonic+overtone)};const Magic=Object.freeze({ManaCharge:magicManaCharge(),SpellCast:magicSpellCast(),Teleport:magicTeleport(),Shield:magicShield(),MagicAura:magicAura()});const animalCatPounce=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.2){const t=k/.2;return-.2*Math.sin(t*Math.PI)}if(k<.3){const t=(k-.2)/.1;return.5*t*t}if(k<.8){const t=(k-.3)/.5;return.5+.5*t+.2*Math.sin(t*Math.PI)}const t=(k-.8)/.2;return 1+.05*Math.sin(t*Math.PI)};const animalBirdFlap=(flaps=4)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const phase=k*Math.PI*2*flaps;const wave=Math.sin(phase)-.3*Math.sin(phase*2);return.2*env*wave};const animalSnakeSlither=(waves=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const wave=Math.sin(k*Math.PI*2*waves);return.2*env*wave};const animalButterflyFlit=(seed=13)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=26;i++)samples.push(rand()-.5);return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*25;const idx=Math.floor(pos);const t=pos-idx;const smooth=t*t*(3-2*t);const interp=samples[idx]+(samples[idx+1]-samples[idx])*smooth;return.3*env*interp}};const animalHorseGallop=(cycles=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const cyclePos=k*cycles-Math.floor(k*cycles);const bell=(c,w=.04)=>Math.exp(-((cyclePos-c)**2)/(2*w*w));return.25*env*(bell(0)+bell(.18)+bell(.36)+bell(.54))};const Animal=Object.freeze({CatPounce:animalCatPounce(),BirdFlap:animalBirdFlap(),SnakeSlither:animalSnakeSlither(),ButterflyFlit:animalButterflyFlit(),HorseGallop:animalHorseGallop()});const Progress=Object.freeze({Physics:Object.freeze({...Physics,Spring:libSpring()}),Motion:Motion,Step:Object.freeze({...Step,Steps6:libSteps()}),Math:Object.freeze({Tremor:MathExt.Tremor}),Impact:Object.freeze({Rain:Impact.Rain,Hammer:Impact.Hammer,BounceDrop:Impact.BounceDrop,ArrowHit:Impact.ArrowHit,Shatter:Impact.Shatter}),Rhythm:Object.freeze({BassDrop:Rhythm.BassDrop}),UI:Object.freeze({SuccessPop:UI.SuccessPop}),Magic:Object.freeze({ManaCharge:Magic.ManaCharge,Shield:Magic.Shield}),Animal:Object.freeze({CatPounce:Animal.CatPounce})});const Pulse=Object.freeze({Attention:Object.freeze({Ping:Attention.Ping}),Breath:Object.freeze({Deep:Breath.Deep,Sigh:Breath.Sigh}),Heart:Object.freeze({Calm:Heart.Calm}),Math:Object.freeze({JumpArc:MathExt.JumpArc,BoomerangSharp:mathBoomerang(E.Cubic.In),BoomerangSoft:mathBoomerang(E.Cubic.Out)}),Explosion:Object.freeze({Impulse:Explosion.Impulse,Flash:Explosion.Flash,Recoil:Explosion.Recoil,Implosion:Explosion.Implosion}),Impact:Object.freeze({Slap:Impact.Slap}),Rhythm:Object.freeze({Kick:Rhythm.Kick}),UI:Object.freeze({ClickSnap:UI.ClickSnap,HoverBloom:UI.HoverBloom,RippleOut:UI.RippleOut}),Magic:Object.freeze({SpellCast:Magic.SpellCast,Teleport:Magic.Teleport})});const Wave=Object.freeze({Attention:Object.freeze({Wiggle:Attention.Wiggle,Strum:Attention.Strum}),Breath:Object.freeze({Normal:Breath.Normal,Panting:Breath.Panting}),Heart:Object.freeze({Excited:Heart.Excited,LubDub:Heart.LubDub,Beat:libHeartBeat()}),Math:Object.freeze({Pendulum:MathExt.Pendulum}),Nature:Nature,Rhythm:Object.freeze({PunchCombo:Rhythm.PunchCombo,Staccato:Rhythm.Staccato,Crescendo:Rhythm.Crescendo,DunDunDun:Rhythm.DunDunDun,BellToll:Rhythm.BellToll}),UI:Object.freeze({ErrorShake:UI.ErrorShake}),Magic:Object.freeze({MagicAura:Magic.MagicAura}),Animal:Object.freeze({BirdFlap:Animal.BirdFlap,SnakeSlither:Animal.SnakeSlither,ButterflyFlit:Animal.ButterflyFlit,HorseGallop:Animal.HorseGallop})});const customEasings=Object.freeze({makeOutIn:makeOutIn,OutIn:OutIn,Progress:Progress,Pulse:Pulse,Wave:Wave,cubicBezier:cubicBezier});exports.customEasings=customEasings;exports.default=customEasings; \ No newline at end of file diff --git a/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/scriptScene.js b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/scriptScene.js new file mode 100644 index 0000000000000000000000000000000000000000..75b894166eb444c87b1abd0939565d80ce613e2c --- /dev/null +++ b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/scriptScene.js @@ -0,0 +1,99 @@ +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)}addAnimations(){const duration=this.Duration;const tweens=[];const clampTime=ms=>{const scaled=ms/2e3*duration;return Math.min(Math.max(scaled,50),duration-50)};const createPresetTween=(shaderPass,fromPreset,toPreset,startMs,endMs,easingFn)=>{const fromConfigRaw=shaderPass.getPresetConfig(fromPreset);const toConfigRaw=shaderPass.getPresetConfig(toPreset);if(!fromConfigRaw){console.error(`${shaderPass.constructor.name} 中没有 ${fromPreset} 预设配置`);return null}if(!toConfigRaw){console.error(`${shaderPass.constructor.name} 中没有 ${toPreset} 预设配置`);return null}const start=clampTime(startMs);const end=clampTime(endMs);const tweenDuration=Math.max(0,end-start);const fromConfig={...fromConfigRaw};const toConfig={...toConfigRaw};return new TWEEN.Tween(fromConfig).to(toConfig,tweenDuration).delay(start).easing(easingFn).onUpdate(obj=>{for(const key in obj){shaderPass.setParameter(key,obj[key])}})};this.shaderPasses.forEach(shaderPass=>{if(shaderPass.constructor.name==="ChromaticAberrationShaderPass"){if(typeof shaderPass.getPresetConfig!=="function"||typeof shaderPass.setParameter!=="function"){console.error(`${shaderPass.constructor.name} 中没有 getPresetConfig 或 setParameter 方法`);return}const noneConfig=shaderPass.getPresetConfig("none");if(!noneConfig){console.error(`${shaderPass.constructor.name} 中没有 none 预设配置`);return}for(const key in noneConfig){shaderPass.setParameter(key,noneConfig[key])}const t1=createPresetTween(shaderPass,"none","low",50,620,TWEEN.Easing.Sinusoidal.InOut);const t2=createPresetTween(shaderPass,"low","glitch_split",620,980,TWEEN.Easing.Exponential.Out);const t3=createPresetTween(shaderPass,"glitch_split","anamorphic_edge",980,1450,TWEEN.Easing.Back.InOut);const t4=createPresetTween(shaderPass,"anamorphic_edge","subtle_lens",1450,1750,TWEEN.Easing.Circular.Out);const t5=createPresetTween(shaderPass,"subtle_lens","none",1750,1850,TWEEN.Easing.Sinusoidal.InOut);const t6=createPresetTween(shaderPass,"none","none",1850,1950,TWEEN.Easing.Sinusoidal.InOut);[t1,t2,t3,t4,t5,t6].forEach(t=>{if(t)tweens.push(t)})}});tweens.forEach(tween=>tween.start());return tweens}initPostProcessing(){if(!this.usePostProcessing)return;const shaderPassConfigs=[{name:"LumiChromaticAberration"}];this.setupPostProcessing(shaderPassConfigs);const tweens=this.addAnimations();if(tweens.length>0){if(!this.sceneObjects.tweens){this.sceneObjects.tweens=[]}this.sceneObjects.tweens.push(...tweens)}}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()}setupScene(){this.initSceneObjects();this.createCrystalPortalPlane();this.setupAnimations();return this.sceneObjects}initSceneObjects(){this.Duration=2e3;this.scene.background=new THREE.Color(2041651);this.camera.position.set(0,0,10);this.camera.lookAt(0,0,0);this.sceneObjects={portalPlane:null,portalMaterial:null,tweens:[]}}createCrystalPortalPlane(){const geometry=new THREE.PlaneGeometry(10,10,1,1);geometry.name="晶体传送门几何体";const material=new THREE.ShaderMaterial({name:"晶体传送门材质",side:THREE.DoubleSide,transparent:false,uniforms:{texture1:{value:this.texture1},texture2:{value:this.texture2},u_energyProgress:{value:0},u_crystalSpread:{value:0},u_collapse:{value:0},u_portalReveal:{value:0},u_chromatic:{value:0},u_brightness:{value:1},u_grayscale:{value:0},ratio:{value:1}},vertexShader:` + varying vec2 vUv; + void main() { + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); + } + `,fragmentShader:` + precision mediump float; + + uniform sampler2D texture1; + uniform sampler2D texture2; + uniform float u_energyProgress; + uniform float u_crystalSpread; + uniform float u_collapse; + uniform float u_portalReveal; + uniform float u_chromatic; + uniform float u_brightness; + uniform float u_grayscale; + uniform float ratio; + + varying vec2 vUv; + + float hash21(vec2 p) { + p = fract(p * vec2(123.34, 345.45)); + p += dot(p, p + 34.345); + return fract(p.x * p.y); + } + + float noise(vec2 p) { + vec2 i = floor(p); + vec2 f = fract(p); + float a = hash21(i); + float b = hash21(i + vec2(1.0, 0.0)); + float c = hash21(i + vec2(0.0, 1.0)); + float d = hash21(i + vec2(1.0, 1.0)); + vec2 u = f * f * (3.0 - 2.0 * f); + return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y; + } + + vec2 getAspectCorrectUV(vec2 uv) { + vec2 aspectUV = uv; + if (ratio > 1.0) { + aspectUV.y /= ratio; + aspectUV.y += (1.0 - 1.0 / ratio) * 0.5; + } else { + aspectUV.x *= ratio; + aspectUV.x += (1.0 - ratio) * 0.5; + } + return aspectUV; + } + + void main() { + vec2 uv = vUv; + vec2 auv = getAspectCorrectUV(uv); + vec2 c = vec2(0.5); + vec2 p = auv - c; + float r = length(p); + float angle = atan(p.y, p.x); + + float core = 1.0 - smoothstep(0.01, 0.22, r); + float corePulse = core * (0.35 + 0.65 * u_energyProgress); + + float branchBase = abs(sin(angle * 9.0 + noise(p * 18.0) * 4.5)); + float branchThin = smoothstep(0.72, 0.98, branchBase); + float spreadFront = smoothstep(0.0, 1.0, u_crystalSpread); + float spreadMask = 1.0 - smoothstep(spreadFront * 0.95 + 0.08, spreadFront * 1.2 + 0.22, r); + float veins = branchThin * spreadMask * smoothstep(0.08, 0.95, r + 0.08); + + float collapseRadius = mix(0.95, 0.06, u_collapse); + float collapseHole = 1.0 - smoothstep(collapseRadius - 0.03, collapseRadius + 0.03, r); + + float fissureReveal = veins * smoothstep(0.0, 0.5, u_portalReveal) * 0.65; + float portalCore = smoothstep(0.0, 1.0, u_portalReveal) * collapseHole; + float revealB = clamp(max(u_portalReveal, max(fissureReveal, portalCore)), 0.0, 1.0); + + vec4 colA = texture2D(texture1, uv); + vec4 colB = texture2D(texture2, uv); + + vec3 crystalTint = vec3(0.35, 0.82, 1.0) * corePulse + vec3(0.48, 0.97, 1.0) * veins; + vec3 enhancedA = colA.rgb + crystalTint * (1.0 - u_collapse * 0.75); + + vec3 mixed = mix(enhancedA, colB.rgb, revealB); + + vec2 dir = uv - vec2(0.5); + float offset = u_chromatic * 0.02; + float rCh = texture2D(texture1, uv + dir * offset).r; + float gCh = texture2D(texture1, uv).g; + float bCh = texture2D(texture1, uv - dir * offset).b; + vec3 chromaColor = vec3(rCh, gCh, bCh); + + mixed = mix(mixed, chromaColor, clamp(u_chromatic, 0.0, 1.0) * (1.0 - revealB * 0.35)); + mixed *= u_brightness; + + float gray = dot(mixed, vec3(0.299, 0.587, 0.114)); + mixed = mix(mixed, vec3(gray), u_grayscale); + + gl_FragColor = vec4(mixed, 1.0); + } + `});material.uniform=material.uniforms;const plane=new THREE.Mesh(geometry,material);plane.name="晶体传送门平面";plane.position.set(0,0,0);plane.scale.set(1,1,1);this.scene.add(plane);this.sceneObjects.portalPlane=plane;this.sceneObjects.portalMaterial=material}setupAnimations(){const{portalPlane,portalMaterial}=this.sceneObjects;this.sceneObjects.tweens=[];const energyStart={v:0};const energyEnd={v:1};const energyTween=new TWEEN.Tween(energyStart).to(energyEnd,550).delay(50).easing(TWEEN.Easing.Exponential.InOut).onUpdate(obj=>{portalMaterial.uniforms.u_energyProgress.value=obj.v}).start();this.sceneObjects.tweens.push(energyTween);const spreadStart={v:0};const spreadEnd={v:1};const spreadTween=new TWEEN.Tween(spreadStart).to(spreadEnd,600).delay(600).easing(customEasings.Progress.Impact.Shatter).onUpdate(obj=>{portalMaterial.uniforms.u_crystalSpread.value=obj.v}).start();this.sceneObjects.tweens.push(spreadTween);const collapseStart={v:0};const collapseEnd={v:1};const collapseTween=new TWEEN.Tween(collapseStart).to(collapseEnd,550).delay(1200).easing(customEasings.Progress.Motion.SnapBack).onUpdate(obj=>{portalMaterial.uniforms.u_collapse.value=obj.v}).start();this.sceneObjects.tweens.push(collapseTween);const revealStart={v:0};const revealEnd={v:1};const revealTween=new TWEEN.Tween(revealStart).to(revealEnd,650).delay(1200).easing(TWEEN.Easing.Sinusoidal.InOut).onUpdate(obj=>{portalMaterial.uniforms.u_portalReveal.value=obj.v}).start();this.sceneObjects.tweens.push(revealTween);const scale1Start={s:1};const scale1End={s:1.06};const scaleTween1=new TWEEN.Tween(scale1Start).to(scale1End,140).delay(620).easing(TWEEN.Easing.Back.Out).onUpdate(obj=>{portalPlane.scale.set(obj.s,obj.s,obj.s)}).start();this.sceneObjects.tweens.push(scaleTween1);const scale2Start={s:1.06};const scale2End={s:.98};const scaleTween2=new TWEEN.Tween(scale2Start).to(scale2End,170).delay(760).easing(customEasings.OutIn.Back).onUpdate(obj=>{portalPlane.scale.set(obj.s,obj.s,obj.s)}).start();this.sceneObjects.tweens.push(scaleTween2);const scale3Start={s:.98};const scale3End={s:1};const scaleTween3=new TWEEN.Tween(scale3Start).to(scale3End,150).delay(930).easing(TWEEN.Easing.Circular.Out).onUpdate(obj=>{portalPlane.scale.set(obj.s,obj.s,obj.s)}).start();this.sceneObjects.tweens.push(scaleTween3);const chroma1Start={v:0};const chroma1End={v:.45};const chromaTween1=new TWEEN.Tween(chroma1Start).to(chroma1End,35).delay(620).easing(TWEEN.Easing.Exponential.Out).onUpdate(obj=>{portalMaterial.uniforms.u_chromatic.value=obj.v}).start();this.sceneObjects.tweens.push(chromaTween1);const chroma2Start={v:.45};const chroma2End={v:0};const chromaTween2=new TWEEN.Tween(chroma2Start).to(chroma2End,425).delay(655).easing(customEasings.Progress.Physics.DampedOscillation).onUpdate(obj=>{portalMaterial.uniforms.u_chromatic.value=obj.v}).start();this.sceneObjects.tweens.push(chromaTween2);const cam1Start={z:10};const cam1End={z:9.4};const camTween1=new TWEEN.Tween(cam1Start).to(cam1End,850).delay(50).easing(TWEEN.Easing.Sinusoidal.InOut).onUpdate(obj=>{this.camera.position.set(0,0,obj.z);this.camera.lookAt(0,0,0)}).start();this.sceneObjects.tweens.push(camTween1);const cam2Start={z:9.4};const cam2End={z:10};const camTween2=new TWEEN.Tween(cam2Start).to(cam2End,1e3).delay(900).easing(TWEEN.Easing.Sinusoidal.InOut).onUpdate(obj=>{this.camera.position.set(0,0,obj.z);this.camera.lookAt(0,0,0)}).start();this.sceneObjects.tweens.push(camTween2);const ratioStateStart={t:0};const ratioStateEnd={t:1};const ratioTween=new TWEEN.Tween(ratioStateStart).to(ratioStateEnd,this.Duration).delay(0).easing(TWEEN.Easing.Linear.None).onUpdate(()=>{if(!this.texture1||!this.texture1.image||!this.texture1.image.width||!this.texture1.image.height){portalMaterial.uniform.ratio.value=1}else{portalMaterial.uniform.ratio.value=this.texture1.image.width/this.texture1.image.height}}).start();this.sceneObjects.tweens.push(ratioTween)}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; \ No newline at end of file diff --git a/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/three-amg-wrapper.js b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/three-amg-wrapper.js new file mode 100644 index 0000000000000000000000000000000000000000..c2037e314e032c4d36912923d4cc1258cba3ab19 --- /dev/null +++ b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/three-amg-wrapper.js @@ -0,0 +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;iobj.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; \ No newline at end of file diff --git a/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/tween.js b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/tween.js new file mode 100644 index 0000000000000000000000000000000000000000..690fb9e4284728629129deed5a5a3f4bcec291ed --- /dev/null +++ b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/tween.js @@ -0,0 +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=power1e4?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;_i0){this._tweensAddedDuringUpdate={};for(var i=0;i1){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[m1;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;itotalTime){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;ithis.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;ithis.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.xthis.max.x||box.max.ythis.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; \ No newline at end of file diff --git a/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Box3.js b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Box3.js new file mode 100644 index 0000000000000000000000000000000000000000..4100dc7442d3a622827c8a415e24557f68c491f1 --- /dev/null +++ b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Box3.js @@ -0,0 +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=3?array[offset+2]:0;if(xthis.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=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.xthis.max.x||box.max.ythis.max.y||box.max.zthis.max.z)}}exports.Box3=Box3; \ No newline at end of file diff --git a/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..be3b8b1334a62f5e88c45feee098063a199fca55 --- /dev/null +++ b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js @@ -0,0 +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=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; \ No newline at end of file diff --git a/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..af9a8a13a46500e78f082a35e18d0b5932061234 --- /dev/null +++ b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js @@ -0,0 +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;iObject.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;i1?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; \ No newline at end of file diff --git a/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Constants.js b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Constants.js new file mode 100644 index 0000000000000000000000000000000000000000..6b8adda19a4d67236719804f5170889b39fd4582 --- /dev/null +++ b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Constants.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js new file mode 100644 index 0000000000000000000000000000000000000000..29b0aad5599401be17f967ba1d48851acb70c2ac --- /dev/null +++ b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js @@ -0,0 +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;i0||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;i0?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;imaxX)maxX=p.x;if(p.ymaxY)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; \ No newline at end of file diff --git a/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..f3dee08bf1c089e040fcfef228902ab9a39c93cb --- /dev/null +++ b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Earcut.js b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Earcut.js new file mode 100644 index 0000000000000000000000000000000000000000..953abffdf38c2def26df73fed180eff8c7644ced --- /dev/null +++ b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Earcut.js @@ -0,0 +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;imaxX)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=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=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.x&&p.x>=mx&&hx!==p.x&&pointInTriangle(hym.x||p.x===m.x&§orContainsSector(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.xb.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;i0||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=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;i0){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;imaxX)maxX=contour[i].x;if(contour[i].ymaxY)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;layerIdx0?-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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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; \ No newline at end of file diff --git a/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Group.js b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Group.js new file mode 100644 index 0000000000000000000000000000000000000000..90c4dbef65aa04d7a3bb6b6d76ec3317ea65a228 --- /dev/null +++ b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Group.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");class Group extends Object3D{constructor(name="Group_w"){super(name)}dispose(){super.dispose()}}exports.Group=Group; \ No newline at end of file diff --git a/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Material.js b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Material.js new file mode 100644 index 0000000000000000000000000000000000000000..81b97053ad9d1e4b1ef05d5ac6ed992487b2ca8e --- /dev/null +++ b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Material.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..dcf34d4cffb9de0869382a24690f78f60dda6049 --- /dev/null +++ b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js new file mode 100644 index 0000000000000000000000000000000000000000..41e6cd0a0eee7dd7bc497be5deac584806b68dc3 --- /dev/null +++ b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Mesh.js b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Mesh.js new file mode 100644 index 0000000000000000000000000000000000000000..254d69b074e797dd34c16d7dad723bbcc3b4895d --- /dev/null +++ b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Mesh.js @@ -0,0 +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;imaterial,set:value=>{material=value;if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;im.dispose&&m.dispose());else if(this.material.dispose)this.material.dispose()}}}exports.MeshWrapper=MeshWrapper; \ No newline at end of file diff --git a/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..ac394f66efc4e113a7127ee0f50ec672e4c5e9eb --- /dev/null +++ b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Object3D.js b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Object3D.js new file mode 100644 index 0000000000000000000000000000000000000000..8532c6122f839460aab34fe88957802ff523318b --- /dev/null +++ b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Object3D.js @@ -0,0 +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{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&¤tScene._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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js new file mode 100644 index 0000000000000000000000000000000000000000..ba39801de50d38ec04424f3c2ebfa2ff5d28fded --- /dev/null +++ b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js @@ -0,0 +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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..bc595fb80ad9e7c2f4d8360c67dbef556f3d6cbe --- /dev/null +++ b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js @@ -0,0 +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;iy0){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; \ No newline at end of file diff --git a/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..02dc1be955bc766de744222a7e75c65bf147bb61 --- /dev/null +++ b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js @@ -0,0 +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&¶meters.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{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=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=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=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; \ No newline at end of file diff --git a/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Shape.js b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Shape.js new file mode 100644 index 0000000000000000000000000000000000000000..ecde48b5ceb30812c922aa5c7cfe2aa7b50cabe4 --- /dev/null +++ b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Shape.js @@ -0,0 +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;i0){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;i0||(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;imaxX)maxX=p.x;if(p.ymaxY)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;i0?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;ipoints.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;itwoPi)deltaAngle-=twoPi;if(deltaAngle>4;uuid[i]=chars[i===19?r&3|8:r]}}return uuid.join("")}exports.Shape=Shape; \ No newline at end of file diff --git a/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..3786abc7d64ed80b56101c4ac9d30ce9fcb8f941 --- /dev/null +++ b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js @@ -0,0 +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;i0){const bounds=calculateBounds(flatVertices);const vertexOffset=vertices.length/3;for(let j=0;j0){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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}function calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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; \ No newline at end of file diff --git a/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..1ea27a55fbce9fc3771c66840c068e5ff6347092 --- /dev/null +++ b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Texture.js b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Texture.js new file mode 100644 index 0000000000000000000000000000000000000000..35bff49d732c9884e07bfcb5682f18a860485e1f --- /dev/null +++ b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Texture.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Vector2.js b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Vector2.js new file mode 100644 index 0000000000000000000000000000000000000000..a30a2431264ee62cec937714dfa9e50932ddedeb --- /dev/null +++ b/scripts/7681409924433333512/AmazingFeature/js/ThreeJS/wrapper/Vector2.js @@ -0,0 +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)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)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){if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-6*k)*Math.cos(12*k)};const springStiff=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(18*k)};const dampedOscillation=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(10*k)};const Physics=Object.freeze({SpringSoft:springSoft,SpringStiff:springStiff,DampedOscillation:dampedOscillation});const anticipate=k=>{if(k<=0)return 0;if(k>=1)return 1;const pullback=.1;if(k<.3){const p=k/.3;return-pullback*p*(2-p)}const p=(k-.3)/.7;return-pullback+(1+pullback)*p*p*(3-2*p)};const overshootFactory=peak=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return peak*p*(2-p)}const p=(k-.6)/.4;return peak+(1-peak)*(1-Math.pow(1-p,3))};const overshoot110=overshootFactory(1.1);const overshoot125=overshootFactory(1.25);const snapBack=k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return 1.05*(1-Math.pow(1-p,3))}const p=(k-.6)/.4;return 1.05-.05*p*p*(3-2*p)};const swing=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.cos(1.5*Math.PI*k)*Math.exp(-2.5*k)};const Motion=Object.freeze({Anticipate:anticipate,Overshoot110:overshoot110,Overshoot125:overshoot125,SnapBack:snapBack,Swing:swing});const makeStep=(n,jumpTerm="end")=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(jumpTerm==="start")return Math.ceil(k*n)/n;return Math.floor(k*n)/n};const Step=Object.freeze({Steps4End:makeStep(4,"end"),Steps8End:makeStep(8,"end"),Steps12End:makeStep(12,"end")});function buildCubicBezier(x1,y1,x2,y2){const cx=3*x1,bx=3*(x2-x1)-cx,ax=1-cx-bx;const cy=3*y1,by=3*(y2-y1)-cy,ay=1-cy-by;const sampleX=s=>((ax*s+bx)*s+cx)*s;const sampleY=s=>((ay*s+by)*s+cy)*s;const sampleDX=s=>(3*ax*s+2*bx)*s+cx;const solveS=x=>{let s=x;for(let i=0;i<8;i++){const cur=sampleX(s)-x;if(Math.abs(cur)<1e-6)return s;const d=sampleDX(s);if(Math.abs(d)<1e-6)break;s-=cur/d;if(s<0)s=0;if(s>1)s=1}let lo=0,hi=1;for(let i=0;i<32&&hi-lo>1e-6;i++){const mid=(lo+hi)/2;if(sampleX(mid){if(k<=0)return 0;if(k>=1)return 1;return sampleY(solveS(k))}}const BEZIER_PRESETS=Object.freeze({"Material.Standard":[.4,0,.2,1],"Material.Accelerate":[.4,0,1,1],"Material.Decelerate":[0,0,.2,1],"CSS.Ease":[.25,.1,.25,1]});const _bezierCache=new Map;function _cachedBezier(x1,y1,x2,y2){const key=x1+","+y1+","+x2+","+y2;let fn=_bezierCache.get(key);if(!fn){fn=buildCubicBezier(x1,y1,x2,y2);_bezierCache.set(key,fn)}return fn}function cubicBezier(a,b,c,d){if(typeof a==="string"){let preset=BEZIER_PRESETS[a];if(!preset){console.warn("[customEasings.cubicBezier] unknown preset, falling back to Material.Standard:",a);preset=BEZIER_PRESETS["Material.Standard"]}return _cachedBezier(preset[0],preset[1],preset[2],preset[3])}const clamp=(v,lo,hi)=>Math.max(lo,Math.min(hi,v));const x1=clamp(a,0,1);const y1=clamp(b,-.5,1.5);const x2=clamp(c,0,1);const y2=clamp(d,-.5,1.5);return _cachedBezier(x1,y1,x2,y2)}const libSpring=({stiffness=180,damping=12,mass=1}={})=>{const DT=1/240;const T=1.5;let x=0,v=0;const samples=[];for(let t=0;t<=T;t+=DT){const force=-stiffness*(x-1)-damping*v;v+=force/mass*DT;x+=v*DT;samples.push({t:t,x:x})}let T_end=T;for(let i=samples.length-1;i>=0;i--){if(Math.abs(samples[i].x-1)>.01){T_end=samples[i].t;break}}return k=>{if(k<=0)return 0;if(k>=1)return 1;const t=k*T_end;const idx=Math.min(samples.length-1,Math.floor(t/DT));return samples[idx].x}};const libHeartBeat=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c)=>Math.exp(-((t-c)**2)/(2*.07*.07));return peak*(bell(k,.2)+bell(k,.5))};const libSteps=(n=6)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return Math.floor(k*n)/n};const attentionPing=(peak=.35,decay=2)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(Math.PI*k)*Math.exp(-decay*k)};const attentionWiggle=(count=4,amplitude=.25)=>k=>{if(k<=0||k>=1)return 0;const env=1-k;return amplitude*env*Math.sin(k*Math.PI*2*count)};const attentionStrum=(notes=4,peak=.4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*.05*.05))}return peak*sum}};const Attention=Object.freeze({Ping:attentionPing(),Wiggle:attentionWiggle(),Strum:attentionStrum()});const breathNormal=(cycles=2,peak=.15)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(k*Math.PI*2*cycles)*Math.sin(k*Math.PI)};const breathDeep=(peak=.3,riseRatio=.35,holdRatio=.15)=>{const holdEnd=riseRatio+holdRatio;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const envelope=Math.sin(k*Math.PI);const wave=.5+.5*Math.sin(k*Math.PI*2*cycles-Math.PI/2);return peak*envelope*wave};const breathSigh=(peak=.25,riseRatio=.2)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return peak*Math.exp(-((k-center)**2)/(2*width*width))};const heartExcited=(beats=4,peak=.3,width=.04)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*width*width))}return peak*sum}};const heartLubDub=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return peak*(bell(k,.25,.045)+.6*bell(k,.42,.03))};const Heart=Object.freeze({Calm:heartCalm(),Excited:heartExcited(),LubDub:heartLubDub()});const mathJumpArc=()=>k=>{if(k<=0||k>=1)return 0;return 4*k*(1-k)};const mathPendulum=(damping=3,freq=2.5)=>k=>{if(k<=0||k>=1)return 0;return Math.sin(k*Math.PI)*Math.exp(-damping*k)*Math.cos(freq*Math.PI*k)};const mathTremor=(amplitude=.04,freq=22)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return k+amplitude*Math.sin(k*Math.PI*2*freq)};const mathBoomerang=fn=>k=>{if(k<=0||k>=1)return 0;return k<.5?fn(k*2):fn(2-k*2)};const MathExt=Object.freeze({JumpArc:mathJumpArc(),Pendulum:mathPendulum(),Tremor:mathTremor()});const explosionImpulse=(sharpness=6)=>{const tail=sharpness*Math.exp(1-sharpness);return k=>{if(k<=0||k>=1)return 0;const h=sharpness*k;return h*Math.exp(1-h)-tail*k}};const explosionFlash=(rise=.05,decay=5)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return-Math.exp(-decay*k)*Math.cos(freq*Math.PI*k)};const explosionImplosion=(charge=.3,depth=.4,burstPeak=1.2)=>{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const w=Math.sin(k*Math.PI*2*cycles)+.5*Math.sin(k*Math.PI*2*cycles*1.5+1.2)+.25*Math.sin(k*Math.PI*2*cycles*3+2.4);return amplitude*env*w*.6};const natureFlicker=(rate=15,intensity=.2,seed=7)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=rate+1;i++)samples.push(rand());return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*rate;const idx=Math.floor(pos);const t=pos-idx;const a=samples[idx];const b=samples[idx+1];const interp=a+(b-a)*t;return intensity*env*(interp-.5)*2}};const natureGust=(gusts=3,peak=.25)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*.08*.08))}return peak*sum/gusts*1.8}};const Nature=Object.freeze({Wave:natureWave(),Flicker:natureFlicker(),Gust:natureGust()});const impactRain=(impactAt=.7,rippleAmp=.08)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const liftEnd=.35,strikeEnd=.6;return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return t*t}const t=(k-.4)/.6;const env=Math.exp(-2.5*t);const wave=Math.abs(Math.sin(t*Math.PI*bounces));return 1-env*wave*rebound};const impactSlap=(contactAt=.3,holdRatio=.1)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return.4*Math.pow(t,2.5)}if(k<.48){const t=(k-.4)/.08;return.4-.2*t}if(k<.52){const t=(k-.48)/.04;return.2+.8*t}const t=(k-.52)/.48;return 1-.04*Math.sin(t*Math.PI*8)*(1-t)};const rhythmPunchCombo=(peak=.4)=>{const pattern=[{c:.15,w:.04,a:.75},{c:.35,w:.04,a:.75},{c:.7,w:.055,a:1}];return k=>{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of pattern){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return peak*sum}};const rhythmStaccato=(beats=4,duty=.3)=>k=>{if(k<=0||k>=1)return 0;const beatLen=1/beats;const phase=k/beatLen-Math.floor(k/beatLen);if(phase>duty)return 0;const t=phase/duty;return Math.sin(t*Math.PI)};const rhythmKick=(peak=1.2)=>k=>{if(k<=0||k>=1)return 0;if(k<.05)return peak*k/.05;const t=(k-.05)/.95;return peak*Math.exp(-4*t)};const rhythmCrescendo=(beats=4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return sum}};const rhythmDunDunDun=()=>{const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return k=>{if(k<=0||k>=1)return 0;return.3*bell(k,.15,.025)+.6*bell(k,.35,.03)+1*bell(k,.68,.09)}};const rhythmBellToll=(decay=3,freq=8)=>{const strike=.05;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.2){const t=k/.2;return-pressDepth*Math.sin(t*Math.PI/2)}if(k<.5){const t=(k-.2)/.3;return-pressDepth+(pressDepth+reboundPeak)*(1-Math.pow(1-t,3))}const t=(k-.5)/.5;return reboundPeak*Math.exp(-4*t)*Math.cos(t*Math.PI*3)};const uiHoverBloom=(riseRatio=.2,fallRatio=.3)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=1-k;const raw=Math.sin(k*Math.PI*2*count);const clipped=Math.sign(raw)*Math.min(1,Math.abs(raw)*1.8);return amplitude*env*clipped};const uiSuccessPop=(overshoot=.2)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return(1+overshoot)*(1-Math.pow(1-t,2))}const t=(k-.4)/.6;return 1+overshoot*Math.exp(-5*t)*Math.cos(t*Math.PI*3)};const uiRippleOut=()=>k=>{if(k<=0||k>=1)return 0;return 6.75*k*Math.pow(1-k,2)};const UI=Object.freeze({ClickSnap:uiClickSnap(),HoverBloom:uiHoverBloom(),ErrorShake:uiErrorShake(),SuccessPop:uiSuccessPop(),RippleOut:uiRippleOut()});const magicManaCharge=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;const base=(Math.exp(3*k)-1)/(Math.exp(3)-1);const pulse=.04*Math.sin(k*Math.PI*8)*k;return base+pulse};const magicSpellCast=(chargeEnd=.4)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.45){const t=k/.45;return t*t*t}if(k<.55)return 1;const t=(k-.55)/.45;return Math.pow(1-t,3)};const magicShield=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.3){const t=k/.3;return 1.2*(1-Math.pow(1-t,2))}if(k<.6){const t=(k-.3)/.3;return 1.2-.2*t}const t=(k-.6)/.4;return 1+.03*Math.sin(t*Math.PI*3)};const magicAura=(peak=.15)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const fundamental=.6*Math.sin(k*Math.PI*2);const harmonic=.3*Math.sin(k*Math.PI*4+1);const overtone=.1*Math.sin(k*Math.PI*6+2);return peak*env*(fundamental+harmonic+overtone)};const Magic=Object.freeze({ManaCharge:magicManaCharge(),SpellCast:magicSpellCast(),Teleport:magicTeleport(),Shield:magicShield(),MagicAura:magicAura()});const animalCatPounce=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.2){const t=k/.2;return-.2*Math.sin(t*Math.PI)}if(k<.3){const t=(k-.2)/.1;return.5*t*t}if(k<.8){const t=(k-.3)/.5;return.5+.5*t+.2*Math.sin(t*Math.PI)}const t=(k-.8)/.2;return 1+.05*Math.sin(t*Math.PI)};const animalBirdFlap=(flaps=4)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const phase=k*Math.PI*2*flaps;const wave=Math.sin(phase)-.3*Math.sin(phase*2);return.2*env*wave};const animalSnakeSlither=(waves=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const wave=Math.sin(k*Math.PI*2*waves);return.2*env*wave};const animalButterflyFlit=(seed=13)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=26;i++)samples.push(rand()-.5);return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*25;const idx=Math.floor(pos);const t=pos-idx;const smooth=t*t*(3-2*t);const interp=samples[idx]+(samples[idx+1]-samples[idx])*smooth;return.3*env*interp}};const animalHorseGallop=(cycles=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const cyclePos=k*cycles-Math.floor(k*cycles);const bell=(c,w=.04)=>Math.exp(-((cyclePos-c)**2)/(2*w*w));return.25*env*(bell(0)+bell(.18)+bell(.36)+bell(.54))};const Animal=Object.freeze({CatPounce:animalCatPounce(),BirdFlap:animalBirdFlap(),SnakeSlither:animalSnakeSlither(),ButterflyFlit:animalButterflyFlit(),HorseGallop:animalHorseGallop()});const Progress=Object.freeze({Physics:Object.freeze({...Physics,Spring:libSpring()}),Motion:Motion,Step:Object.freeze({...Step,Steps6:libSteps()}),Math:Object.freeze({Tremor:MathExt.Tremor}),Impact:Object.freeze({Rain:Impact.Rain,Hammer:Impact.Hammer,BounceDrop:Impact.BounceDrop,ArrowHit:Impact.ArrowHit,Shatter:Impact.Shatter}),Rhythm:Object.freeze({BassDrop:Rhythm.BassDrop}),UI:Object.freeze({SuccessPop:UI.SuccessPop}),Magic:Object.freeze({ManaCharge:Magic.ManaCharge,Shield:Magic.Shield}),Animal:Object.freeze({CatPounce:Animal.CatPounce})});const Pulse=Object.freeze({Attention:Object.freeze({Ping:Attention.Ping}),Breath:Object.freeze({Deep:Breath.Deep,Sigh:Breath.Sigh}),Heart:Object.freeze({Calm:Heart.Calm}),Math:Object.freeze({JumpArc:MathExt.JumpArc,BoomerangSharp:mathBoomerang(E.Cubic.In),BoomerangSoft:mathBoomerang(E.Cubic.Out)}),Explosion:Object.freeze({Impulse:Explosion.Impulse,Flash:Explosion.Flash,Recoil:Explosion.Recoil,Implosion:Explosion.Implosion}),Impact:Object.freeze({Slap:Impact.Slap}),Rhythm:Object.freeze({Kick:Rhythm.Kick}),UI:Object.freeze({ClickSnap:UI.ClickSnap,HoverBloom:UI.HoverBloom,RippleOut:UI.RippleOut}),Magic:Object.freeze({SpellCast:Magic.SpellCast,Teleport:Magic.Teleport})});const Wave=Object.freeze({Attention:Object.freeze({Wiggle:Attention.Wiggle,Strum:Attention.Strum}),Breath:Object.freeze({Normal:Breath.Normal,Panting:Breath.Panting}),Heart:Object.freeze({Excited:Heart.Excited,LubDub:Heart.LubDub,Beat:libHeartBeat()}),Math:Object.freeze({Pendulum:MathExt.Pendulum}),Nature:Nature,Rhythm:Object.freeze({PunchCombo:Rhythm.PunchCombo,Staccato:Rhythm.Staccato,Crescendo:Rhythm.Crescendo,DunDunDun:Rhythm.DunDunDun,BellToll:Rhythm.BellToll}),UI:Object.freeze({ErrorShake:UI.ErrorShake}),Magic:Object.freeze({MagicAura:Magic.MagicAura}),Animal:Object.freeze({BirdFlap:Animal.BirdFlap,SnakeSlither:Animal.SnakeSlither,ButterflyFlit:Animal.ButterflyFlit,HorseGallop:Animal.HorseGallop})});const customEasings=Object.freeze({makeOutIn:makeOutIn,OutIn:OutIn,Progress:Progress,Pulse:Pulse,Wave:Wave,cubicBezier:cubicBezier});exports.customEasings=customEasings;exports.default=customEasings; \ No newline at end of file diff --git a/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/scriptScene.js b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/scriptScene.js new file mode 100644 index 0000000000000000000000000000000000000000..5d5f0a8bde54f7efa0912b77bb0a8298e3fb04e9 --- /dev/null +++ b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/scriptScene.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/three-amg-wrapper.js b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/three-amg-wrapper.js new file mode 100644 index 0000000000000000000000000000000000000000..c2037e314e032c4d36912923d4cc1258cba3ab19 --- /dev/null +++ b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/three-amg-wrapper.js @@ -0,0 +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;iobj.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; \ No newline at end of file diff --git a/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/tween.js b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/tween.js new file mode 100644 index 0000000000000000000000000000000000000000..690fb9e4284728629129deed5a5a3f4bcec291ed --- /dev/null +++ b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/tween.js @@ -0,0 +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=power1e4?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;_i0){this._tweensAddedDuringUpdate={};for(var i=0;i1){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[m1;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;itotalTime){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;ithis.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;ithis.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.xthis.max.x||box.max.ythis.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; \ No newline at end of file diff --git a/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Box3.js b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Box3.js new file mode 100644 index 0000000000000000000000000000000000000000..4100dc7442d3a622827c8a415e24557f68c491f1 --- /dev/null +++ b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Box3.js @@ -0,0 +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=3?array[offset+2]:0;if(xthis.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=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.xthis.max.x||box.max.ythis.max.y||box.max.zthis.max.z)}}exports.Box3=Box3; \ No newline at end of file diff --git a/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..be3b8b1334a62f5e88c45feee098063a199fca55 --- /dev/null +++ b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js @@ -0,0 +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=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; \ No newline at end of file diff --git a/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..af9a8a13a46500e78f082a35e18d0b5932061234 --- /dev/null +++ b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js @@ -0,0 +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;iObject.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;i1?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; \ No newline at end of file diff --git a/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Constants.js b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Constants.js new file mode 100644 index 0000000000000000000000000000000000000000..6b8adda19a4d67236719804f5170889b39fd4582 --- /dev/null +++ b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Constants.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js new file mode 100644 index 0000000000000000000000000000000000000000..29b0aad5599401be17f967ba1d48851acb70c2ac --- /dev/null +++ b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js @@ -0,0 +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;i0||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;i0?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;imaxX)maxX=p.x;if(p.ymaxY)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; \ No newline at end of file diff --git a/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..f3dee08bf1c089e040fcfef228902ab9a39c93cb --- /dev/null +++ b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Earcut.js b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Earcut.js new file mode 100644 index 0000000000000000000000000000000000000000..953abffdf38c2def26df73fed180eff8c7644ced --- /dev/null +++ b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Earcut.js @@ -0,0 +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;imaxX)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=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=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.x&&p.x>=mx&&hx!==p.x&&pointInTriangle(hym.x||p.x===m.x&§orContainsSector(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.xb.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;i0||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=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;i0){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;imaxX)maxX=contour[i].x;if(contour[i].ymaxY)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;layerIdx0?-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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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; \ No newline at end of file diff --git a/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Group.js b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Group.js new file mode 100644 index 0000000000000000000000000000000000000000..90c4dbef65aa04d7a3bb6b6d76ec3317ea65a228 --- /dev/null +++ b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Group.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");class Group extends Object3D{constructor(name="Group_w"){super(name)}dispose(){super.dispose()}}exports.Group=Group; \ No newline at end of file diff --git a/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Material.js b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Material.js new file mode 100644 index 0000000000000000000000000000000000000000..81b97053ad9d1e4b1ef05d5ac6ed992487b2ca8e --- /dev/null +++ b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Material.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..dcf34d4cffb9de0869382a24690f78f60dda6049 --- /dev/null +++ b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js new file mode 100644 index 0000000000000000000000000000000000000000..41e6cd0a0eee7dd7bc497be5deac584806b68dc3 --- /dev/null +++ b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Mesh.js b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Mesh.js new file mode 100644 index 0000000000000000000000000000000000000000..254d69b074e797dd34c16d7dad723bbcc3b4895d --- /dev/null +++ b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Mesh.js @@ -0,0 +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;imaterial,set:value=>{material=value;if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;im.dispose&&m.dispose());else if(this.material.dispose)this.material.dispose()}}}exports.MeshWrapper=MeshWrapper; \ No newline at end of file diff --git a/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..ac394f66efc4e113a7127ee0f50ec672e4c5e9eb --- /dev/null +++ b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Object3D.js b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Object3D.js new file mode 100644 index 0000000000000000000000000000000000000000..8532c6122f839460aab34fe88957802ff523318b --- /dev/null +++ b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Object3D.js @@ -0,0 +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{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&¤tScene._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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js new file mode 100644 index 0000000000000000000000000000000000000000..ba39801de50d38ec04424f3c2ebfa2ff5d28fded --- /dev/null +++ b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js @@ -0,0 +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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..bc595fb80ad9e7c2f4d8360c67dbef556f3d6cbe --- /dev/null +++ b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js @@ -0,0 +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;iy0){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; \ No newline at end of file diff --git a/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..02dc1be955bc766de744222a7e75c65bf147bb61 --- /dev/null +++ b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js @@ -0,0 +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&¶meters.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{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=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=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=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; \ No newline at end of file diff --git a/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Shape.js b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Shape.js new file mode 100644 index 0000000000000000000000000000000000000000..ecde48b5ceb30812c922aa5c7cfe2aa7b50cabe4 --- /dev/null +++ b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Shape.js @@ -0,0 +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;i0){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;i0||(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;imaxX)maxX=p.x;if(p.ymaxY)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;i0?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;ipoints.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;itwoPi)deltaAngle-=twoPi;if(deltaAngle>4;uuid[i]=chars[i===19?r&3|8:r]}}return uuid.join("")}exports.Shape=Shape; \ No newline at end of file diff --git a/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..3786abc7d64ed80b56101c4ac9d30ce9fcb8f941 --- /dev/null +++ b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js @@ -0,0 +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;i0){const bounds=calculateBounds(flatVertices);const vertexOffset=vertices.length/3;for(let j=0;j0){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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}function calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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; \ No newline at end of file diff --git a/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..1ea27a55fbce9fc3771c66840c068e5ff6347092 --- /dev/null +++ b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Texture.js b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Texture.js new file mode 100644 index 0000000000000000000000000000000000000000..35bff49d732c9884e07bfcb5682f18a860485e1f --- /dev/null +++ b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Texture.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Vector2.js b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Vector2.js new file mode 100644 index 0000000000000000000000000000000000000000..a30a2431264ee62cec937714dfa9e50932ddedeb --- /dev/null +++ b/scripts/7681452406219050248/AmazingFeature/js/ThreeJS/wrapper/Vector2.js @@ -0,0 +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)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)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){if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-6*k)*Math.cos(12*k)};const springStiff=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(18*k)};const dampedOscillation=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(10*k)};const Physics=Object.freeze({SpringSoft:springSoft,SpringStiff:springStiff,DampedOscillation:dampedOscillation});const anticipate=k=>{if(k<=0)return 0;if(k>=1)return 1;const pullback=.1;if(k<.3){const p=k/.3;return-pullback*p*(2-p)}const p=(k-.3)/.7;return-pullback+(1+pullback)*p*p*(3-2*p)};const overshootFactory=peak=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return peak*p*(2-p)}const p=(k-.6)/.4;return peak+(1-peak)*(1-Math.pow(1-p,3))};const overshoot110=overshootFactory(1.1);const overshoot125=overshootFactory(1.25);const snapBack=k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return 1.05*(1-Math.pow(1-p,3))}const p=(k-.6)/.4;return 1.05-.05*p*p*(3-2*p)};const swing=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.cos(1.5*Math.PI*k)*Math.exp(-2.5*k)};const Motion=Object.freeze({Anticipate:anticipate,Overshoot110:overshoot110,Overshoot125:overshoot125,SnapBack:snapBack,Swing:swing});const makeStep=(n,jumpTerm="end")=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(jumpTerm==="start")return Math.ceil(k*n)/n;return Math.floor(k*n)/n};const Step=Object.freeze({Steps4End:makeStep(4,"end"),Steps8End:makeStep(8,"end"),Steps12End:makeStep(12,"end")});function buildCubicBezier(x1,y1,x2,y2){const cx=3*x1,bx=3*(x2-x1)-cx,ax=1-cx-bx;const cy=3*y1,by=3*(y2-y1)-cy,ay=1-cy-by;const sampleX=s=>((ax*s+bx)*s+cx)*s;const sampleY=s=>((ay*s+by)*s+cy)*s;const sampleDX=s=>(3*ax*s+2*bx)*s+cx;const solveS=x=>{let s=x;for(let i=0;i<8;i++){const cur=sampleX(s)-x;if(Math.abs(cur)<1e-6)return s;const d=sampleDX(s);if(Math.abs(d)<1e-6)break;s-=cur/d;if(s<0)s=0;if(s>1)s=1}let lo=0,hi=1;for(let i=0;i<32&&hi-lo>1e-6;i++){const mid=(lo+hi)/2;if(sampleX(mid){if(k<=0)return 0;if(k>=1)return 1;return sampleY(solveS(k))}}const BEZIER_PRESETS=Object.freeze({"Material.Standard":[.4,0,.2,1],"Material.Accelerate":[.4,0,1,1],"Material.Decelerate":[0,0,.2,1],"CSS.Ease":[.25,.1,.25,1]});const _bezierCache=new Map;function _cachedBezier(x1,y1,x2,y2){const key=x1+","+y1+","+x2+","+y2;let fn=_bezierCache.get(key);if(!fn){fn=buildCubicBezier(x1,y1,x2,y2);_bezierCache.set(key,fn)}return fn}function cubicBezier(a,b,c,d){if(typeof a==="string"){let preset=BEZIER_PRESETS[a];if(!preset){console.warn("[customEasings.cubicBezier] unknown preset, falling back to Material.Standard:",a);preset=BEZIER_PRESETS["Material.Standard"]}return _cachedBezier(preset[0],preset[1],preset[2],preset[3])}const clamp=(v,lo,hi)=>Math.max(lo,Math.min(hi,v));const x1=clamp(a,0,1);const y1=clamp(b,-.5,1.5);const x2=clamp(c,0,1);const y2=clamp(d,-.5,1.5);return _cachedBezier(x1,y1,x2,y2)}const libSpring=({stiffness=180,damping=12,mass=1}={})=>{const DT=1/240;const T=1.5;let x=0,v=0;const samples=[];for(let t=0;t<=T;t+=DT){const force=-stiffness*(x-1)-damping*v;v+=force/mass*DT;x+=v*DT;samples.push({t:t,x:x})}let T_end=T;for(let i=samples.length-1;i>=0;i--){if(Math.abs(samples[i].x-1)>.01){T_end=samples[i].t;break}}return k=>{if(k<=0)return 0;if(k>=1)return 1;const t=k*T_end;const idx=Math.min(samples.length-1,Math.floor(t/DT));return samples[idx].x}};const libHeartBeat=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c)=>Math.exp(-((t-c)**2)/(2*.07*.07));return peak*(bell(k,.2)+bell(k,.5))};const libSteps=(n=6)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return Math.floor(k*n)/n};const attentionPing=(peak=.35,decay=2)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(Math.PI*k)*Math.exp(-decay*k)};const attentionWiggle=(count=4,amplitude=.25)=>k=>{if(k<=0||k>=1)return 0;const env=1-k;return amplitude*env*Math.sin(k*Math.PI*2*count)};const attentionStrum=(notes=4,peak=.4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*.05*.05))}return peak*sum}};const Attention=Object.freeze({Ping:attentionPing(),Wiggle:attentionWiggle(),Strum:attentionStrum()});const breathNormal=(cycles=2,peak=.15)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(k*Math.PI*2*cycles)*Math.sin(k*Math.PI)};const breathDeep=(peak=.3,riseRatio=.35,holdRatio=.15)=>{const holdEnd=riseRatio+holdRatio;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const envelope=Math.sin(k*Math.PI);const wave=.5+.5*Math.sin(k*Math.PI*2*cycles-Math.PI/2);return peak*envelope*wave};const breathSigh=(peak=.25,riseRatio=.2)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return peak*Math.exp(-((k-center)**2)/(2*width*width))};const heartExcited=(beats=4,peak=.3,width=.04)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*width*width))}return peak*sum}};const heartLubDub=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return peak*(bell(k,.25,.045)+.6*bell(k,.42,.03))};const Heart=Object.freeze({Calm:heartCalm(),Excited:heartExcited(),LubDub:heartLubDub()});const mathJumpArc=()=>k=>{if(k<=0||k>=1)return 0;return 4*k*(1-k)};const mathPendulum=(damping=3,freq=2.5)=>k=>{if(k<=0||k>=1)return 0;return Math.sin(k*Math.PI)*Math.exp(-damping*k)*Math.cos(freq*Math.PI*k)};const mathTremor=(amplitude=.04,freq=22)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return k+amplitude*Math.sin(k*Math.PI*2*freq)};const mathBoomerang=fn=>k=>{if(k<=0||k>=1)return 0;return k<.5?fn(k*2):fn(2-k*2)};const MathExt=Object.freeze({JumpArc:mathJumpArc(),Pendulum:mathPendulum(),Tremor:mathTremor()});const explosionImpulse=(sharpness=6)=>{const tail=sharpness*Math.exp(1-sharpness);return k=>{if(k<=0||k>=1)return 0;const h=sharpness*k;return h*Math.exp(1-h)-tail*k}};const explosionFlash=(rise=.05,decay=5)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return-Math.exp(-decay*k)*Math.cos(freq*Math.PI*k)};const explosionImplosion=(charge=.3,depth=.4,burstPeak=1.2)=>{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const w=Math.sin(k*Math.PI*2*cycles)+.5*Math.sin(k*Math.PI*2*cycles*1.5+1.2)+.25*Math.sin(k*Math.PI*2*cycles*3+2.4);return amplitude*env*w*.6};const natureFlicker=(rate=15,intensity=.2,seed=7)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=rate+1;i++)samples.push(rand());return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*rate;const idx=Math.floor(pos);const t=pos-idx;const a=samples[idx];const b=samples[idx+1];const interp=a+(b-a)*t;return intensity*env*(interp-.5)*2}};const natureGust=(gusts=3,peak=.25)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*.08*.08))}return peak*sum/gusts*1.8}};const Nature=Object.freeze({Wave:natureWave(),Flicker:natureFlicker(),Gust:natureGust()});const impactRain=(impactAt=.7,rippleAmp=.08)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const liftEnd=.35,strikeEnd=.6;return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return t*t}const t=(k-.4)/.6;const env=Math.exp(-2.5*t);const wave=Math.abs(Math.sin(t*Math.PI*bounces));return 1-env*wave*rebound};const impactSlap=(contactAt=.3,holdRatio=.1)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return.4*Math.pow(t,2.5)}if(k<.48){const t=(k-.4)/.08;return.4-.2*t}if(k<.52){const t=(k-.48)/.04;return.2+.8*t}const t=(k-.52)/.48;return 1-.04*Math.sin(t*Math.PI*8)*(1-t)};const rhythmPunchCombo=(peak=.4)=>{const pattern=[{c:.15,w:.04,a:.75},{c:.35,w:.04,a:.75},{c:.7,w:.055,a:1}];return k=>{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of pattern){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return peak*sum}};const rhythmStaccato=(beats=4,duty=.3)=>k=>{if(k<=0||k>=1)return 0;const beatLen=1/beats;const phase=k/beatLen-Math.floor(k/beatLen);if(phase>duty)return 0;const t=phase/duty;return Math.sin(t*Math.PI)};const rhythmKick=(peak=1.2)=>k=>{if(k<=0||k>=1)return 0;if(k<.05)return peak*k/.05;const t=(k-.05)/.95;return peak*Math.exp(-4*t)};const rhythmCrescendo=(beats=4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return sum}};const rhythmDunDunDun=()=>{const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return k=>{if(k<=0||k>=1)return 0;return.3*bell(k,.15,.025)+.6*bell(k,.35,.03)+1*bell(k,.68,.09)}};const rhythmBellToll=(decay=3,freq=8)=>{const strike=.05;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.2){const t=k/.2;return-pressDepth*Math.sin(t*Math.PI/2)}if(k<.5){const t=(k-.2)/.3;return-pressDepth+(pressDepth+reboundPeak)*(1-Math.pow(1-t,3))}const t=(k-.5)/.5;return reboundPeak*Math.exp(-4*t)*Math.cos(t*Math.PI*3)};const uiHoverBloom=(riseRatio=.2,fallRatio=.3)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=1-k;const raw=Math.sin(k*Math.PI*2*count);const clipped=Math.sign(raw)*Math.min(1,Math.abs(raw)*1.8);return amplitude*env*clipped};const uiSuccessPop=(overshoot=.2)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return(1+overshoot)*(1-Math.pow(1-t,2))}const t=(k-.4)/.6;return 1+overshoot*Math.exp(-5*t)*Math.cos(t*Math.PI*3)};const uiRippleOut=()=>k=>{if(k<=0||k>=1)return 0;return 6.75*k*Math.pow(1-k,2)};const UI=Object.freeze({ClickSnap:uiClickSnap(),HoverBloom:uiHoverBloom(),ErrorShake:uiErrorShake(),SuccessPop:uiSuccessPop(),RippleOut:uiRippleOut()});const magicManaCharge=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;const base=(Math.exp(3*k)-1)/(Math.exp(3)-1);const pulse=.04*Math.sin(k*Math.PI*8)*k;return base+pulse};const magicSpellCast=(chargeEnd=.4)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.45){const t=k/.45;return t*t*t}if(k<.55)return 1;const t=(k-.55)/.45;return Math.pow(1-t,3)};const magicShield=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.3){const t=k/.3;return 1.2*(1-Math.pow(1-t,2))}if(k<.6){const t=(k-.3)/.3;return 1.2-.2*t}const t=(k-.6)/.4;return 1+.03*Math.sin(t*Math.PI*3)};const magicAura=(peak=.15)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const fundamental=.6*Math.sin(k*Math.PI*2);const harmonic=.3*Math.sin(k*Math.PI*4+1);const overtone=.1*Math.sin(k*Math.PI*6+2);return peak*env*(fundamental+harmonic+overtone)};const Magic=Object.freeze({ManaCharge:magicManaCharge(),SpellCast:magicSpellCast(),Teleport:magicTeleport(),Shield:magicShield(),MagicAura:magicAura()});const animalCatPounce=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.2){const t=k/.2;return-.2*Math.sin(t*Math.PI)}if(k<.3){const t=(k-.2)/.1;return.5*t*t}if(k<.8){const t=(k-.3)/.5;return.5+.5*t+.2*Math.sin(t*Math.PI)}const t=(k-.8)/.2;return 1+.05*Math.sin(t*Math.PI)};const animalBirdFlap=(flaps=4)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const phase=k*Math.PI*2*flaps;const wave=Math.sin(phase)-.3*Math.sin(phase*2);return.2*env*wave};const animalSnakeSlither=(waves=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const wave=Math.sin(k*Math.PI*2*waves);return.2*env*wave};const animalButterflyFlit=(seed=13)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=26;i++)samples.push(rand()-.5);return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*25;const idx=Math.floor(pos);const t=pos-idx;const smooth=t*t*(3-2*t);const interp=samples[idx]+(samples[idx+1]-samples[idx])*smooth;return.3*env*interp}};const animalHorseGallop=(cycles=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const cyclePos=k*cycles-Math.floor(k*cycles);const bell=(c,w=.04)=>Math.exp(-((cyclePos-c)**2)/(2*w*w));return.25*env*(bell(0)+bell(.18)+bell(.36)+bell(.54))};const Animal=Object.freeze({CatPounce:animalCatPounce(),BirdFlap:animalBirdFlap(),SnakeSlither:animalSnakeSlither(),ButterflyFlit:animalButterflyFlit(),HorseGallop:animalHorseGallop()});const Progress=Object.freeze({Physics:Object.freeze({...Physics,Spring:libSpring()}),Motion:Motion,Step:Object.freeze({...Step,Steps6:libSteps()}),Math:Object.freeze({Tremor:MathExt.Tremor}),Impact:Object.freeze({Rain:Impact.Rain,Hammer:Impact.Hammer,BounceDrop:Impact.BounceDrop,ArrowHit:Impact.ArrowHit,Shatter:Impact.Shatter}),Rhythm:Object.freeze({BassDrop:Rhythm.BassDrop}),UI:Object.freeze({SuccessPop:UI.SuccessPop}),Magic:Object.freeze({ManaCharge:Magic.ManaCharge,Shield:Magic.Shield}),Animal:Object.freeze({CatPounce:Animal.CatPounce})});const Pulse=Object.freeze({Attention:Object.freeze({Ping:Attention.Ping}),Breath:Object.freeze({Deep:Breath.Deep,Sigh:Breath.Sigh}),Heart:Object.freeze({Calm:Heart.Calm}),Math:Object.freeze({JumpArc:MathExt.JumpArc,BoomerangSharp:mathBoomerang(E.Cubic.In),BoomerangSoft:mathBoomerang(E.Cubic.Out)}),Explosion:Object.freeze({Impulse:Explosion.Impulse,Flash:Explosion.Flash,Recoil:Explosion.Recoil,Implosion:Explosion.Implosion}),Impact:Object.freeze({Slap:Impact.Slap}),Rhythm:Object.freeze({Kick:Rhythm.Kick}),UI:Object.freeze({ClickSnap:UI.ClickSnap,HoverBloom:UI.HoverBloom,RippleOut:UI.RippleOut}),Magic:Object.freeze({SpellCast:Magic.SpellCast,Teleport:Magic.Teleport})});const Wave=Object.freeze({Attention:Object.freeze({Wiggle:Attention.Wiggle,Strum:Attention.Strum}),Breath:Object.freeze({Normal:Breath.Normal,Panting:Breath.Panting}),Heart:Object.freeze({Excited:Heart.Excited,LubDub:Heart.LubDub,Beat:libHeartBeat()}),Math:Object.freeze({Pendulum:MathExt.Pendulum}),Nature:Nature,Rhythm:Object.freeze({PunchCombo:Rhythm.PunchCombo,Staccato:Rhythm.Staccato,Crescendo:Rhythm.Crescendo,DunDunDun:Rhythm.DunDunDun,BellToll:Rhythm.BellToll}),UI:Object.freeze({ErrorShake:UI.ErrorShake}),Magic:Object.freeze({MagicAura:Magic.MagicAura}),Animal:Object.freeze({BirdFlap:Animal.BirdFlap,SnakeSlither:Animal.SnakeSlither,ButterflyFlit:Animal.ButterflyFlit,HorseGallop:Animal.HorseGallop})});const customEasings=Object.freeze({makeOutIn:makeOutIn,OutIn:OutIn,Progress:Progress,Pulse:Pulse,Wave:Wave,cubicBezier:cubicBezier});exports.customEasings=customEasings;exports.default=customEasings; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/scriptScene.js b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/scriptScene.js new file mode 100644 index 0000000000000000000000000000000000000000..3823459546c9cd3c5a37d4ae4ddfba33f506d882 --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/scriptScene.js @@ -0,0 +1,49 @@ +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)}addAnimations(){const duration=this.Duration;const tweens=[];const cloneConfig=source=>JSON.parse(JSON.stringify(source));const applyConfig=(config,shaderPass)=>{for(const key in config){if(Object.prototype.hasOwnProperty.call(config,key)){shaderPass.setParameter(key,config[key])}}};this.shaderPasses.forEach(shaderPass=>{const passName=shaderPass.constructor.name;if(passName==="WaveWarpShaderPass"){if(typeof shaderPass.getPresetConfig!=="function"||typeof shaderPass.setParameter!=="function"){console.error(`${passName} 缺少 getPresetConfig 或 setParameter 方法,无法创建动画`);return}const noneConfig=shaderPass.getPresetConfig("none");const lowConfig=shaderPass.getPresetConfig("low");if(!noneConfig||!lowConfig){console.error(`${passName} 缺少 none 或 low 预设配置`);return}const initialState=cloneConfig(noneConfig);const releaseState=cloneConfig(lowConfig);applyConfig(initialState,shaderPass);const tweenIn=new TWEEN.Tween(initialState).to(cloneConfig(lowConfig),(.4-.35)*duration).delay(.35*duration).easing(TWEEN.Easing.Sinusoidal.InOut).onUpdate(obj=>applyConfig(obj,shaderPass));const tweenOut=new TWEEN.Tween(releaseState).to(cloneConfig(noneConfig),(.65-.6)*duration).delay(.6*duration).easing(TWEEN.Easing.Sinusoidal.InOut).onUpdate(obj=>applyConfig(obj,shaderPass));tweens.push(tweenIn,tweenOut)}else if(passName==="CCForceMotionBlurShaderPass"){if(typeof shaderPass.getPresetConfig!=="function"||typeof shaderPass.setParameter!=="function"){console.error(`${passName} 缺少 getPresetConfig 或 setParameter 方法,无法创建动画`);return}const noneConfig=shaderPass.getPresetConfig("none");const lowConfig=shaderPass.getPresetConfig("low");if(!noneConfig||!lowConfig){console.error(`${passName} 缺少 none 或 low 预设配置`);return}const initialState=cloneConfig(noneConfig);const releaseState=cloneConfig(lowConfig);applyConfig(initialState,shaderPass);const tweenIn=new TWEEN.Tween(initialState).to(cloneConfig(lowConfig),(.55-.45)*duration).delay(.45*duration).easing(TWEEN.Easing.Sinusoidal.InOut).onUpdate(obj=>applyConfig(obj,shaderPass));const tweenOut=new TWEEN.Tween(releaseState).to(cloneConfig(noneConfig),(1.15-1.05)*duration).delay(1.05*duration).easing(TWEEN.Easing.Sinusoidal.InOut).onUpdate(obj=>applyConfig(obj,shaderPass));tweens.push(tweenIn,tweenOut)}else if(passName==="GaussianBlurShaderPass"){if(typeof shaderPass.getPresetConfig!=="function"||typeof shaderPass.setParameter!=="function"){console.error(`${passName} 缺少 getPresetConfig 或 setParameter 方法,无法创建动画`);return}const noneConfig=shaderPass.getPresetConfig("none");const lowConfig=shaderPass.getPresetConfig("low");if(!noneConfig||!lowConfig){console.error(`${passName} 缺少 none 或 low 预设配置`);return}const initialState=cloneConfig(noneConfig);const releaseState=cloneConfig(lowConfig);applyConfig(initialState,shaderPass);const tweenIn=new TWEEN.Tween(initialState).to(cloneConfig(lowConfig),(1.35-1.25)*duration).delay(1.25*duration).easing(TWEEN.Easing.Cubic.Out).onUpdate(obj=>applyConfig(obj,shaderPass));const tweenOut=new TWEEN.Tween(releaseState).to(cloneConfig(noneConfig),(1.55-1.45)*duration).delay(1.45*duration).easing(TWEEN.Easing.Quartic.Out).onUpdate(obj=>applyConfig(obj,shaderPass));tweens.push(tweenIn,tweenOut)}});tweens.forEach(tween=>tween.start());return tweens}initPostProcessing(){if(!this.usePostProcessing)return;const shaderPassConfigs=[{name:"LumiWaveWarp"},{name:"LumiCCForceMotionBlur"},{name:"LumiGaussianBlur"}];this.setupPostProcessing(shaderPassConfigs);const tweens=this.addAnimations();if(tweens.length>0){if(!this.sceneObjects.tweens){this.sceneObjects.tweens=[]}this.sceneObjects.tweens.push(...tweens)}}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()}setupScene(){this.initSceneObjects();this.createWaveTiles();this.setupAnimations();return this.sceneObjects}initSceneObjects(){this.Duration=2e3;this.camera.position.set(0,0,10);this.camera.lookAt(0,0,0);this.sceneObjects={waveTilesGroup:null,columns:[],columnMaterials:[],tileMaterials:[],tweens:[]}}createWaveTiles(){const totalSize=10;const rows=12;const columns=12;const tileSize=totalSize/columns;const waveTilesGroup=new THREE.Group;waveTilesGroup.name="waveTilesGroup";this.scene.add(waveTilesGroup);const sharedGeometry=new THREE.PlaneGeometry(tileSize,tileSize);for(let c=0;c{tileMaterials.forEach(material=>{material.uniforms.u_panelExtrusion.value=obj.value})}).start();tweens.push(panelExtrusionTween);const panelFlattenState={value:1};const panelFlattenTween=new TWEEN.Tween(panelFlattenState).to({value:0},200).delay(1650).easing(TWEEN.Easing.Quartic.Out).onUpdate(obj=>{tileMaterials.forEach(material=>{material.uniforms.u_panelExtrusion.value=obj.value})}).start();tweens.push(panelFlattenTween);const settleUniformState={value:0};const settleUniformTween=new TWEEN.Tween(settleUniformState).to({value:1},400).delay(1250).easing(TWEEN.Easing.Cubic.Out).onUpdate(obj=>{tileMaterials.forEach(material=>{material.uniforms.u_settle.value=obj.value})}).start();tweens.push(settleUniformTween);const reconstructState={value:0};const reconstructTween=new TWEEN.Tween(reconstructState).to({value:1},200).delay(1650).easing(TWEEN.Easing.Quartic.Out).onUpdate(obj=>{tileMaterials.forEach(material=>{material.uniforms.u_reconstruct.value=obj.value})}).start();tweens.push(reconstructTween);const waveStart=350;const waveDurationPerColumn=680;const flipStart=550;const flipDurationPerColumn=580;const columnDelay=20;const settleStart=1250;const settleDuration=400;const peakAngle=THREE.MathUtils.degToRad(85);const endAngle=THREE.MathUtils.degToRad(-15);const xAxis=new THREE.Vector3(1,0,0);const tempQuaternion=new THREE.Quaternion;for(let colIndex=0;colIndex{const progress=obj.progress;let angle;if(progress<=.5){const t=progress/.5;angle=THREE.MathUtils.lerp(0,peakAngle,t)}else{const t=(progress-.5)/.5;angle=THREE.MathUtils.lerp(peakAngle,endAngle,t)}tempQuaternion.setFromAxisAngle(xAxis,angle);columnGroup.quaternion.copy(tempQuaternion);materials.forEach(material=>{material.uniforms.u_wavePhase.value=progress})}).start();tweens.push(waveTween);const flipState={value:0};const flipTween=new TWEEN.Tween(flipState).to({value:1},flipDurationPerColumn).delay(flipStart+colIndex*columnDelay).easing(TWEEN.Easing.Sinusoidal.InOut).onUpdate(obj=>{materials.forEach(material=>{material.uniforms.u_flipProgress.value=obj.value})}).start();tweens.push(flipTween);const settleRotationState={angle:endAngle};const settleRotationTween=new TWEEN.Tween(settleRotationState).to({angle:0},settleDuration).delay(settleStart).easing(TWEEN.Easing.Cubic.Out).onUpdate(obj=>{tempQuaternion.setFromAxisAngle(xAxis,obj.angle);columnGroup.quaternion.copy(tempQuaternion)}).start();tweens.push(settleRotationTween)}return 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; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/three-amg-wrapper.js b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/three-amg-wrapper.js new file mode 100644 index 0000000000000000000000000000000000000000..c2037e314e032c4d36912923d4cc1258cba3ab19 --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/three-amg-wrapper.js @@ -0,0 +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;iobj.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; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/tween.js b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/tween.js new file mode 100644 index 0000000000000000000000000000000000000000..690fb9e4284728629129deed5a5a3f4bcec291ed --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/tween.js @@ -0,0 +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=power1e4?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;_i0){this._tweensAddedDuringUpdate={};for(var i=0;i1){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[m1;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;itotalTime){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;ithis.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;ithis.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.xthis.max.x||box.max.ythis.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; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Box3.js b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Box3.js new file mode 100644 index 0000000000000000000000000000000000000000..4100dc7442d3a622827c8a415e24557f68c491f1 --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Box3.js @@ -0,0 +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=3?array[offset+2]:0;if(xthis.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=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.xthis.max.x||box.max.ythis.max.y||box.max.zthis.max.z)}}exports.Box3=Box3; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..be3b8b1334a62f5e88c45feee098063a199fca55 --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js @@ -0,0 +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=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; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..af9a8a13a46500e78f082a35e18d0b5932061234 --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js @@ -0,0 +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;iObject.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;i1?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; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Constants.js b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Constants.js new file mode 100644 index 0000000000000000000000000000000000000000..6b8adda19a4d67236719804f5170889b39fd4582 --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Constants.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js new file mode 100644 index 0000000000000000000000000000000000000000..29b0aad5599401be17f967ba1d48851acb70c2ac --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js @@ -0,0 +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;i0||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;i0?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;imaxX)maxX=p.x;if(p.ymaxY)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; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..f3dee08bf1c089e040fcfef228902ab9a39c93cb --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Earcut.js b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Earcut.js new file mode 100644 index 0000000000000000000000000000000000000000..953abffdf38c2def26df73fed180eff8c7644ced --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Earcut.js @@ -0,0 +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;imaxX)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=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=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.x&&p.x>=mx&&hx!==p.x&&pointInTriangle(hym.x||p.x===m.x&§orContainsSector(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.xb.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;i0||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=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;i0){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;imaxX)maxX=contour[i].x;if(contour[i].ymaxY)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;layerIdx0?-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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Group.js b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Group.js new file mode 100644 index 0000000000000000000000000000000000000000..90c4dbef65aa04d7a3bb6b6d76ec3317ea65a228 --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Group.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");class Group extends Object3D{constructor(name="Group_w"){super(name)}dispose(){super.dispose()}}exports.Group=Group; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Material.js b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Material.js new file mode 100644 index 0000000000000000000000000000000000000000..81b97053ad9d1e4b1ef05d5ac6ed992487b2ca8e --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Material.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..dcf34d4cffb9de0869382a24690f78f60dda6049 --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js new file mode 100644 index 0000000000000000000000000000000000000000..41e6cd0a0eee7dd7bc497be5deac584806b68dc3 --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Mesh.js b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Mesh.js new file mode 100644 index 0000000000000000000000000000000000000000..254d69b074e797dd34c16d7dad723bbcc3b4895d --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Mesh.js @@ -0,0 +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;imaterial,set:value=>{material=value;if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;im.dispose&&m.dispose());else if(this.material.dispose)this.material.dispose()}}}exports.MeshWrapper=MeshWrapper; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..ac394f66efc4e113a7127ee0f50ec672e4c5e9eb --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Object3D.js b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Object3D.js new file mode 100644 index 0000000000000000000000000000000000000000..8532c6122f839460aab34fe88957802ff523318b --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Object3D.js @@ -0,0 +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{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&¤tScene._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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js new file mode 100644 index 0000000000000000000000000000000000000000..ba39801de50d38ec04424f3c2ebfa2ff5d28fded --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js @@ -0,0 +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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..bc595fb80ad9e7c2f4d8360c67dbef556f3d6cbe --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js @@ -0,0 +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;iy0){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; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..02dc1be955bc766de744222a7e75c65bf147bb61 --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js @@ -0,0 +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&¶meters.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{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=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=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=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; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Shape.js b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Shape.js new file mode 100644 index 0000000000000000000000000000000000000000..ecde48b5ceb30812c922aa5c7cfe2aa7b50cabe4 --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Shape.js @@ -0,0 +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;i0){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;i0||(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;imaxX)maxX=p.x;if(p.ymaxY)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;i0?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;ipoints.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;itwoPi)deltaAngle-=twoPi;if(deltaAngle>4;uuid[i]=chars[i===19?r&3|8:r]}}return uuid.join("")}exports.Shape=Shape; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..3786abc7d64ed80b56101c4ac9d30ce9fcb8f941 --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js @@ -0,0 +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;i0){const bounds=calculateBounds(flatVertices);const vertexOffset=vertices.length/3;for(let j=0;j0){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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}function calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..1ea27a55fbce9fc3771c66840c068e5ff6347092 --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Texture.js b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Texture.js new file mode 100644 index 0000000000000000000000000000000000000000..35bff49d732c9884e07bfcb5682f18a860485e1f --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Texture.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Vector2.js b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Vector2.js new file mode 100644 index 0000000000000000000000000000000000000000..a30a2431264ee62cec937714dfa9e50932ddedeb --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/ThreeJS/wrapper/Vector2.js @@ -0,0 +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)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)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)=.01&&(blurDirectionMode===0||blurDirectionMode===1);const isPassVEnabled=this.params.intensity>=.01&&(blurDirectionMode===0||blurDirectionMode===2);const safeRT=this.internalRTs.midRT||null;const canDoTwoPass=!!safeRT;if(isPassHEnabled&&isPassVEnabled&&canDoTwoPass){if(this.passH)this.passH.cameraEntity.getComponent("Camera").renderTexture=safeRT;if(this.passV){this.passV._amgMaterialObject.setTex("u_inputTexture",safeRT);this.passV.cameraEntity.getComponent("Camera").renderTexture=texture;this.passV.cameraEntity.visible=true}if(this.passH)this.passH.cameraEntity.visible=true}else if(isPassHEnabled&&isPassVEnabled){if(this.passH){this.passH.cameraEntity.getComponent("Camera").renderTexture=texture;this.passH.cameraEntity.visible=true}if(this.passV){this.passV.cameraEntity.visible=false}}else if(isPassHEnabled){if(this.passH)this.passH.cameraEntity.getComponent("Camera").renderTexture=texture;if(this.passV){this.passV.cameraEntity.visible=false}}else if(isPassVEnabled){if(this.passV)this.passV.cameraEntity.getComponent("Camera").renderTexture=texture;if(this.passH){this.passH.cameraEntity.visible=false}}else{if(this.passH){this.passH._amgMaterialObject.setTex("u_inputTexture",this.inputTexture);this.passH.cameraEntity.getComponent("Camera").renderTexture=texture;this.passH.cameraEntity.visible=true}if(this.passV){this.passV.cameraEntity.visible=false}}}_syncUniforms(pass){if(!this._isAmaz)return;if(!pass||!pass.material||typeof pass.material._syncUniformToAMG!=="function")return;const uniforms=pass.material.uniforms;if(!uniforms)return;for(const key in uniforms){pass.material._syncUniformToAMG(key,uniforms[key])}}setParameter(name,value){if(!this.params.hasOwnProperty(name))return;if(typeof value==="number"&&!Number.isFinite(value))return;if(name==="blurDirection"){const normalized=this._normalizeBlurDirection(value);if(normalized==null)return;this.params.blurDirection=normalized}else if(name==="borderType"){const normalized=this._normalizeBorderType(value);if(normalized==null)return;this.params.borderType=normalized}else if(name==="blurAlpha"||name==="inverseGammaCorrection"){const normalized=this._normalizeBool(value);if(normalized==null)return;this.params[name]=normalized}else{this.params[name]=value}this.updateParameters();if((name==="intensity"||name==="blurDirection")&&this._isAmaz&&this.outputTexture){this.setOutputTexture(this.outputTexture)}}_clampValue(value,min=0,max=1){return Math.max(min,Math.min(max,value))}_getSampleNum(intensity){let scale=1;let bias=0;let s=1;if(intensity<=30){scale=.5;bias=2;s=.78}else if(intensity<=100){scale=.5;bias=10;s=.66}else if(intensity<=200){scale=.25;bias=50;s=.7}else{scale=.125;bias=80;s=.8}let sampleNum=scale*intensity+bias;sampleNum=sampleNum*s;if(sampleNum<2){sampleNum=Math.floor(sampleNum+.5)}return{sampleNum:sampleNum,downScale:scale}}_getQualityParam(quality){let qualityParam=quality*2-1;if(qualityParam<0){qualityParam=Math.pow(10,qualityParam)}else{qualityParam=qualityParam*2+1}return qualityParam}_getXYScale(width,height){const size1=Math.min(width,height);const size2=Math.max(width,height)/2;const baseSize=Math.max(size1,size2);return[baseSize/width,baseSize/height]}_normalizeBool(value){if(typeof value==="boolean")return value;if(typeof value==="number")return value>=.5;return null}_normalizeBlurDirection(value){const options=["Horizontal and Vertical","Horizontal","Vertical"];if(typeof value==="string"){if(options.includes(value))return value;return null}if(typeof value==="number"){if(!Number.isFinite(value))return null;const idx=Math.max(0,Math.min(2,Math.round(value)));return options[idx]}return null}_normalizeBorderType(value){const options=["Normal","Replicate","Black","Mirror"];if(typeof value==="string"){if(options.includes(value))return value;return null}if(typeof value==="number"){if(!Number.isFinite(value))return null;const idx=Math.max(0,Math.min(3,Math.round(value)));return options[idx]}return null}_getBorderTypeCode(borderType){const table={Normal:0,Replicate:1,Black:2,Mirror:3};if(typeof borderType==="number"){return Math.max(0,Math.min(3,Math.round(borderType)))}return table[borderType]??0}_getBlurDirectionMode(blurDirection){const table={"Horizontal and Vertical":0,Horizontal:1,Vertical:2};if(typeof blurDirection==="number"){return Math.max(0,Math.min(2,Math.round(blurDirection)))}return table[blurDirection]??0}_boolToInt(flag){return flag?1:0}updateParameters(){const blurIntensity=this._clampValue(this.params.intensity,0,this.constants.MaxIntensity);const horizontalStrength=this._clampValue(this.params.horizontalStrength);const verticalStrength=this._clampValue(this.params.verticalStrength);const quality=this._clampValue(this.params.quality);const spaceDither=this._clampValue(this.params.spaceDither);const{sampleNum,downScale}=this._getSampleNum(blurIntensity);const qualityParam=this._getQualityParam(quality);const borderType=this._getBorderTypeCode(this.params.borderType);const inverseGammaCorrection=this._boolToInt(this.params.inverseGammaCorrection);const blurAlpha=this._boolToInt(this.params.blurAlpha);let xStrength=horizontalStrength;let yStrength=verticalStrength;const blurDirection=this._getBlurDirectionMode(this.params.blurDirection);if(blurDirection===1){yStrength=0}else if(blurDirection===2){xStrength=0}const intensityX=blurIntensity*xStrength;const intensityY=blurIntensity*yStrength;const[xScale,yScale]=this._getXYScale(this.width,this.height);const radiusX=xScale*intensityX/this.constants.NormalizationSize;const radiusY=yScale*intensityY/this.constants.NormalizationSize;const sigmaX=radiusX/this.constants.RadiusOverSigma;const sigmaY=radiusY/this.constants.RadiusOverSigma;const sampleX=sampleNum*xStrength*qualityParam;const sampleY=sampleNum*yStrength*qualityParam;const dx=radiusX/Math.max(sampleX,this.constants.Eps);const dy=radiusY/Math.max(sampleY,this.constants.Eps);const screenParams=new THREE.Vector4(this.width,this.height,1/Math.max(this.width,1),1/Math.max(this.height,1));if(this.passH&&this.passH.material){const uniforms=this.passH.material.uniforms;if(uniforms.u_ScreenParams)uniforms.u_ScreenParams.value=screenParams;uniforms.u_stepX.value=dx;uniforms.u_stepY.value=dy;uniforms.u_sampleX.value=sampleX;uniforms.u_sigmaX.value=sigmaX;uniforms.u_gamma.value=this.constants.Gamma;uniforms.u_spaceDither.value=spaceDither;uniforms.u_borderType.value=borderType;uniforms.u_inverseGammaCorrection.value=inverseGammaCorrection;uniforms.u_blurAlpha.value=blurAlpha;this._syncUniforms(this.passH)}if(this.passV&&this.passV.material){const uniforms=this.passV.material.uniforms;if(uniforms.u_ScreenParams)uniforms.u_ScreenParams.value=screenParams;uniforms.u_stepX.value=dx;uniforms.u_stepY.value=dy;uniforms.u_sampleY.value=sampleY;uniforms.u_sigmaY.value=sigmaY;uniforms.u_gamma.value=this.constants.Gamma;uniforms.u_spaceDither.value=spaceDither;uniforms.u_borderType.value=borderType;uniforms.u_inverseGammaCorrection.value=inverseGammaCorrection;uniforms.u_blurAlpha.value=blurAlpha;this._syncUniforms(this.passV)}}setSize(width,height){if(this.width!==width||this.height!==height){this.width=width;this.height=height;this.updateParameters()}}dispose(){if(this._isAmaz&&this.scene){for(let i=0;i=.01&&(blurDirection===0||blurDirection===1);const isPassVEnabled=this.params.intensity>=.01&&(blurDirection===0||blurDirection===2);if(!isPassHEnabled&&!isPassVEnabled){if(!this.copyShader){this.copyShader=new THREE.ShaderMaterial({uniforms:{tDiffuse:{value:null}},vertexShader:` + varying vec2 vUv; + void main() { + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); + } + `,fragmentShader:` + uniform sampler2D tDiffuse; + varying vec2 vUv; + void main() { + gl_FragColor = texture2D(tDiffuse, vUv); + } + `})}if(!this.fullScreenQuad){const geometry=new THREE.BufferGeometry;const vertices=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]);const uvs=new Float32Array([0,0,2,0,0,2]);geometry.setAttribute("position",new THREE.BufferAttribute(vertices,3));geometry.setAttribute("uv",new THREE.BufferAttribute(uvs,2));this.fullScreenQuad=new THREE.Mesh(geometry,this.copyShader)}this.copyShader.uniforms.tDiffuse.value=readBuffer.texture;const currentRenderTarget=renderer.getRenderTarget();renderer.autoClear=false;renderer.setRenderTarget(this.renderToScreen?null:writeBuffer);renderer.clear();const scene=new THREE.Scene;scene.add(this.fullScreenQuad);const camera=new THREE.OrthographicCamera(-1,1,1,-1,0,1);renderer.render(scene,camera);renderer.setRenderTarget(currentRenderTarget);renderer.autoClear=oldAutoClear;return}if(isPassHEnabled){if(this.passH.material&&this.passH.material.uniforms.tDiffuse){this.passH.material.uniforms.tDiffuse.value=readBuffer.texture}if(blurDirection===0){const currentRenderTarget=renderer.getRenderTarget();renderer.setRenderTarget(this.midRenderTarget);renderer.clear();this.passH.render(renderer,this.midRenderTarget,readBuffer,delta,maskActive);renderer.setRenderTarget(currentRenderTarget)}else if(blurDirection===1&&this.renderToScreen){this.passH.render(renderer,null,readBuffer,delta,maskActive)}else if(blurDirection===1&&!this.renderToScreen){this.passH.render(renderer,writeBuffer,readBuffer,delta,maskActive)}}if(isPassVEnabled){if(blurDirection===0){if(this.passV.material&&this.passV.material.uniforms.tDiffuse){this.passV.material.uniforms.tDiffuse.value=this.midRenderTarget.texture}if(this.renderToScreen){this.passV.render(renderer,null,this.midRenderTarget,delta,maskActive)}else{this.passV.render(renderer,writeBuffer,this.midRenderTarget,delta,maskActive)}}else if(blurDirection===2){if(this.passV.material&&this.passV.material.uniforms.tDiffuse){this.passV.material.uniforms.tDiffuse.value=readBuffer.texture}if(this.renderToScreen){this.passV.render(renderer,null,readBuffer,delta,maskActive)}else{this.passV.render(renderer,writeBuffer,readBuffer,delta,maskActive)}}}renderer.autoClear=oldAutoClear}}exports.GaussianBlurMultiPass=GaussianBlurMultiPass; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/pp/LumiGaussianBlur/GaussianBlurShaderPass.js b/scripts/7681469687644884242/AmazingFeature/js/pp/LumiGaussianBlur/GaussianBlurShaderPass.js new file mode 100644 index 0000000000000000000000000000000000000000..4ea2ca5ea727243c2e1c2162b51560dcacf4384d --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/pp/LumiGaussianBlur/GaussianBlurShaderPass.js @@ -0,0 +1 @@ +const THREE=require("../../ThreeJS/three-amg-wrapper.js").THREE;const{ShaderPass}=require("../../ThreeJS/ShaderPass.js");const{GaussianBlurMultiPass}=require("./GaussianBlurMultiPass.js");GaussianBlurMultiPass.setRuntime({THREE:THREE,ShaderPass:ShaderPass});class GaussianBlurShaderPass extends GaussianBlurMultiPass{constructor(config={}){super(config);this.presets={none:{intensity:0,horizontalStrength:0,verticalStrength:0,blurDirection:"Horizontal and Vertical"},soft:{intensity:18,horizontalStrength:1,verticalStrength:1,quality:.55,spaceDither:0,borderType:"Normal",blurAlpha:true,inverseGammaCorrection:true,blurDirection:"Horizontal and Vertical"},low:{intensity:20,horizontalStrength:1,verticalStrength:1,blurDirection:"Horizontal and Vertical"},medium:{intensity:60,horizontalStrength:1,verticalStrength:1,blurDirection:"Horizontal and Vertical"},high:{intensity:140,horizontalStrength:1,verticalStrength:1,blurDirection:"Horizontal and Vertical"},strong:{intensity:220,horizontalStrength:1,verticalStrength:1,quality:.8,spaceDither:.05,borderType:"Mirror",blurAlpha:true,inverseGammaCorrection:true,blurDirection:"Horizontal and Vertical"},horizontal:{intensity:80,horizontalStrength:1,verticalStrength:0,blurDirection:"Horizontal"},vertical:{intensity:80,horizontalStrength:0,verticalStrength:1,blurDirection:"Vertical"},horizontal_streak:{intensity:160,horizontalStrength:1,verticalStrength:0,quality:.7,spaceDither:.08,borderType:"Mirror",blurAlpha:false,inverseGammaCorrection:true,blurDirection:"Horizontal"},vertical_streak:{intensity:160,horizontalStrength:0,verticalStrength:1,quality:.7,spaceDither:.08,borderType:"Mirror",blurAlpha:false,inverseGammaCorrection:true,blurDirection:"Vertical"},mirror_edges:{intensity:60,horizontalStrength:1,verticalStrength:1,quality:.6,spaceDither:.05,borderType:"Mirror",blurAlpha:true,inverseGammaCorrection:true,blurDirection:"Horizontal and Vertical"},fast_preview:{intensity:80,horizontalStrength:1,verticalStrength:1,quality:.25,spaceDither:0,borderType:"Normal",blurAlpha:true,inverseGammaCorrection:true,blurDirection:"Horizontal and Vertical"}};const presetName=config&&(config.preset||config.presetName||config.preset_name)||null;if(typeof presetName==="string"&&presetName){this.applyPreset(presetName)}}_clampValue(value,min=0,max=1){return Math.max(min,Math.min(max,value))}_normalizeParameterKey(key){if(typeof key!=="string")return"";const trimmed=key.trim();if(!trimmed)return"";return trimmed.replace(/[_-]+([a-zA-Z0-9])/g,(_,c)=>c.toUpperCase())}setParameter(key,value){let normalizedKey=this._normalizeParameterKey(key);if(!normalizedKey){console.warn(`Invalid parameter key: ${key}`);return}const methodName="set"+normalizedKey.charAt(0).toUpperCase()+normalizedKey.slice(1);if(typeof this[methodName]==="function"){this[methodName](value);return}super.setParameter(normalizedKey,value)}setPreset(name){this.applyPreset(name)}getPresetNames(){return Object.keys(this.presets)}getPresetConfig(name){const preset=this.presets[name];if(!preset)return null;return{...preset}}applyPreset(name){const cfg=this.getPresetConfig(name);if(!cfg)return;Object.keys(cfg).forEach(key=>{this.setParameter(key,cfg[key])})}}exports.GaussianBlurShaderPass=GaussianBlurShaderPass; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/pp/LumiGaussianBlur/atomic.json b/scripts/7681469687644884242/AmazingFeature/js/pp/LumiGaussianBlur/atomic.json new file mode 100644 index 0000000000000000000000000000000000000000..599f9f3a786e6d21375f9126f1c9cb62c927de28 --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/pp/LumiGaussianBlur/atomic.json @@ -0,0 +1,132 @@ +{ + "key": "LumiGaussianBlur", + "category": "Blur & Sharpen", + "desc": "高斯模糊(多 Pass)- 可控的水平/垂直高斯模糊,支持强度、质量、边界处理、抖动与 Alpha 模糊设置。适用于柔化、景深辅助、过渡遮罩、轻度磨皮与氛围处理。", + "preset": [ + { + "name": "none", + "desc": "无效果 - 强度为0,关闭模糊" + }, + { + "name": "soft", + "desc": "轻柔 - 低强度模糊,细微柔化" + }, + { + "name": "medium", + "desc": "中等 - 通用模糊强度,明显但不糊" + }, + { + "name": "strong", + "desc": "强烈 - 大幅模糊,适合背景虚化/过渡" + }, + { + "name": "horizontal_streak", + "desc": "水平拉丝 - 仅水平模糊,常用于光晕/速度感" + }, + { + "name": "vertical_streak", + "desc": "垂直拉丝 - 仅垂直模糊,常用于雨丝/光束感" + }, + { + "name": "mirror_edges", + "desc": "镜像边界 - 使用 Mirror 边界减少边缘黑边" + }, + { + "name": "fast_preview", + "desc": "快速预览 - 牺牲质量换性能(更粗糙)" + }, + { + "name": "low", + "desc": "Light-touch preset with a subtle version of the effect." + }, + { + "name": "high", + "desc": "Stronger preset that pushes the effect more aggressively." + }, + { + "name": "horizontal", + "desc": "Biases the effect toward horizontal motion, blur, or splitting." + }, + { + "name": "vertical", + "desc": "Biases the effect toward vertical motion or blur." + } + ], + "subProperties": [ + { + "name": "intensity", + "desc": "强度 - 模糊半径/范围(越大越糊)", + "type": "number", + "value": 20, + "min": 0, + "max": 300 + }, + { + "name": "quality", + "desc": "质量 - 影响采样数量与模糊平滑度(更高更慢)", + "type": "number", + "value": 0.5, + "min": 0, + "max": 1 + }, + { + "name": "horizontalStrength", + "desc": "水平权重 - 0 关闭水平模糊,1 为全强度", + "type": "number", + "value": 1, + "min": 0, + "max": 1 + }, + { + "name": "verticalStrength", + "desc": "垂直权重 - 0 关闭垂直模糊,1 为全强度", + "type": "number", + "value": 1, + "min": 0, + "max": 1 + }, + { + "name": "blurDirection", + "desc": "模糊方向 - Horizontal/Vertical/Horizontal and Vertical", + "type": "select", + "value": "Horizontal and Vertical", + "options": [ + "Horizontal and Vertical", + "Horizontal", + "Vertical" + ] + }, + { + "name": "borderType", + "desc": "边界处理 - Normal/Replicate/Black/Mirror", + "type": "select", + "value": "Normal", + "options": [ + "Normal", + "Replicate", + "Black", + "Mirror" + ] + }, + { + "name": "spaceDither", + "desc": "空间抖动 - 轻微抖动可减少条带/采样痕迹", + "type": "number", + "value": 0, + "min": 0, + "max": 1 + }, + { + "name": "blurAlpha", + "desc": "模糊 Alpha - 开启后对 Alpha 通道也进行模糊", + "type": "boolean", + "value": true + }, + { + "name": "inverseGammaCorrection", + "desc": "反伽马校正 - 提升模糊的视觉一致性(通常建议开启)", + "type": "boolean", + "value": true + } + ] +} diff --git a/scripts/7681469687644884242/AmazingFeature/js/pp/LumiGaussianBlur/shaders/commonVert.js b/scripts/7681469687644884242/AmazingFeature/js/pp/LumiGaussianBlur/shaders/commonVert.js new file mode 100644 index 0000000000000000000000000000000000000000..5b9830df131a541e5882a145200239e0b821f8b2 --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/pp/LumiGaussianBlur/shaders/commonVert.js @@ -0,0 +1,6 @@ +exports.source=` +varying vec2 v_uv; +void main() { + v_uv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); +}`; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/pp/LumiGaussianBlur/shaders/gaussianBlurXFrag.js b/scripts/7681469687644884242/AmazingFeature/js/pp/LumiGaussianBlur/shaders/gaussianBlurXFrag.js new file mode 100644 index 0000000000000000000000000000000000000000..b00cbfff6e685788afd2d4724b33d509a16be4f5 --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/pp/LumiGaussianBlur/shaders/gaussianBlurXFrag.js @@ -0,0 +1,161 @@ +exports.source=` +precision highp float; +precision highp int; + +uniform vec4 u_ScreenParams; +uniform mediump int u_inverseGammaCorrection; +uniform float u_gamma; +uniform float u_sampleX; +uniform mediump sampler2D u_inputTexture; +uniform float u_sigmaX; +uniform float u_spaceDither; +uniform float u_stepX; +uniform float u_stepY; +uniform mediump int u_borderType; +uniform mediump int u_blurAlpha; + +varying vec2 v_uv; + +vec4 _f2(mediump sampler2D _p0, vec2 _p1) +{ + vec4 _t3 = texture2D(_p0, _p1); + if (u_inverseGammaCorrection == 1) + { + vec4 _105 = _t3; + vec3 _111 = pow(_105.xyz, vec3(u_gamma)); + _t3.x = _111.x; + _t3.y = _111.y; + _t3.z = _111.z; + } + return _t3; +} + +float _f1(float _p0, float _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +float _f0(vec2 _p0) +{ + vec3 _46 = fract(vec3((_p0 * u_ScreenParams.xy).xyx) * 0.103100001811981201171875); + vec3 _t1 = _46 + vec3(dot(_46, _46.yzx + vec3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +void main() +{ + if (u_sampleX < 9.9999997473787516355514526367188e-06) + { + gl_FragColor = texture2D(u_inputTexture, v_uv); + return; + } + vec2 param = v_uv; + vec4 _139 = _f2(u_inputTexture, param); + vec4 _t4 = _139; + float param_1 = 0.0; + float param_2 = u_sigmaX; + float _146 = _f1(param_1, param_2); + float _t5 = _146; + vec4 _t6 = _139 * _146; + vec2 _t7 = v_uv; + if (u_spaceDither > 9.9999997473787516355514526367188e-06) + { + vec2 param_3 = v_uv; + _t7 += (vec2(u_stepX, u_stepY) * (u_spaceDither * _f0(param_3))); + } + vec2 _t9 = _t7; + for (mediump int _t10 = 1; _t10 <= 1024; _t10++) + { + mediump float _187 = float(_t10); + if (_187 > u_sampleX) + { + break; + } + float _197 = _187 * u_stepX; + float param_4 = _197; + float param_5 = u_sigmaX; + float _203 = _f1(param_4, param_5); + _t9.x = _t7.x - _197; + if (_t9.x < 0.0) + { + if (u_borderType == 1) + { + _t9.x = 0.0; + vec2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, param_6) * _203); + _t5 += _203; + } + else + { + if (u_borderType == 2) + { + _t5 += _203; + } + else + { + if (u_borderType == 3) + { + _t9.x = -_t9.x; + vec2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, param_7) * _203); + _t5 += _203; + } + } + } + } + else + { + vec2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, param_8) * _203); + _t5 += _203; + } + _t9.x = _t7.x + _197; + if (_t9.x > 1.0) + { + if (u_borderType == 1) + { + _t9.x = 1.0; + vec2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, param_9) * _203); + _t5 += _203; + } + else + { + if (u_borderType == 2) + { + _t5 += _203; + } + else + { + if (u_borderType == 3) + { + _t9.x = 2.0 - _t9.x; + vec2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, param_10) * _203); + _t5 += _203; + } + } + } + } + else + { + vec2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, param_11) * _203); + _t5 += _203; + } + } + _t6 /= vec4(_t5); + if (u_inverseGammaCorrection == 1) + { + vec4 _343 = _t6; + vec3 _348 = pow(_343.xyz, vec3(1.0 / max(u_gamma, 1e-3))); + _t6.x = _348.x; + _t6.y = _348.y; + _t6.z = _348.z; + } + if (u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + gl_FragColor = _t6; +}`; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/pp/LumiGaussianBlur/shaders/gaussianBlurYFrag.js b/scripts/7681469687644884242/AmazingFeature/js/pp/LumiGaussianBlur/shaders/gaussianBlurYFrag.js new file mode 100644 index 0000000000000000000000000000000000000000..7683e46838e73000bdea016086f1d9fe2711aa90 --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/pp/LumiGaussianBlur/shaders/gaussianBlurYFrag.js @@ -0,0 +1,161 @@ +exports.source=` +precision highp float; +precision highp int; + +uniform vec4 u_ScreenParams; +uniform mediump int u_inverseGammaCorrection; +uniform float u_gamma; +uniform float u_sampleY; +uniform mediump sampler2D u_inputTexture; +uniform float u_sigmaY; +uniform float u_spaceDither; +uniform float u_stepX; +uniform float u_stepY; +uniform mediump int u_borderType; +uniform mediump int u_blurAlpha; + +varying vec2 v_uv; + +vec4 _f2(mediump sampler2D _p0, vec2 _p1) +{ + vec4 _t3 = texture2D(_p0, _p1); + if (u_inverseGammaCorrection == 1) + { + vec4 _108 = _t3; + vec3 _114 = pow(_108.xyz, vec3(u_gamma)); + _t3.x = _114.x; + _t3.y = _114.y; + _t3.z = _114.z; + } + return _t3; +} + +float _f1(float _p0, float _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +float _f0(vec2 _p0) +{ + vec3 _49 = fract(vec3(((_p0 * u_ScreenParams.xy) + vec2(0.33329999446868896484375)).xyx) * 0.103100001811981201171875); + vec3 _t1 = _49 + vec3(dot(_49, _49.yzx + vec3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +void main() +{ + if (u_sampleY < 9.9999997473787516355514526367188e-06) + { + gl_FragColor = texture2D(u_inputTexture, v_uv); + return; + } + vec2 param = v_uv; + vec4 _142 = _f2(u_inputTexture, param); + vec4 _t4 = _142; + float param_1 = 0.0; + float param_2 = u_sigmaY; + float _149 = _f1(param_1, param_2); + float _t5 = _149; + vec4 _t6 = _142 * _149; + vec2 _t7 = v_uv; + if (u_spaceDither > 9.9999997473787516355514526367188e-06) + { + vec2 param_3 = v_uv; + _t7 += (vec2(u_stepX, u_stepY) * (u_spaceDither * _f0(param_3))); + } + vec2 _t9 = _t7; + for (mediump int _t10 = 1; _t10 <= 1024; _t10++) + { + mediump float _190 = float(_t10); + if (_190 > u_sampleY) + { + break; + } + float _200 = _190 * u_stepY; + float param_4 = _200; + float param_5 = u_sigmaY; + float _206 = _f1(param_4, param_5); + _t9.y = _t7.y - _200; + if (_t9.y < 0.0) + { + if (u_borderType == 1) + { + _t9.y = 0.0; + vec2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, param_6) * _206); + _t5 += _206; + } + else + { + if (u_borderType == 2) + { + _t5 += _206; + } + else + { + if (u_borderType == 3) + { + _t9.y = -_t9.y; + vec2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, param_7) * _206); + _t5 += _206; + } + } + } + } + else + { + vec2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, param_8) * _206); + _t5 += _206; + } + _t9.y = _t7.y + _200; + if (_t9.y > 1.0) + { + if (u_borderType == 1) + { + _t9.y = 1.0; + vec2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, param_9) * _206); + _t5 += _206; + } + else + { + if (u_borderType == 2) + { + _t5 += _206; + } + else + { + if (u_borderType == 3) + { + _t9.y = 2.0 - _t9.y; + vec2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, param_10) * _206); + _t5 += _206; + } + } + } + } + else + { + vec2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, param_11) * _206); + _t5 += _206; + } + } + _t6 /= vec4(_t5); + if (u_inverseGammaCorrection == 1) + { + vec4 _346 = _t6; + vec3 _351 = pow(_346.xyz, vec3(1.0 / max(u_gamma, 1e-3))); + _t6.x = _351.x; + _t6.y = _351.y; + _t6.z = _351.z; + } + if (u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + gl_FragColor = _t6; +}`; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/pp/LumiWaveWarp/WaveWarpShaderPass.js b/scripts/7681469687644884242/AmazingFeature/js/pp/LumiWaveWarp/WaveWarpShaderPass.js new file mode 100644 index 0000000000000000000000000000000000000000..275c5867b6f83dceb1ecea45076890512d6defff --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/pp/LumiWaveWarp/WaveWarpShaderPass.js @@ -0,0 +1 @@ +const THREE=require("../../ThreeJS/three-amg-wrapper.js").THREE;const{ShaderPass}=require("../../ThreeJS/ShaderPass.js");const shaderVertSource=require("./shaders/shaderVert.js").source;const shaderFragSource=require("./shaders/shaderFrag.js").source;function createShader(){const vertexShader=shaderVertSource;const fragmentShader=shaderFragSource.replace(/texture1/g,"tDiffuse");return{name:"WaveWarpShaderPass",uniforms:{tDiffuse:{value:null},progress:{value:.1},ratio:{value:1},wavelength:{value:.1},amplitude:{value:.05},phase:{value:0},direction:{value:new THREE.Vector2(1,0)},waveType:{value:0},edgeMode:{value:0},intensity:{value:1}},vertexShader:vertexShader,fragmentShader:fragmentShader,transparent:true,side:THREE.DoubleSide}}class WaveWarpShaderPass extends ShaderPass{constructor(){super(createShader());this.wavelength=.1;this.amplitude=.05;this.phase=0;this.direction=new THREE.Vector2(1,0);this.waveType=0;this.edgeMode=0;this.intensity=0;this.presets={none:{intensity:0},low:{intensity:1,wavelength:.2,amplitude:.02,phase:0,direction:{x:1,y:0},waveType:0,edgeMode:1},medium:{intensity:1,wavelength:.15,amplitude:.04,phase:0,direction:{x:1,y:0},waveType:0,edgeMode:1},high:{intensity:1,wavelength:.1,amplitude:.06,phase:0,direction:{x:1,y:0},waveType:0,edgeMode:1},ripple:{intensity:1,wavelength:.08,amplitude:.03,phase:.25,direction:{x:.7,y:.7},waveType:0,edgeMode:2},square_wave:{intensity:1,wavelength:.12,amplitude:.05,phase:0,direction:{x:1,y:0},waveType:1,edgeMode:1}}}_clampValue(value,min=0,max=1){return Math.max(min,Math.min(max,value))}setWavelength(wavelength){this.wavelength=this._clampValue(wavelength,0,1)}setAmplitude(amplitude){this.amplitude=this._clampValue(amplitude,0,1)}setPhase(phase){this.phase=this._clampValue(phase,0,1)}setDirection(direction){direction[0]=this._clampValue(direction[0],0,1);direction[1]=this._clampValue(direction[1],0,1);this.direction=direction}setWaveType(waveType){this.waveType=this._clampValue(waveType,0,2)}setEdgeMode(edgeMode){this.edgeMode=this._clampValue(edgeMode,0,2)}setIntensity(intensity){this.intensity=this._clampValue(intensity,0,1)}render(renderer,writeBuffer,readBuffer,delta,maskActive){this.material.uniforms.tDiffuse.value=readBuffer.texture;this.material.uniforms.progress.value=this.progress||.1;this.material.uniforms.ratio.value=this.ratio||1;this.material.uniforms.wavelength.value=this.wavelength;this.material.uniforms.amplitude.value=this.amplitude;this.material.uniforms.phase.value=this.phase;this.material.uniforms.direction.value=this.direction;this.material.uniforms.waveType.value=this.waveType;this.material.uniforms.edgeMode.value=this.edgeMode;this.material.uniforms.intensity.value=this.intensity;super.render(renderer,writeBuffer,readBuffer,delta,maskActive)}setParameter(key,value){const methodName="set"+key.charAt(0).toUpperCase()+key.slice(1);if(typeof this[methodName]==="function"){this[methodName](value)}else{console.warn(`No setter method found for parameter: ${key}`)}}applyPreset(presetName){const preset=this.presets[presetName];if(!preset){console.warn(`Preset '${presetName}' not found`);return}for(const key in preset){if(preset.hasOwnProperty(key)){this.setParameter(key,preset[key])}}}getPresetNames(){return Object.keys(this.presets)}getPresetConfig(presetName){if(!this.presets.hasOwnProperty(presetName)){console.warn(`Preset '${presetName}' not found`);return null}return this.presets[presetName]}}exports.WaveWarpShaderPass=WaveWarpShaderPass; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/pp/LumiWaveWarp/atomic.json b/scripts/7681469687644884242/AmazingFeature/js/pp/LumiWaveWarp/atomic.json new file mode 100644 index 0000000000000000000000000000000000000000..e9f35323a49d9b32d4dbb777a3cd9d0a0b653f88 --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/pp/LumiWaveWarp/atomic.json @@ -0,0 +1,90 @@ +{ + "key": "LumiWaveWarp", + "category": "Distort", + "desc": "波浪变形效果 - 创建正弦、方波、三角波等多种波形的图像扭曲。适用于波浪效果、水面模拟、动态扭曲、周期性变形", + "preset": [ + { + "name": "none", + "desc": "无效果 - 关闭波浪变形效果,不应用任何波浪变形处理,保持图像原始状态" + }, + { + "name": "low", + "desc": "轻度波浪 - 轻微的波浪变形效果,使用较小的波长和振幅,营造柔和的波浪视觉效果" + }, + { + "name": "medium", + "desc": "中等波浪 - 中等强度的波浪变形效果,使用适中的波长和振幅,营造明显的波浪视觉效果" + }, + { + "name": "high", + "desc": "强烈波浪 - 强烈的波浪变形效果,使用较小的波长和较大的振幅,创造戏剧化的波浪视觉效果" + }, + { + "name": "ripple", + "desc": "水波纹效果 - 模拟水面波纹的变形效果,使用特定的方向和相位偏移,营造真实的水波纹视觉效果" + }, + { + "name": "square_wave", + "desc": "方波扭曲 - 使用方波类型的波浪变形效果,创造具有明显棱角的波浪视觉效果" + } + ], + "subProperties": [ + { + "name": "intensity", + "desc": "变形强度 - 控制变形效果的强度,值越大变形越明显,0为无变形", + "type": "number", + "value": 1 + }, + { + "name": "waveLength", + "desc": "波长 - 控制波浪的周期长度,值越小波浪越密集", + "type": "number", + "value": 0.1 + }, + { + "name": "amplitude", + "desc": "振幅 - 控制波浪的强度,值越大扭曲越明显", + "type": "number", + "value": 0.05 + }, + { + "name": "phase", + "desc": "相位偏移 - 控制波浪的起始相位,用于动画控制", + "type": "number", + "value": 0 + }, + { + "name": "direction", + "desc": "波浪方向 - 设定波浪传播的方向向量", + "type": "array", + "value": [ + 1, + 0 + ] + }, + { + "name": "waveType", + "desc": "波形类型 - 选择波形:0=正弦波,1=方波,2=三角波", + "type": "number", + "value": 0, + "min": 0, + "max": 2 + }, + { + "name": "edgeMode", + "desc": "边缘模式 - 控制边缘约束:0=无约束,1=全边缘固定,2=中心固定", + "type": "number", + "value": 0, + "min": 0, + "max": 2 + }, + { + "name": "wavelength", + "desc": "Distance between repeated wave peaks in the warp pattern.", + "type": "number", + "value": 0, + "min": 0, + "max": 1 + } + ] +} diff --git a/scripts/7681469687644884242/AmazingFeature/js/pp/LumiWaveWarp/shaders/shaderFrag.js b/scripts/7681469687644884242/AmazingFeature/js/pp/LumiWaveWarp/shaders/shaderFrag.js new file mode 100644 index 0000000000000000000000000000000000000000..1eb1e8d60b0b4a7ad24157021ef259526bc830c5 --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/pp/LumiWaveWarp/shaders/shaderFrag.js @@ -0,0 +1,104 @@ +exports.source=` +precision highp float; + +uniform sampler2D tDiffuse; // = 源纹理 +uniform float progress; // = 0.5, 动画进度 +uniform float ratio; // = 1.0, 宽高比 + +// 波浪效果参数 +uniform float wavelength; // = 0.1, 波长 +uniform float amplitude; // = 0.05, 振幅 +uniform float phase; // = 0.0, 相位偏移 +uniform vec2 direction; // = vec2(1.0, 0.0), 波浪方向 +uniform int waveType; // = 0, 波形类型 (0=正弦, 1=方波, 2=三角波) +uniform int edgeMode; // = 0, 边缘模式 (0=无, 1=全边缘, 2=中心) +uniform float intensity; // = 1.0, 效果强度 + +varying vec2 vUv; + +// 边界安全采样 +vec4 textureSafe(sampler2D tex, vec2 uv) { + float maskX = step(0.0, uv.x) * step(uv.x, 1.0); + float maskY = step(0.0, uv.y) * step(uv.y, 1.0); + float mask = maskX * maskY; + return texture2D(tex, uv) * mask; +} + +// 线性步进函数 +float linearStep(float edge0, float edge1, float value) { + float t = (value - edge0) / (edge1 - edge0); + return clamp(t, 0.0, 1.0); +} + +// 波形函数 +// 波形函数 +float getWaveAmplitude(float phase) { + if (waveType == 0) { + // 正弦波 + return sin(6.28318 * phase); + } else if (waveType == 1) { + // 方波 + return step(0.5, fract(phase)) * 2.0 - 1.0; + } else if (waveType == 2) { + // 三角波 + float f = fract(phase); + return (f < 0.5) ? (f * 4.0 - 1.0) : (3.0 - f * 4.0); + } + return 0.0; +} + +// 边缘固定 +vec2 applyEdgeConstraints(vec2 originalPos, vec2 wavePos) { + if (edgeMode == 0) { + return wavePos; + } else if (edgeMode == 1) { + // 全边缘固定 + float edgeSize = amplitude * 1.2; + vec2 t0 = vec2(linearStep(0.0, edgeSize, originalPos.x), + linearStep(0.0, edgeSize, originalPos.y)); + vec2 t1 = vec2(linearStep(1.0, 1.0 - edgeSize, originalPos.x), + linearStep(1.0, 1.0 - edgeSize, originalPos.y)); + float mask = min(min(t0.x, t0.y), min(t1.x, t1.y)); + return mix(originalPos, wavePos, mask); + } else if (edgeMode == 2) { + // 中心固定 + vec2 center = vec2(0.5); + float dist = length(originalPos - center); + float maxDist = 0.4; + float mask = linearStep(0.0, maxDist, dist); + return mix(originalPos, wavePos, mask * mask); + } + return wavePos; +} + +void main() { + vec2 uv = vUv; + + // 保存原始UV坐标 + vec2 originalUV = uv; + + // 计算波浪相位 + float animatedPhase = phase + progress * 2.0; + float wavePhase = fract(dot(uv, direction) / wavelength + animatedPhase); + + // 计算波浪振幅 + float waveAmp = getWaveAmplitude(wavePhase) * amplitude; + + // 计算垂直于波浪方向的向量 + vec2 perpDir = vec2(-direction.y, direction.x); + + // 应用波浪位移 + vec2 wavePos = uv + perpDir * waveAmp; + + // 应用边缘约束 + vec2 finalPos = applyEdgeConstraints(uv, wavePos); + + // 根据intensity在原始UV和变形UV之间插值 + vec2 intensityPos = mix(originalUV, finalPos, intensity); + + // 采样纹理 + vec4 color = textureSafe(tDiffuse, intensityPos); + + gl_FragColor = color; +} +`; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/js/pp/LumiWaveWarp/shaders/shaderVert.js b/scripts/7681469687644884242/AmazingFeature/js/pp/LumiWaveWarp/shaders/shaderVert.js new file mode 100644 index 0000000000000000000000000000000000000000..2c87ab8ca97aecc86f650141dcf51ecc1ee7f46e --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/js/pp/LumiWaveWarp/shaders/shaderVert.js @@ -0,0 +1,8 @@ +exports.source=` +varying vec2 vUv; + +void main() { + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); +} +`; \ No newline at end of file diff --git a/scripts/7681469687644884242/AmazingFeature/xshader/Unlit.frag b/scripts/7681469687644884242/AmazingFeature/xshader/Unlit.frag new file mode 100644 index 0000000000000000000000000000000000000000..2b8ef6c235afd5362d14d87961e5b7fa2fe044b1 --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/xshader/Unlit.frag @@ -0,0 +1,25 @@ +precision highp float; +uniform sampler2D u_AlbedoTexture; +uniform vec4 u_AlbedoColor; +uniform vec2 u_Repeat; +uniform vec2 u_Offset; +uniform float u_Translucency; +uniform float u_Opacity; +varying vec2 g_vary_uv0; +void main () +{ + vec2 uv_1; + uv_1.x = g_vary_uv0.x; + uv_1.y = (g_vary_uv0.y); + lowp vec4 tmpvar_2; + tmpvar_2 = texture2D (u_AlbedoTexture, (uv_1 * u_Repeat + u_Offset)); + lowp vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2.xyz * u_AlbedoColor.xyz); + lowp float tmpvar_4; + tmpvar_4 = (tmpvar_2.w * u_Translucency); + mediump vec4 tmpvar_5; + tmpvar_5.xyz = tmpvar_3; + tmpvar_5.w = tmpvar_4; + gl_FragColor = vec4(tmpvar_5.xyz * u_Opacity, tmpvar_5.w * u_Opacity); +} + diff --git a/scripts/7681469687644884242/AmazingFeature/xshader/Unlit.vert b/scripts/7681469687644884242/AmazingFeature/xshader/Unlit.vert new file mode 100644 index 0000000000000000000000000000000000000000..64a27d816e6146a0fb85643a9991207e5fda2acb --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/xshader/Unlit.vert @@ -0,0 +1,35 @@ +precision highp float; +attribute vec3 attPosition; +attribute vec2 attTexcoord0; + +//#define AMAZING_USE_BONES + +#ifdef AMAZING_USE_BONES +attribute vec4 attBoneIds; +attribute vec4 attWeights; +const int MAX_BONES = 50; +uniform mat4 u_Palatte[MAX_BONES]; +#endif + +uniform mat4 u_Model; +uniform mat4 u_MVP; +varying vec2 g_vary_uv0; + + + +void main () +{ + vec3 modelPostiton = attPosition; + vec4 homogeneous_pos = vec4(attPosition, 1.0); + g_vary_uv0 = attTexcoord0; + +#ifdef AMAZING_USE_BONES + mat4 boneTransform = u_Palatte[int(attBoneIds.x)] * attWeights.x; + boneTransform += u_Palatte[int(attBoneIds.y)] * attWeights.y; + boneTransform += u_Palatte[int(attBoneIds.z)] * attWeights.z; + boneTransform += u_Palatte[int(attBoneIds.w)] * attWeights.w; + gl_Position = u_MVP * boneTransform * homogeneous_pos; +#else + gl_Position = u_MVP * homogeneous_pos; +#endif +} diff --git a/scripts/7681469687644884242/AmazingFeature/xshader/noface.frag b/scripts/7681469687644884242/AmazingFeature/xshader/noface.frag new file mode 100644 index 0000000000000000000000000000000000000000..88e9ec343761b2395bae9430e6e55466b0367d67 --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/xshader/noface.frag @@ -0,0 +1,7 @@ +precision lowp float; +varying highp vec2 uv0; +uniform sampler2D u_albedo; +void main() +{ + gl_FragColor = texture2D(u_albedo, uv0); +} diff --git a/scripts/7681469687644884242/AmazingFeature/xshader/noface.vert b/scripts/7681469687644884242/AmazingFeature/xshader/noface.vert new file mode 100644 index 0000000000000000000000000000000000000000..16450a4b5880cf8d83528ea1ae0f47d10b2ab1d8 --- /dev/null +++ b/scripts/7681469687644884242/AmazingFeature/xshader/noface.vert @@ -0,0 +1,12 @@ +precision highp float; + +attribute vec2 position; +attribute vec2 texcoord0; +varying vec2 uv0; +//uniform mat4 u_MVP; +void main() +{ + //gl_Position = u_MVP * position; + gl_Position = sign(vec4(position.xy, 0.0, 1.0)); + uv0 = texcoord0; +} diff --git a/scripts/7681469687644884242/config.json b/scripts/7681469687644884242/config.json new file mode 100644 index 0000000000000000000000000000000000000000..557ff9895b4c8c8a7d91baae310b40001cd6c20d --- /dev/null +++ b/scripts/7681469687644884242/config.json @@ -0,0 +1,16 @@ +{ + "ae_tool": "AmazingEditor", + "bALG_BACH_CONFIG": false, + "effect": { + "Link": [ + { + "path": "AmazingFeature/", + "type": "AmazingFeature", + "zorder": 8011 + } + ] + }, + "name": "AlgorithmGraph_7bdbHcdcscQkbEdcc9cIlcNdvTdtb", + "version": "13.4.0", + "item_source": "user_post_pc_lumi_ai" +} \ No newline at end of file diff --git a/scripts/7681469687644884242/extra.json b/scripts/7681469687644884242/extra.json new file mode 100644 index 0000000000000000000000000000000000000000..effa2dfef87825eb9945206e6b8ac1e126e38d0e --- /dev/null +++ b/scripts/7681469687644884242/extra.json @@ -0,0 +1,7 @@ +{ + "transition": { + "defaultDura": 2.0, + "isOverlap": true + }, + "External_Producer": true +} \ No newline at end of file diff --git a/scripts/7681492502200732936/AmazingFeature/content.json b/scripts/7681492502200732936/AmazingFeature/content.json new file mode 100644 index 0000000000000000000000000000000000000000..df43720515b1b6981b24c4268c902195fa613d43 --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/content.json @@ -0,0 +1,7 @@ +{ + "ae_tool" : "AmazingEditor", + "content" : {}, + "needblend" : false, + "tag" : "AMG_1515088281693380358513659446614427937212", + "version" : "1.0" +} \ No newline at end of file diff --git a/scripts/7681492502200732936/AmazingFeature/js/JSSys.js b/scripts/7681492502200732936/AmazingFeature/js/JSSys.js new file mode 100644 index 0000000000000000000000000000000000000000..bbcbf36f0f75c1beebe88c33dd0464bb4477158e --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/js/JSSys.js @@ -0,0 +1,89 @@ +const effect_api = "undefined" != typeof effect ? effect : "undefined" != typeof tt ? tt : "undefined" != typeof lynx ? lynx : {}; +const Amaz = effect_api.getAmaz(); + +const { ScriptScene } = require('./ThreeJS/scriptScene'); +const THREE = require('./ThreeJS/three-amg-wrapper').THREE; + +class JSSys { + constructor() { + this.name = "JSSys"; + this.comps = {} + this.compsdirty = true + } + + onComponentAdded(comp) { + // console.log("running:JSSys:onComponentAdded"); + } + onComponentRemoved(comp) { + // console.log("running:JSSys:onComponentRemoved"); + } + + onStart() { + console.log("running:JSSys:onStart"); + + this.renderTexture = this.scene.assetMgr.SyncLoad('rt/outputTex.rt'); + + // 添加光源到场景 + console.log('JSSys: 创建ScriptScene实例'); + this.scriptScene = new ScriptScene(this.scene); + + this.input = Amaz.AmazingManager.getSingleton("Input"); + const builtinObject = Amaz.AmazingManager.getSingleton("BuiltinObject"); + + if (builtinObject.getUserTexture("#TransitionInput0") && builtinObject.getUserTexture("#TransitionInput1")) { + this.scriptScene.texture1 = new THREE.Texture(); + this.scriptScene.texture1.setImage(builtinObject.getUserTexture("#TransitionInput0")); + this.scriptScene.texture2 = new THREE.Texture(); + this.scriptScene.texture2.setImage(builtinObject.getUserTexture("#TransitionInput1")); + console.log("JSSys: 获取到纹理"); + } + else + { + this.scriptScene.texture1 = new THREE.Texture(); + this.scriptScene.texture1.setImage(this.scene.assetMgr.SyncLoad('image/Sample1.jpg')); + this.scriptScene.texture2 = new THREE.Texture(); + this.scriptScene.texture2.setImage(this.scene.assetMgr.SyncLoad('image/Sample2.jpg')); + console.log("JSSys: 未获取到纹理,使用默认纹理"); + } + + this.scriptScene.setupScene(); + // 初始化后处理效果 + if (this.scriptScene.initPostProcessing != null) { + this.scriptScene.initPostProcessing(); + } + } + + onUpdate(deltaTime) { + this.time = this.input.getFrameTimestamp(); + // this.time = this.time % 2; + // this.time = this.time / 2.0; + this.scriptScene.seekToTime(this.time * this.scriptScene.Duration); + // this.scriptScene.updateScene(); + } + onLateUpdate(deltaTime) { + // console.log("running:JSSys:onLateUpdate"); + this.scriptScene.scene.seekToTime(this.time * this.scriptScene.Duration); + } + + onEvent(event) { + console.log("running:JSSys:onEvent"); + if (event.type == Amaz.EventType.VIEWER) { + // console.log("JSSys: 窗口大小改变"); + console.log("renderTexture.width",this.renderTexture.width); + console.log("renderTexture.height",this.renderTexture.height); + + window.innerWidth = this.renderTexture.width; + window.innerHeight = this.renderTexture.height; + // console.log("JSSys: 窗口大小改变"); + this.scriptScene.handleResize(); + } + } + + onDestroy() { + // console.log("running:JSSys:onDestroy"); + this.scriptScene.destroy(); + } +} + +exports.JSSys = JSSys; + diff --git a/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/EffectComposer.js b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/EffectComposer.js new file mode 100644 index 0000000000000000000000000000000000000000..e7d8fd7a3f3978d9da1a9bf29af1854806f60014 --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/EffectComposer.js @@ -0,0 +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{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-6*k)*Math.cos(12*k)};const springStiff=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(18*k)};const dampedOscillation=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(10*k)};const Physics=Object.freeze({SpringSoft:springSoft,SpringStiff:springStiff,DampedOscillation:dampedOscillation});const anticipate=k=>{if(k<=0)return 0;if(k>=1)return 1;const pullback=.1;if(k<.3){const p=k/.3;return-pullback*p*(2-p)}const p=(k-.3)/.7;return-pullback+(1+pullback)*p*p*(3-2*p)};const overshootFactory=peak=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return peak*p*(2-p)}const p=(k-.6)/.4;return peak+(1-peak)*(1-Math.pow(1-p,3))};const overshoot110=overshootFactory(1.1);const overshoot125=overshootFactory(1.25);const snapBack=k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return 1.05*(1-Math.pow(1-p,3))}const p=(k-.6)/.4;return 1.05-.05*p*p*(3-2*p)};const swing=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.cos(1.5*Math.PI*k)*Math.exp(-2.5*k)};const Motion=Object.freeze({Anticipate:anticipate,Overshoot110:overshoot110,Overshoot125:overshoot125,SnapBack:snapBack,Swing:swing});const makeStep=(n,jumpTerm="end")=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(jumpTerm==="start")return Math.ceil(k*n)/n;return Math.floor(k*n)/n};const Step=Object.freeze({Steps4End:makeStep(4,"end"),Steps8End:makeStep(8,"end"),Steps12End:makeStep(12,"end")});function buildCubicBezier(x1,y1,x2,y2){const cx=3*x1,bx=3*(x2-x1)-cx,ax=1-cx-bx;const cy=3*y1,by=3*(y2-y1)-cy,ay=1-cy-by;const sampleX=s=>((ax*s+bx)*s+cx)*s;const sampleY=s=>((ay*s+by)*s+cy)*s;const sampleDX=s=>(3*ax*s+2*bx)*s+cx;const solveS=x=>{let s=x;for(let i=0;i<8;i++){const cur=sampleX(s)-x;if(Math.abs(cur)<1e-6)return s;const d=sampleDX(s);if(Math.abs(d)<1e-6)break;s-=cur/d;if(s<0)s=0;if(s>1)s=1}let lo=0,hi=1;for(let i=0;i<32&&hi-lo>1e-6;i++){const mid=(lo+hi)/2;if(sampleX(mid){if(k<=0)return 0;if(k>=1)return 1;return sampleY(solveS(k))}}const BEZIER_PRESETS=Object.freeze({"Material.Standard":[.4,0,.2,1],"Material.Accelerate":[.4,0,1,1],"Material.Decelerate":[0,0,.2,1],"CSS.Ease":[.25,.1,.25,1]});const _bezierCache=new Map;function _cachedBezier(x1,y1,x2,y2){const key=x1+","+y1+","+x2+","+y2;let fn=_bezierCache.get(key);if(!fn){fn=buildCubicBezier(x1,y1,x2,y2);_bezierCache.set(key,fn)}return fn}function cubicBezier(a,b,c,d){if(typeof a==="string"){let preset=BEZIER_PRESETS[a];if(!preset){console.warn("[customEasings.cubicBezier] unknown preset, falling back to Material.Standard:",a);preset=BEZIER_PRESETS["Material.Standard"]}return _cachedBezier(preset[0],preset[1],preset[2],preset[3])}const clamp=(v,lo,hi)=>Math.max(lo,Math.min(hi,v));const x1=clamp(a,0,1);const y1=clamp(b,-.5,1.5);const x2=clamp(c,0,1);const y2=clamp(d,-.5,1.5);return _cachedBezier(x1,y1,x2,y2)}const libSpring=({stiffness=180,damping=12,mass=1}={})=>{const DT=1/240;const T=1.5;let x=0,v=0;const samples=[];for(let t=0;t<=T;t+=DT){const force=-stiffness*(x-1)-damping*v;v+=force/mass*DT;x+=v*DT;samples.push({t:t,x:x})}let T_end=T;for(let i=samples.length-1;i>=0;i--){if(Math.abs(samples[i].x-1)>.01){T_end=samples[i].t;break}}return k=>{if(k<=0)return 0;if(k>=1)return 1;const t=k*T_end;const idx=Math.min(samples.length-1,Math.floor(t/DT));return samples[idx].x}};const libHeartBeat=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c)=>Math.exp(-((t-c)**2)/(2*.07*.07));return peak*(bell(k,.2)+bell(k,.5))};const libSteps=(n=6)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return Math.floor(k*n)/n};const attentionPing=(peak=.35,decay=2)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(Math.PI*k)*Math.exp(-decay*k)};const attentionWiggle=(count=4,amplitude=.25)=>k=>{if(k<=0||k>=1)return 0;const env=1-k;return amplitude*env*Math.sin(k*Math.PI*2*count)};const attentionStrum=(notes=4,peak=.4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*.05*.05))}return peak*sum}};const Attention=Object.freeze({Ping:attentionPing(),Wiggle:attentionWiggle(),Strum:attentionStrum()});const breathNormal=(cycles=2,peak=.15)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(k*Math.PI*2*cycles)*Math.sin(k*Math.PI)};const breathDeep=(peak=.3,riseRatio=.35,holdRatio=.15)=>{const holdEnd=riseRatio+holdRatio;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const envelope=Math.sin(k*Math.PI);const wave=.5+.5*Math.sin(k*Math.PI*2*cycles-Math.PI/2);return peak*envelope*wave};const breathSigh=(peak=.25,riseRatio=.2)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return peak*Math.exp(-((k-center)**2)/(2*width*width))};const heartExcited=(beats=4,peak=.3,width=.04)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*width*width))}return peak*sum}};const heartLubDub=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return peak*(bell(k,.25,.045)+.6*bell(k,.42,.03))};const Heart=Object.freeze({Calm:heartCalm(),Excited:heartExcited(),LubDub:heartLubDub()});const mathJumpArc=()=>k=>{if(k<=0||k>=1)return 0;return 4*k*(1-k)};const mathPendulum=(damping=3,freq=2.5)=>k=>{if(k<=0||k>=1)return 0;return Math.sin(k*Math.PI)*Math.exp(-damping*k)*Math.cos(freq*Math.PI*k)};const mathTremor=(amplitude=.04,freq=22)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return k+amplitude*Math.sin(k*Math.PI*2*freq)};const mathBoomerang=fn=>k=>{if(k<=0||k>=1)return 0;return k<.5?fn(k*2):fn(2-k*2)};const MathExt=Object.freeze({JumpArc:mathJumpArc(),Pendulum:mathPendulum(),Tremor:mathTremor()});const explosionImpulse=(sharpness=6)=>{const tail=sharpness*Math.exp(1-sharpness);return k=>{if(k<=0||k>=1)return 0;const h=sharpness*k;return h*Math.exp(1-h)-tail*k}};const explosionFlash=(rise=.05,decay=5)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return-Math.exp(-decay*k)*Math.cos(freq*Math.PI*k)};const explosionImplosion=(charge=.3,depth=.4,burstPeak=1.2)=>{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const w=Math.sin(k*Math.PI*2*cycles)+.5*Math.sin(k*Math.PI*2*cycles*1.5+1.2)+.25*Math.sin(k*Math.PI*2*cycles*3+2.4);return amplitude*env*w*.6};const natureFlicker=(rate=15,intensity=.2,seed=7)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=rate+1;i++)samples.push(rand());return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*rate;const idx=Math.floor(pos);const t=pos-idx;const a=samples[idx];const b=samples[idx+1];const interp=a+(b-a)*t;return intensity*env*(interp-.5)*2}};const natureGust=(gusts=3,peak=.25)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*.08*.08))}return peak*sum/gusts*1.8}};const Nature=Object.freeze({Wave:natureWave(),Flicker:natureFlicker(),Gust:natureGust()});const impactRain=(impactAt=.7,rippleAmp=.08)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const liftEnd=.35,strikeEnd=.6;return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return t*t}const t=(k-.4)/.6;const env=Math.exp(-2.5*t);const wave=Math.abs(Math.sin(t*Math.PI*bounces));return 1-env*wave*rebound};const impactSlap=(contactAt=.3,holdRatio=.1)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return.4*Math.pow(t,2.5)}if(k<.48){const t=(k-.4)/.08;return.4-.2*t}if(k<.52){const t=(k-.48)/.04;return.2+.8*t}const t=(k-.52)/.48;return 1-.04*Math.sin(t*Math.PI*8)*(1-t)};const rhythmPunchCombo=(peak=.4)=>{const pattern=[{c:.15,w:.04,a:.75},{c:.35,w:.04,a:.75},{c:.7,w:.055,a:1}];return k=>{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of pattern){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return peak*sum}};const rhythmStaccato=(beats=4,duty=.3)=>k=>{if(k<=0||k>=1)return 0;const beatLen=1/beats;const phase=k/beatLen-Math.floor(k/beatLen);if(phase>duty)return 0;const t=phase/duty;return Math.sin(t*Math.PI)};const rhythmKick=(peak=1.2)=>k=>{if(k<=0||k>=1)return 0;if(k<.05)return peak*k/.05;const t=(k-.05)/.95;return peak*Math.exp(-4*t)};const rhythmCrescendo=(beats=4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return sum}};const rhythmDunDunDun=()=>{const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return k=>{if(k<=0||k>=1)return 0;return.3*bell(k,.15,.025)+.6*bell(k,.35,.03)+1*bell(k,.68,.09)}};const rhythmBellToll=(decay=3,freq=8)=>{const strike=.05;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.2){const t=k/.2;return-pressDepth*Math.sin(t*Math.PI/2)}if(k<.5){const t=(k-.2)/.3;return-pressDepth+(pressDepth+reboundPeak)*(1-Math.pow(1-t,3))}const t=(k-.5)/.5;return reboundPeak*Math.exp(-4*t)*Math.cos(t*Math.PI*3)};const uiHoverBloom=(riseRatio=.2,fallRatio=.3)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=1-k;const raw=Math.sin(k*Math.PI*2*count);const clipped=Math.sign(raw)*Math.min(1,Math.abs(raw)*1.8);return amplitude*env*clipped};const uiSuccessPop=(overshoot=.2)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return(1+overshoot)*(1-Math.pow(1-t,2))}const t=(k-.4)/.6;return 1+overshoot*Math.exp(-5*t)*Math.cos(t*Math.PI*3)};const uiRippleOut=()=>k=>{if(k<=0||k>=1)return 0;return 6.75*k*Math.pow(1-k,2)};const UI=Object.freeze({ClickSnap:uiClickSnap(),HoverBloom:uiHoverBloom(),ErrorShake:uiErrorShake(),SuccessPop:uiSuccessPop(),RippleOut:uiRippleOut()});const magicManaCharge=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;const base=(Math.exp(3*k)-1)/(Math.exp(3)-1);const pulse=.04*Math.sin(k*Math.PI*8)*k;return base+pulse};const magicSpellCast=(chargeEnd=.4)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.45){const t=k/.45;return t*t*t}if(k<.55)return 1;const t=(k-.55)/.45;return Math.pow(1-t,3)};const magicShield=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.3){const t=k/.3;return 1.2*(1-Math.pow(1-t,2))}if(k<.6){const t=(k-.3)/.3;return 1.2-.2*t}const t=(k-.6)/.4;return 1+.03*Math.sin(t*Math.PI*3)};const magicAura=(peak=.15)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const fundamental=.6*Math.sin(k*Math.PI*2);const harmonic=.3*Math.sin(k*Math.PI*4+1);const overtone=.1*Math.sin(k*Math.PI*6+2);return peak*env*(fundamental+harmonic+overtone)};const Magic=Object.freeze({ManaCharge:magicManaCharge(),SpellCast:magicSpellCast(),Teleport:magicTeleport(),Shield:magicShield(),MagicAura:magicAura()});const animalCatPounce=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.2){const t=k/.2;return-.2*Math.sin(t*Math.PI)}if(k<.3){const t=(k-.2)/.1;return.5*t*t}if(k<.8){const t=(k-.3)/.5;return.5+.5*t+.2*Math.sin(t*Math.PI)}const t=(k-.8)/.2;return 1+.05*Math.sin(t*Math.PI)};const animalBirdFlap=(flaps=4)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const phase=k*Math.PI*2*flaps;const wave=Math.sin(phase)-.3*Math.sin(phase*2);return.2*env*wave};const animalSnakeSlither=(waves=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const wave=Math.sin(k*Math.PI*2*waves);return.2*env*wave};const animalButterflyFlit=(seed=13)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=26;i++)samples.push(rand()-.5);return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*25;const idx=Math.floor(pos);const t=pos-idx;const smooth=t*t*(3-2*t);const interp=samples[idx]+(samples[idx+1]-samples[idx])*smooth;return.3*env*interp}};const animalHorseGallop=(cycles=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const cyclePos=k*cycles-Math.floor(k*cycles);const bell=(c,w=.04)=>Math.exp(-((cyclePos-c)**2)/(2*w*w));return.25*env*(bell(0)+bell(.18)+bell(.36)+bell(.54))};const Animal=Object.freeze({CatPounce:animalCatPounce(),BirdFlap:animalBirdFlap(),SnakeSlither:animalSnakeSlither(),ButterflyFlit:animalButterflyFlit(),HorseGallop:animalHorseGallop()});const Progress=Object.freeze({Physics:Object.freeze({...Physics,Spring:libSpring()}),Motion:Motion,Step:Object.freeze({...Step,Steps6:libSteps()}),Math:Object.freeze({Tremor:MathExt.Tremor}),Impact:Object.freeze({Rain:Impact.Rain,Hammer:Impact.Hammer,BounceDrop:Impact.BounceDrop,ArrowHit:Impact.ArrowHit,Shatter:Impact.Shatter}),Rhythm:Object.freeze({BassDrop:Rhythm.BassDrop}),UI:Object.freeze({SuccessPop:UI.SuccessPop}),Magic:Object.freeze({ManaCharge:Magic.ManaCharge,Shield:Magic.Shield}),Animal:Object.freeze({CatPounce:Animal.CatPounce})});const Pulse=Object.freeze({Attention:Object.freeze({Ping:Attention.Ping}),Breath:Object.freeze({Deep:Breath.Deep,Sigh:Breath.Sigh}),Heart:Object.freeze({Calm:Heart.Calm}),Math:Object.freeze({JumpArc:MathExt.JumpArc,BoomerangSharp:mathBoomerang(E.Cubic.In),BoomerangSoft:mathBoomerang(E.Cubic.Out)}),Explosion:Object.freeze({Impulse:Explosion.Impulse,Flash:Explosion.Flash,Recoil:Explosion.Recoil,Implosion:Explosion.Implosion}),Impact:Object.freeze({Slap:Impact.Slap}),Rhythm:Object.freeze({Kick:Rhythm.Kick}),UI:Object.freeze({ClickSnap:UI.ClickSnap,HoverBloom:UI.HoverBloom,RippleOut:UI.RippleOut}),Magic:Object.freeze({SpellCast:Magic.SpellCast,Teleport:Magic.Teleport})});const Wave=Object.freeze({Attention:Object.freeze({Wiggle:Attention.Wiggle,Strum:Attention.Strum}),Breath:Object.freeze({Normal:Breath.Normal,Panting:Breath.Panting}),Heart:Object.freeze({Excited:Heart.Excited,LubDub:Heart.LubDub,Beat:libHeartBeat()}),Math:Object.freeze({Pendulum:MathExt.Pendulum}),Nature:Nature,Rhythm:Object.freeze({PunchCombo:Rhythm.PunchCombo,Staccato:Rhythm.Staccato,Crescendo:Rhythm.Crescendo,DunDunDun:Rhythm.DunDunDun,BellToll:Rhythm.BellToll}),UI:Object.freeze({ErrorShake:UI.ErrorShake}),Magic:Object.freeze({MagicAura:Magic.MagicAura}),Animal:Object.freeze({BirdFlap:Animal.BirdFlap,SnakeSlither:Animal.SnakeSlither,ButterflyFlit:Animal.ButterflyFlit,HorseGallop:Animal.HorseGallop})});const customEasings=Object.freeze({makeOutIn:makeOutIn,OutIn:OutIn,Progress:Progress,Pulse:Pulse,Wave:Wave,cubicBezier:cubicBezier});exports.customEasings=customEasings;exports.default=customEasings; \ No newline at end of file diff --git a/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/scriptScene.js b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/scriptScene.js new file mode 100644 index 0000000000000000000000000000000000000000..5d5f0a8bde54f7efa0912b77bb0a8298e3fb04e9 --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/scriptScene.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/three-amg-wrapper.js b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/three-amg-wrapper.js new file mode 100644 index 0000000000000000000000000000000000000000..c2037e314e032c4d36912923d4cc1258cba3ab19 --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/three-amg-wrapper.js @@ -0,0 +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;iobj.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; \ No newline at end of file diff --git a/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/tween.js b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/tween.js new file mode 100644 index 0000000000000000000000000000000000000000..690fb9e4284728629129deed5a5a3f4bcec291ed --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/tween.js @@ -0,0 +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=power1e4?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;_i0){this._tweensAddedDuringUpdate={};for(var i=0;i1){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[m1;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;itotalTime){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;ithis.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;ithis.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.xthis.max.x||box.max.ythis.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; \ No newline at end of file diff --git a/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Box3.js b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Box3.js new file mode 100644 index 0000000000000000000000000000000000000000..4100dc7442d3a622827c8a415e24557f68c491f1 --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Box3.js @@ -0,0 +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=3?array[offset+2]:0;if(xthis.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=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.xthis.max.x||box.max.ythis.max.y||box.max.zthis.max.z)}}exports.Box3=Box3; \ No newline at end of file diff --git a/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..be3b8b1334a62f5e88c45feee098063a199fca55 --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js @@ -0,0 +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=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; \ No newline at end of file diff --git a/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..af9a8a13a46500e78f082a35e18d0b5932061234 --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js @@ -0,0 +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;iObject.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;i1?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; \ No newline at end of file diff --git a/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Constants.js b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Constants.js new file mode 100644 index 0000000000000000000000000000000000000000..6b8adda19a4d67236719804f5170889b39fd4582 --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Constants.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js new file mode 100644 index 0000000000000000000000000000000000000000..29b0aad5599401be17f967ba1d48851acb70c2ac --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js @@ -0,0 +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;i0||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;i0?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;imaxX)maxX=p.x;if(p.ymaxY)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; \ No newline at end of file diff --git a/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..f3dee08bf1c089e040fcfef228902ab9a39c93cb --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Earcut.js b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Earcut.js new file mode 100644 index 0000000000000000000000000000000000000000..953abffdf38c2def26df73fed180eff8c7644ced --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Earcut.js @@ -0,0 +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;imaxX)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=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=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.x&&p.x>=mx&&hx!==p.x&&pointInTriangle(hym.x||p.x===m.x&§orContainsSector(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.xb.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;i0||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=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;i0){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;imaxX)maxX=contour[i].x;if(contour[i].ymaxY)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;layerIdx0?-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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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; \ No newline at end of file diff --git a/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Group.js b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Group.js new file mode 100644 index 0000000000000000000000000000000000000000..90c4dbef65aa04d7a3bb6b6d76ec3317ea65a228 --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Group.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");class Group extends Object3D{constructor(name="Group_w"){super(name)}dispose(){super.dispose()}}exports.Group=Group; \ No newline at end of file diff --git a/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Material.js b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Material.js new file mode 100644 index 0000000000000000000000000000000000000000..81b97053ad9d1e4b1ef05d5ac6ed992487b2ca8e --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Material.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..dcf34d4cffb9de0869382a24690f78f60dda6049 --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js new file mode 100644 index 0000000000000000000000000000000000000000..41e6cd0a0eee7dd7bc497be5deac584806b68dc3 --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Mesh.js b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Mesh.js new file mode 100644 index 0000000000000000000000000000000000000000..254d69b074e797dd34c16d7dad723bbcc3b4895d --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Mesh.js @@ -0,0 +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;imaterial,set:value=>{material=value;if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;im.dispose&&m.dispose());else if(this.material.dispose)this.material.dispose()}}}exports.MeshWrapper=MeshWrapper; \ No newline at end of file diff --git a/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..ac394f66efc4e113a7127ee0f50ec672e4c5e9eb --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Object3D.js b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Object3D.js new file mode 100644 index 0000000000000000000000000000000000000000..8532c6122f839460aab34fe88957802ff523318b --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Object3D.js @@ -0,0 +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{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&¤tScene._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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js new file mode 100644 index 0000000000000000000000000000000000000000..ba39801de50d38ec04424f3c2ebfa2ff5d28fded --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js @@ -0,0 +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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..bc595fb80ad9e7c2f4d8360c67dbef556f3d6cbe --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js @@ -0,0 +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;iy0){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; \ No newline at end of file diff --git a/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..02dc1be955bc766de744222a7e75c65bf147bb61 --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js @@ -0,0 +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&¶meters.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{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=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=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=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; \ No newline at end of file diff --git a/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Shape.js b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Shape.js new file mode 100644 index 0000000000000000000000000000000000000000..ecde48b5ceb30812c922aa5c7cfe2aa7b50cabe4 --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Shape.js @@ -0,0 +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;i0){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;i0||(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;imaxX)maxX=p.x;if(p.ymaxY)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;i0?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;ipoints.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;itwoPi)deltaAngle-=twoPi;if(deltaAngle>4;uuid[i]=chars[i===19?r&3|8:r]}}return uuid.join("")}exports.Shape=Shape; \ No newline at end of file diff --git a/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..3786abc7d64ed80b56101c4ac9d30ce9fcb8f941 --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js @@ -0,0 +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;i0){const bounds=calculateBounds(flatVertices);const vertexOffset=vertices.length/3;for(let j=0;j0){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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}function calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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; \ No newline at end of file diff --git a/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..1ea27a55fbce9fc3771c66840c068e5ff6347092 --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Texture.js b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Texture.js new file mode 100644 index 0000000000000000000000000000000000000000..35bff49d732c9884e07bfcb5682f18a860485e1f --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Texture.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Vector2.js b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Vector2.js new file mode 100644 index 0000000000000000000000000000000000000000..a30a2431264ee62cec937714dfa9e50932ddedeb --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/js/ThreeJS/wrapper/Vector2.js @@ -0,0 +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)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)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)= 1.0) return texel2; + + float p = smoothstep(0.0, 1.0, progress); + + vec2 center = focus; + vec2 base = vUv - center; + base.x *= ratio; + + vec4 accum1 = vec4(0.0); + vec4 accum2 = vec4(0.0); + float wSum1 = 0.0; + float wSum2 = 0.0; + + for (int i = 0; i < 4; i++) { + float fi = float(i); + float t = fi / 3.0; + + float s1 = 1.0 + (p * zoomPower + t * 0.9) * 3.2; + float a1 = twistAmount * (0.35 + t) * (0.4 + p * 1.2); + vec2 q1 = rotate2D(base, a1) / s1; + q1.x /= ratio; + vec2 uv1 = safeUv(center + q1); + float w1 = 1.0 - t * 0.22; + accum1 += texture2D(tDiffuse, uv1) * w1; + wSum1 += w1; + + float s2 = 1.0 + ((1.0 - p) * zoomPower + (1.0 - t) * 0.9) * 3.2; + float a2 = -twistAmount * (0.35 + t) * (0.4 + (1.0 - p) * 1.2); + vec2 q2 = rotate2D(base, a2) / s2; + q2.x /= ratio; + vec2 uv2 = safeUv(center + q2); + float w2 = 1.0 - (1.0 - t) * 0.22; + accum2 += texture2D(tDiffuse1, uv2) * w2; + wSum2 += w2; + } + + vec4 col1 = accum1 / max(wSum1, 1e-5); + vec4 col2 = accum2 / max(wSum2, 1e-5); + + float reveal = p; + vec4 mixed = mix(col1, col2, reveal); + mixed.rgb = clamp(mixed.rgb, 0.0, 1.0); + mixed.a = mix(texel1.a, texel2.a, reveal); + + return mixed; +} + +void main() { + // Get the pixel color from both textures + vec4 texel1 = texture2D(tDiffuse, vUv); + vec4 texel2 = texture2D(tDiffuse1, vUv); + + // --- Transition Configuration --- + const float fadeInEnd = 0.1; + const float fadeOutStart = 0.9; + + // 1. Calculate the transition's own progress. + float transitionProgress = clamp((progress - fadeInEnd) / (fadeOutStart - fadeInEnd), 0.0, 1.0); + vec4 transitionColor = transition(texel1, texel2, transitionProgress); + + // 2. Calculate smooth blending factors for the start and end zones. + float blendInFactor = smoothstep(0.0, fadeInEnd, progress); + float blendOutFactor = smoothstep(fadeOutStart, 1.0, progress); + + // 3. Apply the blending. + vec4 finalColor = mix(texel1, transitionColor, blendInFactor); + finalColor = mix(finalColor, texel2, blendOutFactor); + + gl_FragColor = finalColor; +} +//===end_frag_code=== +`; \ No newline at end of file diff --git a/scripts/7681492502200732936/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js b/scripts/7681492502200732936/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js new file mode 100644 index 0000000000000000000000000000000000000000..2c87ab8ca97aecc86f650141dcf51ecc1ee7f46e --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js @@ -0,0 +1,8 @@ +exports.source=` +varying vec2 vUv; + +void main() { + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); +} +`; \ No newline at end of file diff --git a/scripts/7681492502200732936/AmazingFeature/xshader/Unlit.frag b/scripts/7681492502200732936/AmazingFeature/xshader/Unlit.frag new file mode 100644 index 0000000000000000000000000000000000000000..2b8ef6c235afd5362d14d87961e5b7fa2fe044b1 --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/xshader/Unlit.frag @@ -0,0 +1,25 @@ +precision highp float; +uniform sampler2D u_AlbedoTexture; +uniform vec4 u_AlbedoColor; +uniform vec2 u_Repeat; +uniform vec2 u_Offset; +uniform float u_Translucency; +uniform float u_Opacity; +varying vec2 g_vary_uv0; +void main () +{ + vec2 uv_1; + uv_1.x = g_vary_uv0.x; + uv_1.y = (g_vary_uv0.y); + lowp vec4 tmpvar_2; + tmpvar_2 = texture2D (u_AlbedoTexture, (uv_1 * u_Repeat + u_Offset)); + lowp vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2.xyz * u_AlbedoColor.xyz); + lowp float tmpvar_4; + tmpvar_4 = (tmpvar_2.w * u_Translucency); + mediump vec4 tmpvar_5; + tmpvar_5.xyz = tmpvar_3; + tmpvar_5.w = tmpvar_4; + gl_FragColor = vec4(tmpvar_5.xyz * u_Opacity, tmpvar_5.w * u_Opacity); +} + diff --git a/scripts/7681492502200732936/AmazingFeature/xshader/Unlit.vert b/scripts/7681492502200732936/AmazingFeature/xshader/Unlit.vert new file mode 100644 index 0000000000000000000000000000000000000000..64a27d816e6146a0fb85643a9991207e5fda2acb --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/xshader/Unlit.vert @@ -0,0 +1,35 @@ +precision highp float; +attribute vec3 attPosition; +attribute vec2 attTexcoord0; + +//#define AMAZING_USE_BONES + +#ifdef AMAZING_USE_BONES +attribute vec4 attBoneIds; +attribute vec4 attWeights; +const int MAX_BONES = 50; +uniform mat4 u_Palatte[MAX_BONES]; +#endif + +uniform mat4 u_Model; +uniform mat4 u_MVP; +varying vec2 g_vary_uv0; + + + +void main () +{ + vec3 modelPostiton = attPosition; + vec4 homogeneous_pos = vec4(attPosition, 1.0); + g_vary_uv0 = attTexcoord0; + +#ifdef AMAZING_USE_BONES + mat4 boneTransform = u_Palatte[int(attBoneIds.x)] * attWeights.x; + boneTransform += u_Palatte[int(attBoneIds.y)] * attWeights.y; + boneTransform += u_Palatte[int(attBoneIds.z)] * attWeights.z; + boneTransform += u_Palatte[int(attBoneIds.w)] * attWeights.w; + gl_Position = u_MVP * boneTransform * homogeneous_pos; +#else + gl_Position = u_MVP * homogeneous_pos; +#endif +} diff --git a/scripts/7681492502200732936/AmazingFeature/xshader/noface.frag b/scripts/7681492502200732936/AmazingFeature/xshader/noface.frag new file mode 100644 index 0000000000000000000000000000000000000000..88e9ec343761b2395bae9430e6e55466b0367d67 --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/xshader/noface.frag @@ -0,0 +1,7 @@ +precision lowp float; +varying highp vec2 uv0; +uniform sampler2D u_albedo; +void main() +{ + gl_FragColor = texture2D(u_albedo, uv0); +} diff --git a/scripts/7681492502200732936/AmazingFeature/xshader/noface.vert b/scripts/7681492502200732936/AmazingFeature/xshader/noface.vert new file mode 100644 index 0000000000000000000000000000000000000000..16450a4b5880cf8d83528ea1ae0f47d10b2ab1d8 --- /dev/null +++ b/scripts/7681492502200732936/AmazingFeature/xshader/noface.vert @@ -0,0 +1,12 @@ +precision highp float; + +attribute vec2 position; +attribute vec2 texcoord0; +varying vec2 uv0; +//uniform mat4 u_MVP; +void main() +{ + //gl_Position = u_MVP * position; + gl_Position = sign(vec4(position.xy, 0.0, 1.0)); + uv0 = texcoord0; +} diff --git a/scripts/7681492502200732936/config.json b/scripts/7681492502200732936/config.json new file mode 100644 index 0000000000000000000000000000000000000000..557ff9895b4c8c8a7d91baae310b40001cd6c20d --- /dev/null +++ b/scripts/7681492502200732936/config.json @@ -0,0 +1,16 @@ +{ + "ae_tool": "AmazingEditor", + "bALG_BACH_CONFIG": false, + "effect": { + "Link": [ + { + "path": "AmazingFeature/", + "type": "AmazingFeature", + "zorder": 8011 + } + ] + }, + "name": "AlgorithmGraph_7bdbHcdcscQkbEdcc9cIlcNdvTdtb", + "version": "13.4.0", + "item_source": "user_post_pc_lumi_ai" +} \ No newline at end of file diff --git a/scripts/7681492502200732936/extra.json b/scripts/7681492502200732936/extra.json new file mode 100644 index 0000000000000000000000000000000000000000..27214334dcb584d0fdf698382e72c11aaaf256db --- /dev/null +++ b/scripts/7681492502200732936/extra.json @@ -0,0 +1,44 @@ +{ + "transition": { + "defaultDura": 2.0, + "isOverlap": true + }, + "External_Producer": true, + "setting": { + "lumiai_material_properties": [ + { + "effect_key": "progress", + "effect_key_cn": "\u6548\u679c\u8fdb\u5ea6", + "type": "float", + "default": 0, + "min": 0, + "max": 1 + }, + { + "effect_key": "zoomPower", + "effect_key_cn": "zoom P", + "type": "float", + "default": 2.8, + "min": 0.5, + "max": 6 + }, + { + "effect_key": "twistAmount", + "effect_key_cn": "twist ", + "type": "float", + "default": 1.4, + "min": 0, + "max": 5 + }, + { + "effect_key": "focus", + "effect_key_cn": "focus", + "type": "vec2", + "default": [ + 0.5, + 0.5 + ] + } + ] + } +} \ No newline at end of file diff --git a/scripts/7681530401944390928/AmazingFeature/content.json b/scripts/7681530401944390928/AmazingFeature/content.json new file mode 100644 index 0000000000000000000000000000000000000000..df43720515b1b6981b24c4268c902195fa613d43 --- /dev/null +++ b/scripts/7681530401944390928/AmazingFeature/content.json @@ -0,0 +1,7 @@ +{ + "ae_tool" : "AmazingEditor", + "content" : {}, + "needblend" : false, + "tag" : "AMG_1515088281693380358513659446614427937212", + "version" : "1.0" +} \ No newline at end of file diff --git a/scripts/7681530401944390928/AmazingFeature/js/JSSys.js b/scripts/7681530401944390928/AmazingFeature/js/JSSys.js new file mode 100644 index 0000000000000000000000000000000000000000..bbcbf36f0f75c1beebe88c33dd0464bb4477158e --- /dev/null +++ b/scripts/7681530401944390928/AmazingFeature/js/JSSys.js @@ -0,0 +1,89 @@ +const effect_api = "undefined" != typeof effect ? effect : "undefined" != typeof tt ? tt : "undefined" != typeof lynx ? lynx : {}; +const Amaz = effect_api.getAmaz(); + +const { ScriptScene } = require('./ThreeJS/scriptScene'); +const THREE = require('./ThreeJS/three-amg-wrapper').THREE; + +class JSSys { + constructor() { + this.name = "JSSys"; + this.comps = {} + this.compsdirty = true + } + + onComponentAdded(comp) { + // console.log("running:JSSys:onComponentAdded"); + } + onComponentRemoved(comp) { + // console.log("running:JSSys:onComponentRemoved"); + } + + onStart() { + console.log("running:JSSys:onStart"); + + this.renderTexture = this.scene.assetMgr.SyncLoad('rt/outputTex.rt'); + + // 添加光源到场景 + console.log('JSSys: 创建ScriptScene实例'); + this.scriptScene = new ScriptScene(this.scene); + + this.input = Amaz.AmazingManager.getSingleton("Input"); + const builtinObject = Amaz.AmazingManager.getSingleton("BuiltinObject"); + + if (builtinObject.getUserTexture("#TransitionInput0") && builtinObject.getUserTexture("#TransitionInput1")) { + this.scriptScene.texture1 = new THREE.Texture(); + this.scriptScene.texture1.setImage(builtinObject.getUserTexture("#TransitionInput0")); + this.scriptScene.texture2 = new THREE.Texture(); + this.scriptScene.texture2.setImage(builtinObject.getUserTexture("#TransitionInput1")); + console.log("JSSys: 获取到纹理"); + } + else + { + this.scriptScene.texture1 = new THREE.Texture(); + this.scriptScene.texture1.setImage(this.scene.assetMgr.SyncLoad('image/Sample1.jpg')); + this.scriptScene.texture2 = new THREE.Texture(); + this.scriptScene.texture2.setImage(this.scene.assetMgr.SyncLoad('image/Sample2.jpg')); + console.log("JSSys: 未获取到纹理,使用默认纹理"); + } + + this.scriptScene.setupScene(); + // 初始化后处理效果 + if (this.scriptScene.initPostProcessing != null) { + this.scriptScene.initPostProcessing(); + } + } + + onUpdate(deltaTime) { + this.time = this.input.getFrameTimestamp(); + // this.time = this.time % 2; + // this.time = this.time / 2.0; + this.scriptScene.seekToTime(this.time * this.scriptScene.Duration); + // this.scriptScene.updateScene(); + } + onLateUpdate(deltaTime) { + // console.log("running:JSSys:onLateUpdate"); + this.scriptScene.scene.seekToTime(this.time * this.scriptScene.Duration); + } + + onEvent(event) { + console.log("running:JSSys:onEvent"); + if (event.type == Amaz.EventType.VIEWER) { + // console.log("JSSys: 窗口大小改变"); + console.log("renderTexture.width",this.renderTexture.width); + console.log("renderTexture.height",this.renderTexture.height); + + window.innerWidth = this.renderTexture.width; + window.innerHeight = this.renderTexture.height; + // console.log("JSSys: 窗口大小改变"); + this.scriptScene.handleResize(); + } + } + + onDestroy() { + // console.log("running:JSSys:onDestroy"); + this.scriptScene.destroy(); + } +} + +exports.JSSys = JSSys; + diff --git a/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/EffectComposer.js b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/EffectComposer.js new file mode 100644 index 0000000000000000000000000000000000000000..e7d8fd7a3f3978d9da1a9bf29af1854806f60014 --- /dev/null +++ b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/EffectComposer.js @@ -0,0 +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{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-6*k)*Math.cos(12*k)};const springStiff=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(18*k)};const dampedOscillation=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(10*k)};const Physics=Object.freeze({SpringSoft:springSoft,SpringStiff:springStiff,DampedOscillation:dampedOscillation});const anticipate=k=>{if(k<=0)return 0;if(k>=1)return 1;const pullback=.1;if(k<.3){const p=k/.3;return-pullback*p*(2-p)}const p=(k-.3)/.7;return-pullback+(1+pullback)*p*p*(3-2*p)};const overshootFactory=peak=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return peak*p*(2-p)}const p=(k-.6)/.4;return peak+(1-peak)*(1-Math.pow(1-p,3))};const overshoot110=overshootFactory(1.1);const overshoot125=overshootFactory(1.25);const snapBack=k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return 1.05*(1-Math.pow(1-p,3))}const p=(k-.6)/.4;return 1.05-.05*p*p*(3-2*p)};const swing=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.cos(1.5*Math.PI*k)*Math.exp(-2.5*k)};const Motion=Object.freeze({Anticipate:anticipate,Overshoot110:overshoot110,Overshoot125:overshoot125,SnapBack:snapBack,Swing:swing});const makeStep=(n,jumpTerm="end")=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(jumpTerm==="start")return Math.ceil(k*n)/n;return Math.floor(k*n)/n};const Step=Object.freeze({Steps4End:makeStep(4,"end"),Steps8End:makeStep(8,"end"),Steps12End:makeStep(12,"end")});function buildCubicBezier(x1,y1,x2,y2){const cx=3*x1,bx=3*(x2-x1)-cx,ax=1-cx-bx;const cy=3*y1,by=3*(y2-y1)-cy,ay=1-cy-by;const sampleX=s=>((ax*s+bx)*s+cx)*s;const sampleY=s=>((ay*s+by)*s+cy)*s;const sampleDX=s=>(3*ax*s+2*bx)*s+cx;const solveS=x=>{let s=x;for(let i=0;i<8;i++){const cur=sampleX(s)-x;if(Math.abs(cur)<1e-6)return s;const d=sampleDX(s);if(Math.abs(d)<1e-6)break;s-=cur/d;if(s<0)s=0;if(s>1)s=1}let lo=0,hi=1;for(let i=0;i<32&&hi-lo>1e-6;i++){const mid=(lo+hi)/2;if(sampleX(mid){if(k<=0)return 0;if(k>=1)return 1;return sampleY(solveS(k))}}const BEZIER_PRESETS=Object.freeze({"Material.Standard":[.4,0,.2,1],"Material.Accelerate":[.4,0,1,1],"Material.Decelerate":[0,0,.2,1],"CSS.Ease":[.25,.1,.25,1]});const _bezierCache=new Map;function _cachedBezier(x1,y1,x2,y2){const key=x1+","+y1+","+x2+","+y2;let fn=_bezierCache.get(key);if(!fn){fn=buildCubicBezier(x1,y1,x2,y2);_bezierCache.set(key,fn)}return fn}function cubicBezier(a,b,c,d){if(typeof a==="string"){let preset=BEZIER_PRESETS[a];if(!preset){console.warn("[customEasings.cubicBezier] unknown preset, falling back to Material.Standard:",a);preset=BEZIER_PRESETS["Material.Standard"]}return _cachedBezier(preset[0],preset[1],preset[2],preset[3])}const clamp=(v,lo,hi)=>Math.max(lo,Math.min(hi,v));const x1=clamp(a,0,1);const y1=clamp(b,-.5,1.5);const x2=clamp(c,0,1);const y2=clamp(d,-.5,1.5);return _cachedBezier(x1,y1,x2,y2)}const libSpring=({stiffness=180,damping=12,mass=1}={})=>{const DT=1/240;const T=1.5;let x=0,v=0;const samples=[];for(let t=0;t<=T;t+=DT){const force=-stiffness*(x-1)-damping*v;v+=force/mass*DT;x+=v*DT;samples.push({t:t,x:x})}let T_end=T;for(let i=samples.length-1;i>=0;i--){if(Math.abs(samples[i].x-1)>.01){T_end=samples[i].t;break}}return k=>{if(k<=0)return 0;if(k>=1)return 1;const t=k*T_end;const idx=Math.min(samples.length-1,Math.floor(t/DT));return samples[idx].x}};const libHeartBeat=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c)=>Math.exp(-((t-c)**2)/(2*.07*.07));return peak*(bell(k,.2)+bell(k,.5))};const libSteps=(n=6)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return Math.floor(k*n)/n};const attentionPing=(peak=.35,decay=2)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(Math.PI*k)*Math.exp(-decay*k)};const attentionWiggle=(count=4,amplitude=.25)=>k=>{if(k<=0||k>=1)return 0;const env=1-k;return amplitude*env*Math.sin(k*Math.PI*2*count)};const attentionStrum=(notes=4,peak=.4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*.05*.05))}return peak*sum}};const Attention=Object.freeze({Ping:attentionPing(),Wiggle:attentionWiggle(),Strum:attentionStrum()});const breathNormal=(cycles=2,peak=.15)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(k*Math.PI*2*cycles)*Math.sin(k*Math.PI)};const breathDeep=(peak=.3,riseRatio=.35,holdRatio=.15)=>{const holdEnd=riseRatio+holdRatio;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const envelope=Math.sin(k*Math.PI);const wave=.5+.5*Math.sin(k*Math.PI*2*cycles-Math.PI/2);return peak*envelope*wave};const breathSigh=(peak=.25,riseRatio=.2)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return peak*Math.exp(-((k-center)**2)/(2*width*width))};const heartExcited=(beats=4,peak=.3,width=.04)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*width*width))}return peak*sum}};const heartLubDub=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return peak*(bell(k,.25,.045)+.6*bell(k,.42,.03))};const Heart=Object.freeze({Calm:heartCalm(),Excited:heartExcited(),LubDub:heartLubDub()});const mathJumpArc=()=>k=>{if(k<=0||k>=1)return 0;return 4*k*(1-k)};const mathPendulum=(damping=3,freq=2.5)=>k=>{if(k<=0||k>=1)return 0;return Math.sin(k*Math.PI)*Math.exp(-damping*k)*Math.cos(freq*Math.PI*k)};const mathTremor=(amplitude=.04,freq=22)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return k+amplitude*Math.sin(k*Math.PI*2*freq)};const mathBoomerang=fn=>k=>{if(k<=0||k>=1)return 0;return k<.5?fn(k*2):fn(2-k*2)};const MathExt=Object.freeze({JumpArc:mathJumpArc(),Pendulum:mathPendulum(),Tremor:mathTremor()});const explosionImpulse=(sharpness=6)=>{const tail=sharpness*Math.exp(1-sharpness);return k=>{if(k<=0||k>=1)return 0;const h=sharpness*k;return h*Math.exp(1-h)-tail*k}};const explosionFlash=(rise=.05,decay=5)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return-Math.exp(-decay*k)*Math.cos(freq*Math.PI*k)};const explosionImplosion=(charge=.3,depth=.4,burstPeak=1.2)=>{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const w=Math.sin(k*Math.PI*2*cycles)+.5*Math.sin(k*Math.PI*2*cycles*1.5+1.2)+.25*Math.sin(k*Math.PI*2*cycles*3+2.4);return amplitude*env*w*.6};const natureFlicker=(rate=15,intensity=.2,seed=7)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=rate+1;i++)samples.push(rand());return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*rate;const idx=Math.floor(pos);const t=pos-idx;const a=samples[idx];const b=samples[idx+1];const interp=a+(b-a)*t;return intensity*env*(interp-.5)*2}};const natureGust=(gusts=3,peak=.25)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*.08*.08))}return peak*sum/gusts*1.8}};const Nature=Object.freeze({Wave:natureWave(),Flicker:natureFlicker(),Gust:natureGust()});const impactRain=(impactAt=.7,rippleAmp=.08)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const liftEnd=.35,strikeEnd=.6;return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return t*t}const t=(k-.4)/.6;const env=Math.exp(-2.5*t);const wave=Math.abs(Math.sin(t*Math.PI*bounces));return 1-env*wave*rebound};const impactSlap=(contactAt=.3,holdRatio=.1)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return.4*Math.pow(t,2.5)}if(k<.48){const t=(k-.4)/.08;return.4-.2*t}if(k<.52){const t=(k-.48)/.04;return.2+.8*t}const t=(k-.52)/.48;return 1-.04*Math.sin(t*Math.PI*8)*(1-t)};const rhythmPunchCombo=(peak=.4)=>{const pattern=[{c:.15,w:.04,a:.75},{c:.35,w:.04,a:.75},{c:.7,w:.055,a:1}];return k=>{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of pattern){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return peak*sum}};const rhythmStaccato=(beats=4,duty=.3)=>k=>{if(k<=0||k>=1)return 0;const beatLen=1/beats;const phase=k/beatLen-Math.floor(k/beatLen);if(phase>duty)return 0;const t=phase/duty;return Math.sin(t*Math.PI)};const rhythmKick=(peak=1.2)=>k=>{if(k<=0||k>=1)return 0;if(k<.05)return peak*k/.05;const t=(k-.05)/.95;return peak*Math.exp(-4*t)};const rhythmCrescendo=(beats=4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return sum}};const rhythmDunDunDun=()=>{const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return k=>{if(k<=0||k>=1)return 0;return.3*bell(k,.15,.025)+.6*bell(k,.35,.03)+1*bell(k,.68,.09)}};const rhythmBellToll=(decay=3,freq=8)=>{const strike=.05;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.2){const t=k/.2;return-pressDepth*Math.sin(t*Math.PI/2)}if(k<.5){const t=(k-.2)/.3;return-pressDepth+(pressDepth+reboundPeak)*(1-Math.pow(1-t,3))}const t=(k-.5)/.5;return reboundPeak*Math.exp(-4*t)*Math.cos(t*Math.PI*3)};const uiHoverBloom=(riseRatio=.2,fallRatio=.3)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=1-k;const raw=Math.sin(k*Math.PI*2*count);const clipped=Math.sign(raw)*Math.min(1,Math.abs(raw)*1.8);return amplitude*env*clipped};const uiSuccessPop=(overshoot=.2)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return(1+overshoot)*(1-Math.pow(1-t,2))}const t=(k-.4)/.6;return 1+overshoot*Math.exp(-5*t)*Math.cos(t*Math.PI*3)};const uiRippleOut=()=>k=>{if(k<=0||k>=1)return 0;return 6.75*k*Math.pow(1-k,2)};const UI=Object.freeze({ClickSnap:uiClickSnap(),HoverBloom:uiHoverBloom(),ErrorShake:uiErrorShake(),SuccessPop:uiSuccessPop(),RippleOut:uiRippleOut()});const magicManaCharge=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;const base=(Math.exp(3*k)-1)/(Math.exp(3)-1);const pulse=.04*Math.sin(k*Math.PI*8)*k;return base+pulse};const magicSpellCast=(chargeEnd=.4)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.45){const t=k/.45;return t*t*t}if(k<.55)return 1;const t=(k-.55)/.45;return Math.pow(1-t,3)};const magicShield=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.3){const t=k/.3;return 1.2*(1-Math.pow(1-t,2))}if(k<.6){const t=(k-.3)/.3;return 1.2-.2*t}const t=(k-.6)/.4;return 1+.03*Math.sin(t*Math.PI*3)};const magicAura=(peak=.15)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const fundamental=.6*Math.sin(k*Math.PI*2);const harmonic=.3*Math.sin(k*Math.PI*4+1);const overtone=.1*Math.sin(k*Math.PI*6+2);return peak*env*(fundamental+harmonic+overtone)};const Magic=Object.freeze({ManaCharge:magicManaCharge(),SpellCast:magicSpellCast(),Teleport:magicTeleport(),Shield:magicShield(),MagicAura:magicAura()});const animalCatPounce=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.2){const t=k/.2;return-.2*Math.sin(t*Math.PI)}if(k<.3){const t=(k-.2)/.1;return.5*t*t}if(k<.8){const t=(k-.3)/.5;return.5+.5*t+.2*Math.sin(t*Math.PI)}const t=(k-.8)/.2;return 1+.05*Math.sin(t*Math.PI)};const animalBirdFlap=(flaps=4)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const phase=k*Math.PI*2*flaps;const wave=Math.sin(phase)-.3*Math.sin(phase*2);return.2*env*wave};const animalSnakeSlither=(waves=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const wave=Math.sin(k*Math.PI*2*waves);return.2*env*wave};const animalButterflyFlit=(seed=13)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=26;i++)samples.push(rand()-.5);return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*25;const idx=Math.floor(pos);const t=pos-idx;const smooth=t*t*(3-2*t);const interp=samples[idx]+(samples[idx+1]-samples[idx])*smooth;return.3*env*interp}};const animalHorseGallop=(cycles=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const cyclePos=k*cycles-Math.floor(k*cycles);const bell=(c,w=.04)=>Math.exp(-((cyclePos-c)**2)/(2*w*w));return.25*env*(bell(0)+bell(.18)+bell(.36)+bell(.54))};const Animal=Object.freeze({CatPounce:animalCatPounce(),BirdFlap:animalBirdFlap(),SnakeSlither:animalSnakeSlither(),ButterflyFlit:animalButterflyFlit(),HorseGallop:animalHorseGallop()});const Progress=Object.freeze({Physics:Object.freeze({...Physics,Spring:libSpring()}),Motion:Motion,Step:Object.freeze({...Step,Steps6:libSteps()}),Math:Object.freeze({Tremor:MathExt.Tremor}),Impact:Object.freeze({Rain:Impact.Rain,Hammer:Impact.Hammer,BounceDrop:Impact.BounceDrop,ArrowHit:Impact.ArrowHit,Shatter:Impact.Shatter}),Rhythm:Object.freeze({BassDrop:Rhythm.BassDrop}),UI:Object.freeze({SuccessPop:UI.SuccessPop}),Magic:Object.freeze({ManaCharge:Magic.ManaCharge,Shield:Magic.Shield}),Animal:Object.freeze({CatPounce:Animal.CatPounce})});const Pulse=Object.freeze({Attention:Object.freeze({Ping:Attention.Ping}),Breath:Object.freeze({Deep:Breath.Deep,Sigh:Breath.Sigh}),Heart:Object.freeze({Calm:Heart.Calm}),Math:Object.freeze({JumpArc:MathExt.JumpArc,BoomerangSharp:mathBoomerang(E.Cubic.In),BoomerangSoft:mathBoomerang(E.Cubic.Out)}),Explosion:Object.freeze({Impulse:Explosion.Impulse,Flash:Explosion.Flash,Recoil:Explosion.Recoil,Implosion:Explosion.Implosion}),Impact:Object.freeze({Slap:Impact.Slap}),Rhythm:Object.freeze({Kick:Rhythm.Kick}),UI:Object.freeze({ClickSnap:UI.ClickSnap,HoverBloom:UI.HoverBloom,RippleOut:UI.RippleOut}),Magic:Object.freeze({SpellCast:Magic.SpellCast,Teleport:Magic.Teleport})});const Wave=Object.freeze({Attention:Object.freeze({Wiggle:Attention.Wiggle,Strum:Attention.Strum}),Breath:Object.freeze({Normal:Breath.Normal,Panting:Breath.Panting}),Heart:Object.freeze({Excited:Heart.Excited,LubDub:Heart.LubDub,Beat:libHeartBeat()}),Math:Object.freeze({Pendulum:MathExt.Pendulum}),Nature:Nature,Rhythm:Object.freeze({PunchCombo:Rhythm.PunchCombo,Staccato:Rhythm.Staccato,Crescendo:Rhythm.Crescendo,DunDunDun:Rhythm.DunDunDun,BellToll:Rhythm.BellToll}),UI:Object.freeze({ErrorShake:UI.ErrorShake}),Magic:Object.freeze({MagicAura:Magic.MagicAura}),Animal:Object.freeze({BirdFlap:Animal.BirdFlap,SnakeSlither:Animal.SnakeSlither,ButterflyFlit:Animal.ButterflyFlit,HorseGallop:Animal.HorseGallop})});const customEasings=Object.freeze({makeOutIn:makeOutIn,OutIn:OutIn,Progress:Progress,Pulse:Pulse,Wave:Wave,cubicBezier:cubicBezier});exports.customEasings=customEasings;exports.default=customEasings; \ No newline at end of file diff --git a/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/scriptScene.js b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/scriptScene.js new file mode 100644 index 0000000000000000000000000000000000000000..5d5f0a8bde54f7efa0912b77bb0a8298e3fb04e9 --- /dev/null +++ b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/scriptScene.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/three-amg-wrapper.js b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/three-amg-wrapper.js new file mode 100644 index 0000000000000000000000000000000000000000..c2037e314e032c4d36912923d4cc1258cba3ab19 --- /dev/null +++ b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/three-amg-wrapper.js @@ -0,0 +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;iobj.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; \ No newline at end of file diff --git a/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/tween.js b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/tween.js new file mode 100644 index 0000000000000000000000000000000000000000..690fb9e4284728629129deed5a5a3f4bcec291ed --- /dev/null +++ b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/tween.js @@ -0,0 +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=power1e4?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;_i0){this._tweensAddedDuringUpdate={};for(var i=0;i1){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[m1;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;itotalTime){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;ithis.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;ithis.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.xthis.max.x||box.max.ythis.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; \ No newline at end of file diff --git a/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Box3.js b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Box3.js new file mode 100644 index 0000000000000000000000000000000000000000..4100dc7442d3a622827c8a415e24557f68c491f1 --- /dev/null +++ b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Box3.js @@ -0,0 +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=3?array[offset+2]:0;if(xthis.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=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.xthis.max.x||box.max.ythis.max.y||box.max.zthis.max.z)}}exports.Box3=Box3; \ No newline at end of file diff --git a/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..be3b8b1334a62f5e88c45feee098063a199fca55 --- /dev/null +++ b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js @@ -0,0 +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=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; \ No newline at end of file diff --git a/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..af9a8a13a46500e78f082a35e18d0b5932061234 --- /dev/null +++ b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js @@ -0,0 +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;iObject.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;i1?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; \ No newline at end of file diff --git a/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Constants.js b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Constants.js new file mode 100644 index 0000000000000000000000000000000000000000..6b8adda19a4d67236719804f5170889b39fd4582 --- /dev/null +++ b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Constants.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js new file mode 100644 index 0000000000000000000000000000000000000000..29b0aad5599401be17f967ba1d48851acb70c2ac --- /dev/null +++ b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js @@ -0,0 +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;i0||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;i0?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;imaxX)maxX=p.x;if(p.ymaxY)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; \ No newline at end of file diff --git a/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..f3dee08bf1c089e040fcfef228902ab9a39c93cb --- /dev/null +++ b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Earcut.js b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Earcut.js new file mode 100644 index 0000000000000000000000000000000000000000..953abffdf38c2def26df73fed180eff8c7644ced --- /dev/null +++ b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Earcut.js @@ -0,0 +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;imaxX)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=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=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.x&&p.x>=mx&&hx!==p.x&&pointInTriangle(hym.x||p.x===m.x&§orContainsSector(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.xb.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;i0||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=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;i0){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;imaxX)maxX=contour[i].x;if(contour[i].ymaxY)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;layerIdx0?-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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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; \ No newline at end of file diff --git a/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Group.js b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Group.js new file mode 100644 index 0000000000000000000000000000000000000000..90c4dbef65aa04d7a3bb6b6d76ec3317ea65a228 --- /dev/null +++ b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Group.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");class Group extends Object3D{constructor(name="Group_w"){super(name)}dispose(){super.dispose()}}exports.Group=Group; \ No newline at end of file diff --git a/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Material.js b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Material.js new file mode 100644 index 0000000000000000000000000000000000000000..81b97053ad9d1e4b1ef05d5ac6ed992487b2ca8e --- /dev/null +++ b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Material.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..dcf34d4cffb9de0869382a24690f78f60dda6049 --- /dev/null +++ b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js new file mode 100644 index 0000000000000000000000000000000000000000..41e6cd0a0eee7dd7bc497be5deac584806b68dc3 --- /dev/null +++ b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Mesh.js b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Mesh.js new file mode 100644 index 0000000000000000000000000000000000000000..254d69b074e797dd34c16d7dad723bbcc3b4895d --- /dev/null +++ b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Mesh.js @@ -0,0 +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;imaterial,set:value=>{material=value;if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;im.dispose&&m.dispose());else if(this.material.dispose)this.material.dispose()}}}exports.MeshWrapper=MeshWrapper; \ No newline at end of file diff --git a/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..ac394f66efc4e113a7127ee0f50ec672e4c5e9eb --- /dev/null +++ b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Object3D.js b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Object3D.js new file mode 100644 index 0000000000000000000000000000000000000000..8532c6122f839460aab34fe88957802ff523318b --- /dev/null +++ b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Object3D.js @@ -0,0 +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{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&¤tScene._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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js new file mode 100644 index 0000000000000000000000000000000000000000..ba39801de50d38ec04424f3c2ebfa2ff5d28fded --- /dev/null +++ b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js @@ -0,0 +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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..bc595fb80ad9e7c2f4d8360c67dbef556f3d6cbe --- /dev/null +++ b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js @@ -0,0 +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;iy0){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; \ No newline at end of file diff --git a/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..02dc1be955bc766de744222a7e75c65bf147bb61 --- /dev/null +++ b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js @@ -0,0 +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&¶meters.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{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=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=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=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; \ No newline at end of file diff --git a/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Shape.js b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Shape.js new file mode 100644 index 0000000000000000000000000000000000000000..ecde48b5ceb30812c922aa5c7cfe2aa7b50cabe4 --- /dev/null +++ b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Shape.js @@ -0,0 +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;i0){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;i0||(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;imaxX)maxX=p.x;if(p.ymaxY)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;i0?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;ipoints.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;itwoPi)deltaAngle-=twoPi;if(deltaAngle>4;uuid[i]=chars[i===19?r&3|8:r]}}return uuid.join("")}exports.Shape=Shape; \ No newline at end of file diff --git a/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..3786abc7d64ed80b56101c4ac9d30ce9fcb8f941 --- /dev/null +++ b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js @@ -0,0 +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;i0){const bounds=calculateBounds(flatVertices);const vertexOffset=vertices.length/3;for(let j=0;j0){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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}function calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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; \ No newline at end of file diff --git a/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..1ea27a55fbce9fc3771c66840c068e5ff6347092 --- /dev/null +++ b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Texture.js b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Texture.js new file mode 100644 index 0000000000000000000000000000000000000000..35bff49d732c9884e07bfcb5682f18a860485e1f --- /dev/null +++ b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Texture.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Vector2.js b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Vector2.js new file mode 100644 index 0000000000000000000000000000000000000000..a30a2431264ee62cec937714dfa9e50932ddedeb --- /dev/null +++ b/scripts/7681530401944390928/AmazingFeature/js/ThreeJS/wrapper/Vector2.js @@ -0,0 +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)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)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){if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-6*k)*Math.cos(12*k)};const springStiff=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(18*k)};const dampedOscillation=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(10*k)};const Physics=Object.freeze({SpringSoft:springSoft,SpringStiff:springStiff,DampedOscillation:dampedOscillation});const anticipate=k=>{if(k<=0)return 0;if(k>=1)return 1;const pullback=.1;if(k<.3){const p=k/.3;return-pullback*p*(2-p)}const p=(k-.3)/.7;return-pullback+(1+pullback)*p*p*(3-2*p)};const overshootFactory=peak=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return peak*p*(2-p)}const p=(k-.6)/.4;return peak+(1-peak)*(1-Math.pow(1-p,3))};const overshoot110=overshootFactory(1.1);const overshoot125=overshootFactory(1.25);const snapBack=k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return 1.05*(1-Math.pow(1-p,3))}const p=(k-.6)/.4;return 1.05-.05*p*p*(3-2*p)};const swing=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.cos(1.5*Math.PI*k)*Math.exp(-2.5*k)};const Motion=Object.freeze({Anticipate:anticipate,Overshoot110:overshoot110,Overshoot125:overshoot125,SnapBack:snapBack,Swing:swing});const makeStep=(n,jumpTerm="end")=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(jumpTerm==="start")return Math.ceil(k*n)/n;return Math.floor(k*n)/n};const Step=Object.freeze({Steps4End:makeStep(4,"end"),Steps8End:makeStep(8,"end"),Steps12End:makeStep(12,"end")});function buildCubicBezier(x1,y1,x2,y2){const cx=3*x1,bx=3*(x2-x1)-cx,ax=1-cx-bx;const cy=3*y1,by=3*(y2-y1)-cy,ay=1-cy-by;const sampleX=s=>((ax*s+bx)*s+cx)*s;const sampleY=s=>((ay*s+by)*s+cy)*s;const sampleDX=s=>(3*ax*s+2*bx)*s+cx;const solveS=x=>{let s=x;for(let i=0;i<8;i++){const cur=sampleX(s)-x;if(Math.abs(cur)<1e-6)return s;const d=sampleDX(s);if(Math.abs(d)<1e-6)break;s-=cur/d;if(s<0)s=0;if(s>1)s=1}let lo=0,hi=1;for(let i=0;i<32&&hi-lo>1e-6;i++){const mid=(lo+hi)/2;if(sampleX(mid){if(k<=0)return 0;if(k>=1)return 1;return sampleY(solveS(k))}}const BEZIER_PRESETS=Object.freeze({"Material.Standard":[.4,0,.2,1],"Material.Accelerate":[.4,0,1,1],"Material.Decelerate":[0,0,.2,1],"CSS.Ease":[.25,.1,.25,1]});const _bezierCache=new Map;function _cachedBezier(x1,y1,x2,y2){const key=x1+","+y1+","+x2+","+y2;let fn=_bezierCache.get(key);if(!fn){fn=buildCubicBezier(x1,y1,x2,y2);_bezierCache.set(key,fn)}return fn}function cubicBezier(a,b,c,d){if(typeof a==="string"){let preset=BEZIER_PRESETS[a];if(!preset){console.warn("[customEasings.cubicBezier] unknown preset, falling back to Material.Standard:",a);preset=BEZIER_PRESETS["Material.Standard"]}return _cachedBezier(preset[0],preset[1],preset[2],preset[3])}const clamp=(v,lo,hi)=>Math.max(lo,Math.min(hi,v));const x1=clamp(a,0,1);const y1=clamp(b,-.5,1.5);const x2=clamp(c,0,1);const y2=clamp(d,-.5,1.5);return _cachedBezier(x1,y1,x2,y2)}const libSpring=({stiffness=180,damping=12,mass=1}={})=>{const DT=1/240;const T=1.5;let x=0,v=0;const samples=[];for(let t=0;t<=T;t+=DT){const force=-stiffness*(x-1)-damping*v;v+=force/mass*DT;x+=v*DT;samples.push({t:t,x:x})}let T_end=T;for(let i=samples.length-1;i>=0;i--){if(Math.abs(samples[i].x-1)>.01){T_end=samples[i].t;break}}return k=>{if(k<=0)return 0;if(k>=1)return 1;const t=k*T_end;const idx=Math.min(samples.length-1,Math.floor(t/DT));return samples[idx].x}};const libHeartBeat=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c)=>Math.exp(-((t-c)**2)/(2*.07*.07));return peak*(bell(k,.2)+bell(k,.5))};const libSteps=(n=6)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return Math.floor(k*n)/n};const attentionPing=(peak=.35,decay=2)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(Math.PI*k)*Math.exp(-decay*k)};const attentionWiggle=(count=4,amplitude=.25)=>k=>{if(k<=0||k>=1)return 0;const env=1-k;return amplitude*env*Math.sin(k*Math.PI*2*count)};const attentionStrum=(notes=4,peak=.4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*.05*.05))}return peak*sum}};const Attention=Object.freeze({Ping:attentionPing(),Wiggle:attentionWiggle(),Strum:attentionStrum()});const breathNormal=(cycles=2,peak=.15)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(k*Math.PI*2*cycles)*Math.sin(k*Math.PI)};const breathDeep=(peak=.3,riseRatio=.35,holdRatio=.15)=>{const holdEnd=riseRatio+holdRatio;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const envelope=Math.sin(k*Math.PI);const wave=.5+.5*Math.sin(k*Math.PI*2*cycles-Math.PI/2);return peak*envelope*wave};const breathSigh=(peak=.25,riseRatio=.2)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return peak*Math.exp(-((k-center)**2)/(2*width*width))};const heartExcited=(beats=4,peak=.3,width=.04)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*width*width))}return peak*sum}};const heartLubDub=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return peak*(bell(k,.25,.045)+.6*bell(k,.42,.03))};const Heart=Object.freeze({Calm:heartCalm(),Excited:heartExcited(),LubDub:heartLubDub()});const mathJumpArc=()=>k=>{if(k<=0||k>=1)return 0;return 4*k*(1-k)};const mathPendulum=(damping=3,freq=2.5)=>k=>{if(k<=0||k>=1)return 0;return Math.sin(k*Math.PI)*Math.exp(-damping*k)*Math.cos(freq*Math.PI*k)};const mathTremor=(amplitude=.04,freq=22)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return k+amplitude*Math.sin(k*Math.PI*2*freq)};const mathBoomerang=fn=>k=>{if(k<=0||k>=1)return 0;return k<.5?fn(k*2):fn(2-k*2)};const MathExt=Object.freeze({JumpArc:mathJumpArc(),Pendulum:mathPendulum(),Tremor:mathTremor()});const explosionImpulse=(sharpness=6)=>{const tail=sharpness*Math.exp(1-sharpness);return k=>{if(k<=0||k>=1)return 0;const h=sharpness*k;return h*Math.exp(1-h)-tail*k}};const explosionFlash=(rise=.05,decay=5)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return-Math.exp(-decay*k)*Math.cos(freq*Math.PI*k)};const explosionImplosion=(charge=.3,depth=.4,burstPeak=1.2)=>{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const w=Math.sin(k*Math.PI*2*cycles)+.5*Math.sin(k*Math.PI*2*cycles*1.5+1.2)+.25*Math.sin(k*Math.PI*2*cycles*3+2.4);return amplitude*env*w*.6};const natureFlicker=(rate=15,intensity=.2,seed=7)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=rate+1;i++)samples.push(rand());return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*rate;const idx=Math.floor(pos);const t=pos-idx;const a=samples[idx];const b=samples[idx+1];const interp=a+(b-a)*t;return intensity*env*(interp-.5)*2}};const natureGust=(gusts=3,peak=.25)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*.08*.08))}return peak*sum/gusts*1.8}};const Nature=Object.freeze({Wave:natureWave(),Flicker:natureFlicker(),Gust:natureGust()});const impactRain=(impactAt=.7,rippleAmp=.08)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const liftEnd=.35,strikeEnd=.6;return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return t*t}const t=(k-.4)/.6;const env=Math.exp(-2.5*t);const wave=Math.abs(Math.sin(t*Math.PI*bounces));return 1-env*wave*rebound};const impactSlap=(contactAt=.3,holdRatio=.1)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return.4*Math.pow(t,2.5)}if(k<.48){const t=(k-.4)/.08;return.4-.2*t}if(k<.52){const t=(k-.48)/.04;return.2+.8*t}const t=(k-.52)/.48;return 1-.04*Math.sin(t*Math.PI*8)*(1-t)};const rhythmPunchCombo=(peak=.4)=>{const pattern=[{c:.15,w:.04,a:.75},{c:.35,w:.04,a:.75},{c:.7,w:.055,a:1}];return k=>{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of pattern){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return peak*sum}};const rhythmStaccato=(beats=4,duty=.3)=>k=>{if(k<=0||k>=1)return 0;const beatLen=1/beats;const phase=k/beatLen-Math.floor(k/beatLen);if(phase>duty)return 0;const t=phase/duty;return Math.sin(t*Math.PI)};const rhythmKick=(peak=1.2)=>k=>{if(k<=0||k>=1)return 0;if(k<.05)return peak*k/.05;const t=(k-.05)/.95;return peak*Math.exp(-4*t)};const rhythmCrescendo=(beats=4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return sum}};const rhythmDunDunDun=()=>{const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return k=>{if(k<=0||k>=1)return 0;return.3*bell(k,.15,.025)+.6*bell(k,.35,.03)+1*bell(k,.68,.09)}};const rhythmBellToll=(decay=3,freq=8)=>{const strike=.05;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.2){const t=k/.2;return-pressDepth*Math.sin(t*Math.PI/2)}if(k<.5){const t=(k-.2)/.3;return-pressDepth+(pressDepth+reboundPeak)*(1-Math.pow(1-t,3))}const t=(k-.5)/.5;return reboundPeak*Math.exp(-4*t)*Math.cos(t*Math.PI*3)};const uiHoverBloom=(riseRatio=.2,fallRatio=.3)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=1-k;const raw=Math.sin(k*Math.PI*2*count);const clipped=Math.sign(raw)*Math.min(1,Math.abs(raw)*1.8);return amplitude*env*clipped};const uiSuccessPop=(overshoot=.2)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return(1+overshoot)*(1-Math.pow(1-t,2))}const t=(k-.4)/.6;return 1+overshoot*Math.exp(-5*t)*Math.cos(t*Math.PI*3)};const uiRippleOut=()=>k=>{if(k<=0||k>=1)return 0;return 6.75*k*Math.pow(1-k,2)};const UI=Object.freeze({ClickSnap:uiClickSnap(),HoverBloom:uiHoverBloom(),ErrorShake:uiErrorShake(),SuccessPop:uiSuccessPop(),RippleOut:uiRippleOut()});const magicManaCharge=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;const base=(Math.exp(3*k)-1)/(Math.exp(3)-1);const pulse=.04*Math.sin(k*Math.PI*8)*k;return base+pulse};const magicSpellCast=(chargeEnd=.4)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.45){const t=k/.45;return t*t*t}if(k<.55)return 1;const t=(k-.55)/.45;return Math.pow(1-t,3)};const magicShield=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.3){const t=k/.3;return 1.2*(1-Math.pow(1-t,2))}if(k<.6){const t=(k-.3)/.3;return 1.2-.2*t}const t=(k-.6)/.4;return 1+.03*Math.sin(t*Math.PI*3)};const magicAura=(peak=.15)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const fundamental=.6*Math.sin(k*Math.PI*2);const harmonic=.3*Math.sin(k*Math.PI*4+1);const overtone=.1*Math.sin(k*Math.PI*6+2);return peak*env*(fundamental+harmonic+overtone)};const Magic=Object.freeze({ManaCharge:magicManaCharge(),SpellCast:magicSpellCast(),Teleport:magicTeleport(),Shield:magicShield(),MagicAura:magicAura()});const animalCatPounce=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.2){const t=k/.2;return-.2*Math.sin(t*Math.PI)}if(k<.3){const t=(k-.2)/.1;return.5*t*t}if(k<.8){const t=(k-.3)/.5;return.5+.5*t+.2*Math.sin(t*Math.PI)}const t=(k-.8)/.2;return 1+.05*Math.sin(t*Math.PI)};const animalBirdFlap=(flaps=4)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const phase=k*Math.PI*2*flaps;const wave=Math.sin(phase)-.3*Math.sin(phase*2);return.2*env*wave};const animalSnakeSlither=(waves=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const wave=Math.sin(k*Math.PI*2*waves);return.2*env*wave};const animalButterflyFlit=(seed=13)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=26;i++)samples.push(rand()-.5);return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*25;const idx=Math.floor(pos);const t=pos-idx;const smooth=t*t*(3-2*t);const interp=samples[idx]+(samples[idx+1]-samples[idx])*smooth;return.3*env*interp}};const animalHorseGallop=(cycles=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const cyclePos=k*cycles-Math.floor(k*cycles);const bell=(c,w=.04)=>Math.exp(-((cyclePos-c)**2)/(2*w*w));return.25*env*(bell(0)+bell(.18)+bell(.36)+bell(.54))};const Animal=Object.freeze({CatPounce:animalCatPounce(),BirdFlap:animalBirdFlap(),SnakeSlither:animalSnakeSlither(),ButterflyFlit:animalButterflyFlit(),HorseGallop:animalHorseGallop()});const Progress=Object.freeze({Physics:Object.freeze({...Physics,Spring:libSpring()}),Motion:Motion,Step:Object.freeze({...Step,Steps6:libSteps()}),Math:Object.freeze({Tremor:MathExt.Tremor}),Impact:Object.freeze({Rain:Impact.Rain,Hammer:Impact.Hammer,BounceDrop:Impact.BounceDrop,ArrowHit:Impact.ArrowHit,Shatter:Impact.Shatter}),Rhythm:Object.freeze({BassDrop:Rhythm.BassDrop}),UI:Object.freeze({SuccessPop:UI.SuccessPop}),Magic:Object.freeze({ManaCharge:Magic.ManaCharge,Shield:Magic.Shield}),Animal:Object.freeze({CatPounce:Animal.CatPounce})});const Pulse=Object.freeze({Attention:Object.freeze({Ping:Attention.Ping}),Breath:Object.freeze({Deep:Breath.Deep,Sigh:Breath.Sigh}),Heart:Object.freeze({Calm:Heart.Calm}),Math:Object.freeze({JumpArc:MathExt.JumpArc,BoomerangSharp:mathBoomerang(E.Cubic.In),BoomerangSoft:mathBoomerang(E.Cubic.Out)}),Explosion:Object.freeze({Impulse:Explosion.Impulse,Flash:Explosion.Flash,Recoil:Explosion.Recoil,Implosion:Explosion.Implosion}),Impact:Object.freeze({Slap:Impact.Slap}),Rhythm:Object.freeze({Kick:Rhythm.Kick}),UI:Object.freeze({ClickSnap:UI.ClickSnap,HoverBloom:UI.HoverBloom,RippleOut:UI.RippleOut}),Magic:Object.freeze({SpellCast:Magic.SpellCast,Teleport:Magic.Teleport})});const Wave=Object.freeze({Attention:Object.freeze({Wiggle:Attention.Wiggle,Strum:Attention.Strum}),Breath:Object.freeze({Normal:Breath.Normal,Panting:Breath.Panting}),Heart:Object.freeze({Excited:Heart.Excited,LubDub:Heart.LubDub,Beat:libHeartBeat()}),Math:Object.freeze({Pendulum:MathExt.Pendulum}),Nature:Nature,Rhythm:Object.freeze({PunchCombo:Rhythm.PunchCombo,Staccato:Rhythm.Staccato,Crescendo:Rhythm.Crescendo,DunDunDun:Rhythm.DunDunDun,BellToll:Rhythm.BellToll}),UI:Object.freeze({ErrorShake:UI.ErrorShake}),Magic:Object.freeze({MagicAura:Magic.MagicAura}),Animal:Object.freeze({BirdFlap:Animal.BirdFlap,SnakeSlither:Animal.SnakeSlither,ButterflyFlit:Animal.ButterflyFlit,HorseGallop:Animal.HorseGallop})});const customEasings=Object.freeze({makeOutIn:makeOutIn,OutIn:OutIn,Progress:Progress,Pulse:Pulse,Wave:Wave,cubicBezier:cubicBezier});exports.customEasings=customEasings;exports.default=customEasings; \ No newline at end of file diff --git a/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/scriptScene.js b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/scriptScene.js new file mode 100644 index 0000000000000000000000000000000000000000..5d5f0a8bde54f7efa0912b77bb0a8298e3fb04e9 --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/scriptScene.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/three-amg-wrapper.js b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/three-amg-wrapper.js new file mode 100644 index 0000000000000000000000000000000000000000..c2037e314e032c4d36912923d4cc1258cba3ab19 --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/three-amg-wrapper.js @@ -0,0 +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;iobj.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; \ No newline at end of file diff --git a/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/tween.js b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/tween.js new file mode 100644 index 0000000000000000000000000000000000000000..690fb9e4284728629129deed5a5a3f4bcec291ed --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/tween.js @@ -0,0 +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=power1e4?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;_i0){this._tweensAddedDuringUpdate={};for(var i=0;i1){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[m1;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;itotalTime){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;ithis.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;ithis.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.xthis.max.x||box.max.ythis.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; \ No newline at end of file diff --git a/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Box3.js b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Box3.js new file mode 100644 index 0000000000000000000000000000000000000000..4100dc7442d3a622827c8a415e24557f68c491f1 --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Box3.js @@ -0,0 +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=3?array[offset+2]:0;if(xthis.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=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.xthis.max.x||box.max.ythis.max.y||box.max.zthis.max.z)}}exports.Box3=Box3; \ No newline at end of file diff --git a/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..be3b8b1334a62f5e88c45feee098063a199fca55 --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js @@ -0,0 +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=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; \ No newline at end of file diff --git a/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..af9a8a13a46500e78f082a35e18d0b5932061234 --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js @@ -0,0 +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;iObject.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;i1?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; \ No newline at end of file diff --git a/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Constants.js b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Constants.js new file mode 100644 index 0000000000000000000000000000000000000000..6b8adda19a4d67236719804f5170889b39fd4582 --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Constants.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js new file mode 100644 index 0000000000000000000000000000000000000000..29b0aad5599401be17f967ba1d48851acb70c2ac --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js @@ -0,0 +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;i0||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;i0?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;imaxX)maxX=p.x;if(p.ymaxY)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; \ No newline at end of file diff --git a/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..f3dee08bf1c089e040fcfef228902ab9a39c93cb --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Earcut.js b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Earcut.js new file mode 100644 index 0000000000000000000000000000000000000000..953abffdf38c2def26df73fed180eff8c7644ced --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Earcut.js @@ -0,0 +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;imaxX)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=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=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.x&&p.x>=mx&&hx!==p.x&&pointInTriangle(hym.x||p.x===m.x&§orContainsSector(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.xb.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;i0||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=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;i0){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;imaxX)maxX=contour[i].x;if(contour[i].ymaxY)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;layerIdx0?-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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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; \ No newline at end of file diff --git a/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Group.js b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Group.js new file mode 100644 index 0000000000000000000000000000000000000000..90c4dbef65aa04d7a3bb6b6d76ec3317ea65a228 --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Group.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");class Group extends Object3D{constructor(name="Group_w"){super(name)}dispose(){super.dispose()}}exports.Group=Group; \ No newline at end of file diff --git a/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Material.js b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Material.js new file mode 100644 index 0000000000000000000000000000000000000000..81b97053ad9d1e4b1ef05d5ac6ed992487b2ca8e --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Material.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..dcf34d4cffb9de0869382a24690f78f60dda6049 --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js new file mode 100644 index 0000000000000000000000000000000000000000..41e6cd0a0eee7dd7bc497be5deac584806b68dc3 --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Mesh.js b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Mesh.js new file mode 100644 index 0000000000000000000000000000000000000000..254d69b074e797dd34c16d7dad723bbcc3b4895d --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Mesh.js @@ -0,0 +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;imaterial,set:value=>{material=value;if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;im.dispose&&m.dispose());else if(this.material.dispose)this.material.dispose()}}}exports.MeshWrapper=MeshWrapper; \ No newline at end of file diff --git a/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..ac394f66efc4e113a7127ee0f50ec672e4c5e9eb --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Object3D.js b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Object3D.js new file mode 100644 index 0000000000000000000000000000000000000000..8532c6122f839460aab34fe88957802ff523318b --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Object3D.js @@ -0,0 +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{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&¤tScene._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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js new file mode 100644 index 0000000000000000000000000000000000000000..ba39801de50d38ec04424f3c2ebfa2ff5d28fded --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js @@ -0,0 +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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..bc595fb80ad9e7c2f4d8360c67dbef556f3d6cbe --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js @@ -0,0 +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;iy0){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; \ No newline at end of file diff --git a/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..02dc1be955bc766de744222a7e75c65bf147bb61 --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js @@ -0,0 +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&¶meters.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{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=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=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=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; \ No newline at end of file diff --git a/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Shape.js b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Shape.js new file mode 100644 index 0000000000000000000000000000000000000000..ecde48b5ceb30812c922aa5c7cfe2aa7b50cabe4 --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Shape.js @@ -0,0 +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;i0){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;i0||(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;imaxX)maxX=p.x;if(p.ymaxY)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;i0?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;ipoints.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;itwoPi)deltaAngle-=twoPi;if(deltaAngle>4;uuid[i]=chars[i===19?r&3|8:r]}}return uuid.join("")}exports.Shape=Shape; \ No newline at end of file diff --git a/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..3786abc7d64ed80b56101c4ac9d30ce9fcb8f941 --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js @@ -0,0 +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;i0){const bounds=calculateBounds(flatVertices);const vertexOffset=vertices.length/3;for(let j=0;j0){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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}function calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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; \ No newline at end of file diff --git a/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..1ea27a55fbce9fc3771c66840c068e5ff6347092 --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Texture.js b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Texture.js new file mode 100644 index 0000000000000000000000000000000000000000..35bff49d732c9884e07bfcb5682f18a860485e1f --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Texture.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Vector2.js b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Vector2.js new file mode 100644 index 0000000000000000000000000000000000000000..a30a2431264ee62cec937714dfa9e50932ddedeb --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/js/ThreeJS/wrapper/Vector2.js @@ -0,0 +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)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)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)= 1.0) return texel2; + + const float PI = 3.141592653589793; + const float TWO_PI = 6.283185307179586; + + vec2 p = vUv * 2.0 - 1.0; + p.x *= ratio; + + float r = length(p); + float maxR = length(vec2(max(ratio, 1.0), 1.0)); + float rNorm = clamp(r / maxR, 0.0, 1.0); + + float ang = atan(p.y, p.x); + float spiral = 0.5 + 0.5 * sin(ang * wedgeCount + rNorm * spiralTurns * TWO_PI); + + float field = clamp(rNorm + (spiral - 0.5) * diveStrength, 0.0, 1.0); + float reveal = smoothstep(field - edgeSoftness, field + edgeSoftness, progress); + + float bRecover = mix(0.82, 1.0, smoothstep(0.70, 1.0, progress)); + vec4 texel2Adjusted = vec4(clamp(texel2.rgb * bRecover, 0.0, 1.0), texel2.a); + + return mix(texel1, texel2Adjusted, reveal); +} + +void main() { + // Get the pixel color from both textures + vec4 texel1 = texture2D(tDiffuse, vUv); + vec4 texel2 = texture2D(tDiffuse1, vUv); + + // --- Transition Configuration --- + const float fadeInEnd = 0.1; + const float fadeOutStart = 0.9; + + // 1. Calculate the transition's own progress. + float transitionProgress = clamp((progress - fadeInEnd) / (fadeOutStart - fadeInEnd), 0.0, 1.0); + vec4 transitionColor = transition(texel1, texel2, transitionProgress); + + // 2. Calculate smooth blending factors for the start and end zones. + float blendInFactor = smoothstep(0.0, fadeInEnd, progress); + float blendOutFactor = smoothstep(fadeOutStart, 1.0, progress); + + // 3. Apply the blending. + vec4 finalColor = mix(texel1, transitionColor, blendInFactor); + finalColor = mix(finalColor, texel2, blendOutFactor); + + gl_FragColor = finalColor; +} +//===end_frag_code=== +`; \ No newline at end of file diff --git a/scripts/7681541997026479377/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js b/scripts/7681541997026479377/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js new file mode 100644 index 0000000000000000000000000000000000000000..2c87ab8ca97aecc86f650141dcf51ecc1ee7f46e --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js @@ -0,0 +1,8 @@ +exports.source=` +varying vec2 vUv; + +void main() { + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); +} +`; \ No newline at end of file diff --git a/scripts/7681541997026479377/AmazingFeature/xshader/Unlit.frag b/scripts/7681541997026479377/AmazingFeature/xshader/Unlit.frag new file mode 100644 index 0000000000000000000000000000000000000000..2b8ef6c235afd5362d14d87961e5b7fa2fe044b1 --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/xshader/Unlit.frag @@ -0,0 +1,25 @@ +precision highp float; +uniform sampler2D u_AlbedoTexture; +uniform vec4 u_AlbedoColor; +uniform vec2 u_Repeat; +uniform vec2 u_Offset; +uniform float u_Translucency; +uniform float u_Opacity; +varying vec2 g_vary_uv0; +void main () +{ + vec2 uv_1; + uv_1.x = g_vary_uv0.x; + uv_1.y = (g_vary_uv0.y); + lowp vec4 tmpvar_2; + tmpvar_2 = texture2D (u_AlbedoTexture, (uv_1 * u_Repeat + u_Offset)); + lowp vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2.xyz * u_AlbedoColor.xyz); + lowp float tmpvar_4; + tmpvar_4 = (tmpvar_2.w * u_Translucency); + mediump vec4 tmpvar_5; + tmpvar_5.xyz = tmpvar_3; + tmpvar_5.w = tmpvar_4; + gl_FragColor = vec4(tmpvar_5.xyz * u_Opacity, tmpvar_5.w * u_Opacity); +} + diff --git a/scripts/7681541997026479377/AmazingFeature/xshader/Unlit.vert b/scripts/7681541997026479377/AmazingFeature/xshader/Unlit.vert new file mode 100644 index 0000000000000000000000000000000000000000..64a27d816e6146a0fb85643a9991207e5fda2acb --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/xshader/Unlit.vert @@ -0,0 +1,35 @@ +precision highp float; +attribute vec3 attPosition; +attribute vec2 attTexcoord0; + +//#define AMAZING_USE_BONES + +#ifdef AMAZING_USE_BONES +attribute vec4 attBoneIds; +attribute vec4 attWeights; +const int MAX_BONES = 50; +uniform mat4 u_Palatte[MAX_BONES]; +#endif + +uniform mat4 u_Model; +uniform mat4 u_MVP; +varying vec2 g_vary_uv0; + + + +void main () +{ + vec3 modelPostiton = attPosition; + vec4 homogeneous_pos = vec4(attPosition, 1.0); + g_vary_uv0 = attTexcoord0; + +#ifdef AMAZING_USE_BONES + mat4 boneTransform = u_Palatte[int(attBoneIds.x)] * attWeights.x; + boneTransform += u_Palatte[int(attBoneIds.y)] * attWeights.y; + boneTransform += u_Palatte[int(attBoneIds.z)] * attWeights.z; + boneTransform += u_Palatte[int(attBoneIds.w)] * attWeights.w; + gl_Position = u_MVP * boneTransform * homogeneous_pos; +#else + gl_Position = u_MVP * homogeneous_pos; +#endif +} diff --git a/scripts/7681541997026479377/AmazingFeature/xshader/noface.frag b/scripts/7681541997026479377/AmazingFeature/xshader/noface.frag new file mode 100644 index 0000000000000000000000000000000000000000..88e9ec343761b2395bae9430e6e55466b0367d67 --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/xshader/noface.frag @@ -0,0 +1,7 @@ +precision lowp float; +varying highp vec2 uv0; +uniform sampler2D u_albedo; +void main() +{ + gl_FragColor = texture2D(u_albedo, uv0); +} diff --git a/scripts/7681541997026479377/AmazingFeature/xshader/noface.vert b/scripts/7681541997026479377/AmazingFeature/xshader/noface.vert new file mode 100644 index 0000000000000000000000000000000000000000..16450a4b5880cf8d83528ea1ae0f47d10b2ab1d8 --- /dev/null +++ b/scripts/7681541997026479377/AmazingFeature/xshader/noface.vert @@ -0,0 +1,12 @@ +precision highp float; + +attribute vec2 position; +attribute vec2 texcoord0; +varying vec2 uv0; +//uniform mat4 u_MVP; +void main() +{ + //gl_Position = u_MVP * position; + gl_Position = sign(vec4(position.xy, 0.0, 1.0)); + uv0 = texcoord0; +} diff --git a/scripts/7681541997026479377/config.json b/scripts/7681541997026479377/config.json new file mode 100644 index 0000000000000000000000000000000000000000..aa3304ee315b1818802204b0097f1dd6a89d635d --- /dev/null +++ b/scripts/7681541997026479377/config.json @@ -0,0 +1,17 @@ +{ + "ae_tool" : "AmazingEditor", + "bALG_BACH_CONFIG" : false, + "effect" : + { + "Link" : + [ + { + "path" : "AmazingFeature/", + "type" : "AmazingFeature", + "zorder" : 8011 + } + ] + }, + "name" : "AlgorithmGraph_7bdbHcdcscQkbEdcc9cIlcNdvTdtb", + "version" : "13.4.0" +} \ No newline at end of file diff --git a/scripts/7681541997026479377/extra.json b/scripts/7681541997026479377/extra.json new file mode 100644 index 0000000000000000000000000000000000000000..7dea99639afda94276818ee548ea5801486540be --- /dev/null +++ b/scripts/7681541997026479377/extra.json @@ -0,0 +1,51 @@ +{ + "transition": { + "defaultDura": 2.0, + "isOverlap": true + }, + "External_Producer": true, + "setting": { + "lumiai_material_properties": [ + { + "effect_key": "progress", + "effect_key_cn": "\u6548\u679c\u8fdb\u5ea6", + "type": "float", + "default": 0, + "min": 0, + "max": 1 + }, + { + "effect_key": "spiralTurns", + "effect_key_cn": "spiral", + "type": "float", + "default": 5, + "min": 1, + "max": 12 + }, + { + "effect_key": "wedgeCount", + "effect_key_cn": "wedge ", + "type": "float", + "default": 8, + "min": 3, + "max": 24 + }, + { + "effect_key": "edgeSoftness", + "effect_key_cn": "edge S", + "type": "float", + "default": 0.08, + "min": 0.001, + "max": 0.3 + }, + { + "effect_key": "diveStrength", + "effect_key_cn": "dive S", + "type": "float", + "default": 0.28, + "min": 0, + "max": 1 + } + ] + } +} \ No newline at end of file diff --git a/scripts/7681552231262326017/AmazingFeature/content.json b/scripts/7681552231262326017/AmazingFeature/content.json new file mode 100644 index 0000000000000000000000000000000000000000..91fbb9be9167ba1f5315de330b0f1903d08afc0b --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/content.json @@ -0,0 +1,7 @@ +{ + "ae_tool" : "AmazingEditor", + "content" : {}, + "needblend" : false, + "tag" : "AMG_96763024926065909023875386850577846442", + "version" : "1.0" +} \ No newline at end of file diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua b/scripts/7681552231262326017/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua new file mode 100644 index 0000000000000000000000000000000000000000..a498e06b924f116108617c6860cb4ca1fd5e9b15 --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua @@ -0,0 +1,327 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiAnimSeqLoadAndCrop = LumiAnimSeqLoadAndCrop or {} +LumiAnimSeqLoadAndCrop.__index = LumiAnimSeqLoadAndCrop +---@class LumiAnimSeqLoadAndCrop : ScriptComponent +---@field animSeqType string [UI(Option={"Video", "Image", "Texture"})] +---@field cropType string [UI(Option={"Stretch", "Fill", "Fit", "Texture Size"})] +---@field edgeType string [UI(Option={"Tile", "Mirror", "Clamp", "Empty"})] +---@field pivot Vector2f +---@field position Vector2f +---@field rotation double [UI(Range={0, 360}, Drag)] +---@field scale double [UI(Range={0, 5}, Drag)] +---@field opacity double [UI(Range={0, 1}, Drag)] +---@field playMode string [UI(Option={"once", "loop"})] +---@field speed double [UI(Range={0.001, 10}, Drag)] +---@field seqTime number [UI(Range={0, 100}, Drag)] +---@field enableVideoAlphaBlend boolean +---@field videoFilename String +---@field animSeq AnimSeq +---@field seqTex Texture +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local animSeqTypeName = { + "Video", "Image", "Texture", +} +setmetatable(animSeqTypeName, {__index = function(_, _) return animSeqTypeName[1] end}) +local animSeqTypeIndex = {} +for index, value in ipairs(animSeqTypeName) do animSeqTypeIndex[value] = index - 1 end +setmetatable(animSeqTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, 'Unsupported AnimSeqType: ' .. key) + return 0 + end +}) + +local cropTypeName = { + "Stretch", "Fill", "Fit", "Texture Size" +} +setmetatable(cropTypeName, {__index = function(_, _) return cropTypeName[1] end}) +local cropTypeIndex = {} +for index, value in ipairs(cropTypeName) do cropTypeIndex[value] = index - 1 end +setmetatable(cropTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported SeqCrop Type: " .. key) + return 0 + end +}) + +local edgeTypeName = { + "Tile", "Mirror", "Clamp", "Empty", +} +setmetatable(edgeTypeName, {__index = function(_, _) return edgeTypeName[1] end}) +local edgeTypeIndex = {} +for index, value in ipairs(edgeTypeName) do edgeTypeIndex[value] = index - 1 end +setmetatable(edgeTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported Edge Type: " .. key) + return 0 + end +}) + +local playModeName = { + "once", "loop" +} +setmetatable(playModeName, {__index = function(_, _) return playModeName[1] end}) +local playModeIndex = {} +for index, value in ipairs(playModeName) do playModeIndex[value] = index - 1 end +setmetatable(playModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported Play Mode: " .. key) + return 0 + end +}) + +function LumiAnimSeqLoadAndCrop.new(construct, ...) + local self = setmetatable({}, LumiAnimSeqLoadAndCrop) + + self.AEPlugin = false + self.seqTime = 0.0 + self.globalRotation = 0.0 + self.globalScale = 1.0 + self.globalOpacity = 1.0 + self.globalSpeed = 1.0 + + self.paramInitInfo = { + {'specify', false}, + {'animSeqType', 'Texture'}, + {'cropType', 'Stretch'}, + {'edgeType', 'Empty'}, + {'pivot', Amaz.Vector2f(0.5, 0.5)}, + {'position', Amaz.Vector2f(0.5, 0.5)}, + {'rotation', 0}, + {'scale', 1.0}, + {'opacity', 1.0}, + {'playMode', 'loop'}, + {'speed', 1.0}, + -- Video seq + {'videoFilename', ''}, + {'enableVideoAlphaBlend', false}, + -- Image seq + {'animSeq', nil}, + -- Texture + {'seqTex', nil}, + } + + self.multiAspect = { + ['5.8'] = 1.125 / 2.436, -- 0.4618 + ['9_16'] = 9 / 16, -- 0.5625 + ['3_4'] = 3 / 4, -- 0.75 + ['1_1'] = 1, + ['4_3'] = 4 / 3, -- 1.3333 + ['16_9'] = 16 / 9, -- 1.7778 + ['1.85_1'] = 1.85, + ['2_1'] = 2, + ['2.35_1'] = 2.35, + } + + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self.paramInitInfo[i][2] + end + + for key, _ in pairs(self.multiAspect) do + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1] .. '_' .. key] = self.paramInitInfo[i][2] + end + end + + self.needUpdateSize = true + self.InputTex = nil + self.OutputTex = nil + + return self +end + +function LumiAnimSeqLoadAndCrop:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.camera = self.entity:searchEntity("AnimSeqCamera"):getComponent("Camera") + self.material = self.entity:searchEntity('AnimSeqPass'):getComponent('MeshRenderer').material + self.videoAnim = self.entity:searchEntity("AnimSeqPass"):getComponent("VideoAnimSeq") + self.seqAnim = self.entity:searchEntity("AnimSeqPass"):getComponent("AnimSeqComponent") +end + +function LumiAnimSeqLoadAndCrop:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value, _force) + if _force or self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if self[key] ~= nil then + if key:sub(1, #'cropType') == 'cropType' then + local type = cropTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'edgeType') == 'edgeType' then + local type = edgeTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'animSeqType') == 'animSeqType' then + local type = animSeqTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'playMode') == 'playMode' then + local type = playModeName[value + 1] + _setEffectAttr(key, type) + else + _setEffectAttr(key, value) + end + elseif key:sub(1, #'seqTex') == 'seqTex' + or key:sub(1, #'animSeq') == 'animSeq' + then + _setEffectAttr(key, value, true) + else + _setEffectAttr(key, value) + end +end + +function LumiAnimSeqLoadAndCrop:afterAnimSeqSystemUpdate(comp) + if self.animSeqType == "Image" then + if self.needUpdateSize and self.material then + local seqTex = self.material:getTex("u_seqTexture") + self.material:setVec2("u_seqTexSize", Amaz.Vector2f(seqTex.width, seqTex.height)) + seqTex = nil + self.needUpdateSize = false + end + end +end + +function LumiAnimSeqLoadAndCrop:onUpdate(comp, deltaTime) + if self.OutputTex then + self.camera.renderTexture = self.OutputTex + end + + local w = self.camera.renderTexture.width + local h = self.camera.renderTexture.height + + local ratio = w / h + local paramFlag = '' + local _diff = math.huge + for key, value in pairs(self.multiAspect) do + if self['specify_' .. key] then + local diff = math.abs(ratio - value) + if diff < _diff then + _diff = diff + paramFlag = key + end + end + end + + -- update parameters based on resolution + if paramFlag == '' then + if self.AEPlugin then + Amaz.LOGE(self.TAG, 'No aspect specified' .. ', ratio: ' .. ratio .. ', reset params!') + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self.paramInitInfo[i][2] + end + else + Amaz.LOGE(self.TAG, 'No aspect specified' .. ', ratio: ' .. ratio) + end + else + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self[self.paramInitInfo[i][1] .. '_' .. paramFlag] + end + end + + if self.AEPlugin then + self.animSeqType = 'Texture' + end + + self.material:setTex("u_inputTexture", self.InputTex) + self.material:setInt('u_cropType', cropTypeIndex[self.cropType]) + self.material:setInt('u_edgeType', edgeTypeIndex[self.edgeType]) + self.material:setFloat('u_opacity', self.opacity * self.globalOpacity) + self.material:setVec2('u_scale', Amaz.Vector2f(self.scale, self.scale) * self.globalScale) + self.material:setVec2('u_pivot', self.pivot - Amaz.Vector2f(0.5, 0.5)) + self.material:setVec2('u_position', self.position - Amaz.Vector2f(0.5, 0.5)) + self.material:setFloat('u_rotation', math.rad(self.rotation + self.globalRotation)) + + local playMode = Amaz.PlayMode.loop + if self.playMode == 'once' then + playMode = Amaz.PlayMode.once + end + + local speed = self.speed * self.globalSpeed + + if self.animSeqType == "Video" then + self.videoAnim.enabled = true + self.seqAnim.enabled = false + + if not isEditor then + self.videoAnim.enableFixedSeekMode = true + end + if self.videoAnim.videoFilename ~= self.videoFilename then + self.videoAnim.videoFilename = self.videoFilename + end + if self.videoAnim.enableAlphaBlend ~= self.enableVideoAlphaBlend then + self.videoAnim.enableAlphaBlend = self.enableVideoAlphaBlend + end + if self.videoAnim.playmode ~= playMode then + self.videoAnim.playmode = playMode + end + if self.videoAnim.speed ~= speed then + self.videoAnim.speed = speed + end + local frames = self.videoAnim:getFrameCount() + local duration = self.videoAnim:getDuration() + local videoFps = frames / duration * 1000 + self.videoAnim:seekToTime(self.seqTime + 0.5 / videoFps) + local videoSize = self.videoAnim:getVideoSize() + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", 0) + -- self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + self.material:setInt('u_yFlip', 1) + elseif self.animSeqType == "Image" then + self.videoAnim.enabled = false + self.seqAnim.enabled = true + + if self.seqAnim.animSeq ~= self.animSeq then + self.seqAnim.animSeq = self.animSeq + self.needUpdateSize = true + end + if self.seqAnim.playmode ~= playMode then + self.seqAnim.playmode = playMode + end + if self.seqAnim.speed ~= speed then + self.seqAnim.speed = speed + end + self.seqAnim:seekToTime(self.seqTime + 0.5 / self.animSeq.fps) + self.material:setInt("u_convertAlpha", 0) + self.material:setInt('u_yFlip', 1) + elseif self.animSeqType == "Texture" then + self.videoAnim.enabled = false + self.seqAnim.enabled = false + + if self.seqTex then + self.material:setTex("u_seqTexture", self.seqTex) + local videoSize = Amaz.Vector2f(self.seqTex.width, self.seqTex.height) + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + else + self.material:setTex("u_seqTexture", self.InputTex) + local inputWidth = Amaz.BuiltinObject.getInputTextureWidth() + local inputHeight = Amaz.BuiltinObject.getInputTextureHeight() + local videoSize = Amaz.Vector2f(inputWidth, inputHeight) + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + end + self.material:setInt('u_yFlip', 0) + end +end + +exports.LumiAnimSeqLoadAndCrop = LumiAnimSeqLoadAndCrop +return exports diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag b/scripts/7681552231262326017/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag new file mode 100644 index 0000000000000000000000000000000000000000..776d48b9649c5f359d8b806bfa1895121567e7d5 --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag @@ -0,0 +1,162 @@ +precision highp float; +precision highp int; + +uniform mediump int u_yFlip; +uniform mediump int u_convertAlpha; +uniform mediump sampler2D u_seqTexture; +uniform vec4 u_ScreenParams; +uniform vec2 u_scale; +uniform float u_rotation; +uniform vec2 u_position; +uniform vec2 u_pivot; +uniform vec2 u_seqTexSize; +uniform mediump int u_cropType; +uniform mediump int u_edgeType; +uniform float u_opacity; + +varying vec2 uv0; + +vec2 _f4(inout vec2 _p0, float _p1, vec2 _p2, vec2 _p3, vec2 _p4) +{ + _p0 -= _p2; + _p0 -= vec2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _169 = sin(_p1); + float _172 = cos(_p1); + _p0 = mat2(vec2(_172, _169), vec2(-_169, _172)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 /= _p4; + _p0 += vec2(0.5); + _p0 += _p3; + return _p0; +} + +vec2 _f2(vec2 _p0) +{ + vec2 _122 = mod(_p0, vec2(1.0)); + return _122 + (vec2(1.0) - step(vec2(0.0), _122)); +} + +vec2 _f1(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +vec4 _f0(inout vec2 _p0) +{ + if (u_yFlip == 1) + { + _p0 = vec2(_p0.x, 1.0 - _p0.y); + } + if (u_convertAlpha == 0) + { + return texture2D(u_seqTexture, _p0); + } + vec4 _t2; + _t2.w = texture2D(u_seqTexture, vec2(_p0.x * 0.5, _p0.y)).x; + mediump vec3 _97 = texture2D(u_seqTexture, vec2((_p0.x * 0.5) + 0.5, _p0.y)).xyz; + _t2.x = _97.x; + _t2.y = _97.y; + _t2.z = _97.z; + return _t2; +} + +float _f3(vec2 _p0) +{ + vec2 _t4 = step(vec2(0.0), _p0) * step(_p0, vec2(1.0)); + return _t4.x * _t4.y; +} + +void main() +{ + bool _214 = abs(u_scale.x) < 9.9999997473787516355514526367188e-05; + bool _222; + if (!_214) + { + _222 = abs(u_scale.y) < 9.9999997473787516355514526367188e-05; + } + else + { + _222 = _214; + } + if (_222) + { + gl_FragData[0] = vec4(0.0); + return; + } + vec2 param = uv0; + float param_1 = u_rotation; + vec2 param_2 = u_position; + vec2 param_3 = u_pivot; + vec2 param_4 = u_scale; + vec2 _245 = _f4(param, param_1, param_2, param_3, param_4); + vec2 _t8 = _245; + float _252 = u_seqTexSize.x / u_seqTexSize.y; + float _258 = u_ScreenParams.x / u_ScreenParams.y; + vec2 _t11 = _245; + if (u_cropType == 1) + { + if (_252 > _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (u_cropType == 2) + { + if (_252 < _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (u_cropType == 3) + { + _t11 -= vec2(0.5); + _t11.x *= (u_ScreenParams.x / u_seqTexSize.x); + _t11.y *= (u_ScreenParams.y / u_seqTexSize.y); + _t11 += vec2(0.5); + } + } + } + if (u_edgeType == 0) + { + vec2 param_5 = _t11; + _t11 = _f2(param_5); + } + else + { + if (u_edgeType == 1) + { + vec2 param_6 = _t11; + _t11 = _f1(param_6); + } + } + vec2 param_7 = _t11; + vec4 _389 = _f0(param_7); + vec4 _t16 = _389; + if (u_edgeType == 3) + { + vec2 param_8 = _t11; + _t16 *= _f3(param_8); + } + vec4 _401 = _t16; + vec4 _402 = _401 * u_opacity; + _t16 = _402; + gl_FragData[0] = _402; +} + diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert b/scripts/7681552231262326017/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag b/scripts/7681552231262326017/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag new file mode 100644 index 0000000000000000000000000000000000000000..d21575c9d17e191328bff9c1ab15dd22db3dc969 --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag @@ -0,0 +1,190 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + int u_yFlip; + int u_convertAlpha; + float4 u_ScreenParams; + float2 u_scale; + float u_rotation; + float2 u_position; + float2 u_pivot; + float2 u_seqTexSize; + int u_cropType; + int u_edgeType; + float u_opacity; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f4(thread float2& _p0, thread const float& _p1, thread const float2& _p2, thread const float2& _p3, thread const float2& _p4, constant float4& u_ScreenParams) +{ + _p0 -= _p2; + _p0 -= float2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _169 = sin(_p1); + float _172 = cos(_p1); + _p0 = float2x2(float2(_172, _169), float2(-_169, _172)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 /= _p4; + _p0 += float2(0.5); + _p0 += _p3; + return _p0; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float2& _p0) +{ + float2 _122 = mod(_p0, float2(1.0)); + return _122 + (float2(1.0) - step(float2(0.0), _122)); +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float4 _f0(thread float2& _p0, constant int& u_yFlip, constant int& u_convertAlpha, texture2d u_seqTexture, sampler u_seqTextureSmplr) +{ + if (u_yFlip == 1) + { + _p0 = float2(_p0.x, 1.0 - _p0.y); + } + if (u_convertAlpha == 0) + { + return u_seqTexture.sample(u_seqTextureSmplr, _p0); + } + float4 _t2; + _t2.w = u_seqTexture.sample(u_seqTextureSmplr, float2(_p0.x * 0.5, _p0.y)).x; + float3 _97 = u_seqTexture.sample(u_seqTextureSmplr, float2((_p0.x * 0.5) + 0.5, _p0.y)).xyz; + _t2.x = _97.x; + _t2.y = _97.y; + _t2.z = _97.z; + return _t2; +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0) +{ + float2 _t4 = step(float2(0.0), _p0) * step(_p0, float2(1.0)); + return _t4.x * _t4.y; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_seqTexture [[texture(0)]], sampler u_seqTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + bool _214 = abs(buffer.u_scale.x) < 9.9999997473787516355514526367188e-05; + bool _222; + if (!_214) + { + _222 = abs(buffer.u_scale.y) < 9.9999997473787516355514526367188e-05; + } + else + { + _222 = _214; + } + if (_222) + { + out.o_fragColor = float4(0.0); + return out; + } + float2 param = in.uv0; + float param_1 = buffer.u_rotation; + float2 param_2 = buffer.u_position; + float2 param_3 = buffer.u_pivot; + float2 param_4 = buffer.u_scale; + float2 _245 = _f4(param, param_1, param_2, param_3, param_4, buffer.u_ScreenParams); + float2 _t8 = _245; + float _252 = buffer.u_seqTexSize.x / buffer.u_seqTexSize.y; + float _258 = buffer.u_ScreenParams.x / buffer.u_ScreenParams.y; + float2 _t11 = _245; + if (buffer.u_cropType == 1) + { + if (_252 > _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (buffer.u_cropType == 2) + { + if (_252 < _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (buffer.u_cropType == 3) + { + _t11 -= float2(0.5); + _t11.x *= (buffer.u_ScreenParams.x / buffer.u_seqTexSize.x); + _t11.y *= (buffer.u_ScreenParams.y / buffer.u_seqTexSize.y); + _t11 += float2(0.5); + } + } + } + if (buffer.u_edgeType == 0) + { + float2 param_5 = _t11; + _t11 = _f2(param_5); + } + else + { + if (buffer.u_edgeType == 1) + { + float2 param_6 = _t11; + _t11 = _f1(param_6); + } + } + float2 param_7 = _t11; + float4 _389 = _f0(param_7, buffer.u_yFlip, buffer.u_convertAlpha, u_seqTexture, u_seqTextureSmplr); + float4 _t16 = _389; + if (buffer.u_edgeType == 3) + { + float2 param_8 = _t11; + _t16 *= _f3(param_8); + } + float4 _401 = _t16; + float4 _402 = _401 * buffer.u_opacity; + _t16 = _402; + out.o_fragColor = _402; + return out; +} + diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert b/scripts/7681552231262326017/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiBCC_Prism/lua/LumiBCC_Prism.lua b/scripts/7681552231262326017/AmazingFeature/effects/LumiBCC_Prism/lua/LumiBCC_Prism.lua new file mode 100644 index 0000000000000000000000000000000000000000..3113b47951ef77f1a2cbc30a81efcc6cd0ddcea4 --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiBCC_Prism/lua/LumiBCC_Prism.lua @@ -0,0 +1,122 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiBCC_Prism = LumiBCC_Prism or {} +LumiBCC_Prism.__index = LumiBCC_Prism +---@class LumiBCC_Prism : ScriptComponent +---@field globalTransform number +---@field smoothness number [UI(Range={0, 1.0}, Drag)] +---@field weight number [UI(Range={0, 1.0}, Drag)] +---@field center vector2f +---@field scaleStart number +---@field scaleEnd number +---@field angleStart number +---@field angleEnd number +---@field falloff number +---@field offsetStart vector2f +---@field offsetEnd vector2f +---@field colorStart vector3f +---@field colorMid vector3f +---@field colorEnd vector3f +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local function createRenderTexture(width, height, filterMag, filterMin) + local rt = Amaz.RenderTexture() + rt.width = width + rt.height = height + rt.depth = 1 + rt.filterMag = filterMag or Amaz.FilterMode.LINEAR + rt.filterMin = filterMin or Amaz.FilterMode.LINEAR + rt.filterMipmap = Amaz.FilterMipmapMode.NONE + rt.attachment = Amaz.RenderTextureAttachment.NONE + return rt +end + +local function updateTexSize(rt, width, height) + if rt == nil or width <= 0 or height <= 0 then + return + end + if rt.width ~= width or rt.height ~= height then + rt.width = width + rt.height = height + end +end + +function LumiBCC_Prism.new(construct, ...) + local self = setmetatable({}, LumiBCC_Prism) + self.scaleStart = 100 + self.scaleEnd = 100 + self.angleStart = 0 + self.angleEnd = 0 + self.falloff = 0 + self.globalTransform = 100. + self.center = Amaz.Vector2f(0.5,0.5) + self.smoothness = 0 + self.weight = 0 + self.offsetStart = Amaz.Vector2f(0.5,0.5) + self.offsetEnd = Amaz.Vector2f(0.5,0.5) + self.colorStart = Amaz.Color(1,0,0,1) + self.colorMid = Amaz.Color(0,1,0,1) + self.colorEnd = Amaz.Color(0,0,1,1) + self.__lumi_type = "lumi_obj" + self.__lumi_rt_pingpong_type = "custom" + + self.InputTex = nil + self.OutputTex = nil + + return self +end + +function LumiBCC_Prism:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value, _force) + if _force or self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + _setEffectAttr(key, value) +end + +function LumiBCC_Prism:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + -- Amaz.LOGI(self.TAG, 'onStart') + + -- Use entity instead of scene + self.camera = self.entity:searchEntity("CameraBCC_Prism"):getComponent("Camera") + self.material = self.entity:searchEntity("BCC_Prism"):getComponent("MeshRenderer").material + +end + +function LumiBCC_Prism:onUpdate(comp, deltaTime) + -- set the input and output textures to be displayed + if self.OutputTex then + self.camera.renderTexture = self.OutputTex + end + self.material:setTex("u_inputTexture", self.InputTex) + self.material:setFloat("u_scaleStart", self.scaleStart/100.) + self.material:setFloat("u_scaleEnd", self.scaleEnd/100) + + self.material:setFloat("u_angleStart", math.rad(self.angleStart)) + self.material:setFloat("u_angleEnd", math.rad(self.angleEnd)) + self.material:setFloat("u_fallOff", self.falloff/100) + self.material:setVec2("u_center", self.center) + + self.material:setFloat("u_weight", math.sqrt(self.weight)) + self.material:setFloat("u_smoothness", self.smoothness) + self.material:setFloat("u_globalTransform", self.globalTransform/100) + self.material:setVec2("u_offsetStart", self.offsetStart) + self.material:setVec2("u_offsetEnd",self.offsetEnd) + + self.material:setVec3("u_colorEnd", Amaz.Vector3f(self.colorEnd.r, self.colorEnd.g, self.colorEnd.b)) + self.material:setVec3("u_colorMid", Amaz.Vector3f(self.colorMid.r, self.colorMid.g, self.colorMid.b)) + self.material:setVec3("u_colorStart", Amaz.Vector3f(self.colorStart.r, self.colorStart.g, self.colorStart.b)) +end + +exports.LumiBCC_Prism = LumiBCC_Prism +return exports diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiBCC_Prism/xshader/shaderLib/shaderGLES/bafaa0ad87de182eb87df42c43abae73.frag b/scripts/7681552231262326017/AmazingFeature/effects/LumiBCC_Prism/xshader/shaderLib/shaderGLES/bafaa0ad87de182eb87df42c43abae73.frag new file mode 100644 index 0000000000000000000000000000000000000000..619f2bac09680d20882e4216b463f6f0e09704f5 --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiBCC_Prism/xshader/shaderLib/shaderGLES/bafaa0ad87de182eb87df42c43abae73.frag @@ -0,0 +1,151 @@ +precision highp float; +precision highp int; + +uniform vec4 u_ScreenParams; +uniform vec2 u_center; +uniform float u_globalTransform; +uniform float u_scaleEnd; +uniform float u_scaleStart; +uniform float u_angleEnd; +uniform float u_angleStart; +uniform float u_smoothness; +uniform vec2 u_offsetStart; +uniform vec2 u_offsetEnd; +uniform vec3 u_colorStart; +uniform vec3 u_colorMid; +uniform vec3 u_colorEnd; +uniform float u_weight; +uniform float u_fallOff; +uniform mediump sampler2D u_inputTexture; + +varying vec2 v_uv; + +mat2 _f0(float _p0) +{ + float _50 = sin(_p0); + float _53 = cos(_p0); + return mat2(vec2(_53, -_50), vec2(_50, _53)); +} + +vec2 _f1(vec2 _p0, vec2 _p1, float _p2) +{ + vec2 _t2 = _p0 - _p1; + float _81 = u_ScreenParams.x / u_ScreenParams.y; + _t2.x *= _81; + float param = _p2; + _t2 *= _f0(param); + _t2.x /= _81; + return _t2 + _p1; +} + +vec2 _f2(vec2 _p0, vec2 _p1, mat2 _p2) +{ + vec2 _t3 = _p0 - _p1; + float _113 = u_ScreenParams.x / u_ScreenParams.y; + _t3.x *= _113; + _t3 *= _p2; + _t3.x /= _113; + return _t3 + _p1; +} + +float _f4(float _p0, float _p1, float _p2, float _p3) +{ + return clamp((1.0 - (abs(_p3 - _p0) / _p2)) * _p1, 0.0, 1.0); +} + +vec3 _f5(vec3 _p0, vec3 _p1, vec3 _p2, float _p3) +{ + float param = 0.0; + float param_1 = 1.0; + float param_2 = 0.5; + float param_3 = _p3; + float param_4 = 0.5; + float param_5 = 1.0; + float param_6 = 0.5; + float param_7 = _p3; + float param_8 = 1.0; + float param_9 = 1.0; + float param_10 = 0.5; + float param_11 = _p3; + return ((_p0 * _f4(param, param_1, param_2, param_3)) + (_p1 * _f4(param_4, param_5, param_6, param_7))) + (_p2 * _f4(param_8, param_9, param_10, param_11)); +} + +vec2 _f3(vec2 _p0) +{ + return abs(mod(_p0 + vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +void main() +{ + vec4 _t7 = vec4(0.0); + vec4 _t8 = vec4(0.0); + vec4 _t9 = vec4(0.0); + vec4 _t10 = vec4(0.0); + vec2 _210 = mix(vec2(0.5), vec2(u_center), vec2(u_globalTransform)); + float _227 = u_scaleEnd - u_scaleStart; + float _t13 = max(80.0 * abs(_227), mix(0.0, 79.0, abs(u_angleEnd - u_angleStart) / 0.5)); + float _243 = u_smoothness * u_smoothness; + if (_243 > 0.300000011920928955078125) + { + _t13 = max((_t13 * sqrt(length(v_uv - _210))) * 4.0, 6.0); + } + float _272 = _t13; + float _284 = floor(mix(2.0, max(2.0, max(length((u_offsetStart - u_offsetEnd) * (u_ScreenParams.xy / vec2(min(u_ScreenParams.y, u_ScreenParams.x)))) * 450.0, _272) * u_globalTransform), clamp(_243, 0.0, 1.0))); + _t13 = _284; + float _291 = u_angleStart * u_globalTransform; + float param = ((u_angleEnd * u_globalTransform) - _291) / _284; + mat2 _296 = _f0(param); + vec2 param_1 = v_uv; + vec2 param_2 = _210; + float param_3 = _291; + vec2 _t15 = _f1(param_1, param_2, param_3); + vec2 _311 = (u_offsetStart - vec2(0.5)) * u_globalTransform; + vec2 _316 = (u_offsetEnd - vec2(0.5)) * u_globalTransform; + for (mediump int _t18 = 0; _t18 <= 1024; _t18++) + { + mediump float _331 = float(_t18); + if (_331 > _t13) + { + break; + } + float _341 = _331 / _t13; + vec2 _343 = _t15; + vec2 _345 = _343 - _210; + vec2 _368 = vec2(_341); + vec2 param_4 = _343; + vec2 param_5 = _210; + mat2 param_6 = _296; + _t15 = _f2(param_4, param_5, param_6); + float _390 = 1.0 - _341; + vec3 param_7 = u_colorStart; + vec3 param_8 = u_colorMid; + vec3 param_9 = u_colorEnd; + float param_10 = _390; + vec3 _t24 = mix(vec3(0.00999999977648258209228515625), _f5(param_7, param_8, param_9, param_10), vec3(clamp(u_weight, 0.0, 1.0))); + float _t25 = 0.00999999977648258209228515625; + if (u_scaleStart > u_scaleEnd) + { + _t25 = pow(clamp(_390, 0.001000000047497451305389404296875, 1.0), 1.0 + ((u_scaleStart - u_scaleEnd) * 2.0)); + } + else + { + _t25 = pow(clamp(_341, 0.001000000047497451305389404296875, 1.0), 1.0 + (_227 * 2.0)); + } + _t24 *= _t25; + vec2 param_11 = mix((_345 / vec2(mix(1.0, u_scaleStart, u_globalTransform))) + _210, (_345 / vec2(mix(1.0, u_scaleEnd, u_globalTransform))) + _210, _368) - mix(_311, _316, _368); + mediump vec4 _453 = texture2D(u_inputTexture, _f3(param_11)); + vec4 _459 = vec4(_t24, 1.0); + _t7 += ((_453 * _459) * vec4(vec3(mix(1.0 - u_fallOff, 1.0 + u_fallOff, _341)), 1.0)); + _t8 += _459; + _t9 += (_453 * _t25); + _t10 += vec4(_t25); + } + vec4 _489 = _t7; + vec4 _490 = _489 / _t8; + _t7 = _490; + vec4 _492 = _t9; + vec4 _493 = _492 / _t10; + _t9 = _493; + gl_FragData[0] = vec4(mix(_493, _490, vec4(u_weight))); +} + diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiBCC_Prism/xshader/shaderLib/shaderGLES/bafaa0ad87de182eb87df42c43abae73.vert b/scripts/7681552231262326017/AmazingFeature/effects/LumiBCC_Prism/xshader/shaderLib/shaderGLES/bafaa0ad87de182eb87df42c43abae73.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiBCC_Prism/xshader/shaderLib/shaderGLES/bafaa0ad87de182eb87df42c43abae73.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiBCC_Prism/xshader/shaderLib/shaderMetal/bafaa0ad87de182eb87df42c43abae73.frag b/scripts/7681552231262326017/AmazingFeature/effects/LumiBCC_Prism/xshader/shaderLib/shaderMetal/bafaa0ad87de182eb87df42c43abae73.frag new file mode 100644 index 0000000000000000000000000000000000000000..66a515383e6a94c85b8f0a9e22df1b1a0caad058 --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiBCC_Prism/xshader/shaderLib/shaderMetal/bafaa0ad87de182eb87df42c43abae73.frag @@ -0,0 +1,180 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + float4 u_ScreenParams; + float2 u_center; + float u_globalTransform; + float u_scaleEnd; + float u_scaleStart; + float u_angleEnd; + float u_angleStart; + float u_smoothness; + float2 u_offsetStart; + float2 u_offsetEnd; + float3 u_colorStart; + float3 u_colorMid; + float3 u_colorEnd; + float u_weight; + float u_fallOff; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2x2 _f0(thread const float& _p0) +{ + float _50 = sin(_p0); + float _53 = cos(_p0); + return float2x2(float2(_53, -_50), float2(_50, _53)); +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float2& _p0, thread const float2& _p1, thread const float& _p2, constant float4& u_ScreenParams) +{ + float2 _t2 = _p0 - _p1; + float _81 = u_ScreenParams.x / u_ScreenParams.y; + _t2.x *= _81; + float param = _p2; + _t2 *= _f0(param); + _t2.x /= _81; + return _t2 + _p1; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float2& _p0, thread const float2& _p1, thread const float2x2& _p2, constant float4& u_ScreenParams) +{ + float2 _t3 = _p0 - _p1; + float _113 = u_ScreenParams.x / u_ScreenParams.y; + _t3.x *= _113; + _t3 *= _p2; + _t3.x /= _113; + return _t3 + _p1; +} + +static inline __attribute__((always_inline)) +float _f4(thread const float& _p0, thread const float& _p1, thread const float& _p2, thread const float& _p3) +{ + return fast::clamp((1.0 - (abs(_p3 - _p0) / _p2)) * _p1, 0.0, 1.0); +} + +static inline __attribute__((always_inline)) +float3 _f5(thread const float3& _p0, thread const float3& _p1, thread const float3& _p2, thread const float& _p3) +{ + float param = 0.0; + float param_1 = 1.0; + float param_2 = 0.5; + float param_3 = _p3; + float param_4 = 0.5; + float param_5 = 1.0; + float param_6 = 0.5; + float param_7 = _p3; + float param_8 = 1.0; + float param_9 = 1.0; + float param_10 = 0.5; + float param_11 = _p3; + return ((_p0 * _f4(param, param_1, param_2, param_3)) + (_p1 * _f4(param_4, param_5, param_6, param_7))) + (_p2 * _f4(param_8, param_9, param_10, param_11)); +} + +static inline __attribute__((always_inline)) +float2 _f3(thread const float2& _p0) +{ + return abs(mod(_p0 + float2(1.0), float2(2.0)) - float2(1.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTexture [[texture(0)]], sampler u_inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _t7 = float4(0.0); + float4 _t8 = float4(0.0); + float4 _t9 = float4(0.0); + float4 _t10 = float4(0.0); + float2 _210 = mix(float2(0.5), float2(buffer.u_center), float2(buffer.u_globalTransform)); + float _227 = buffer.u_scaleEnd - buffer.u_scaleStart; + float _t13 = fast::max(80.0 * abs(_227), mix(0.0, 79.0, abs(buffer.u_angleEnd - buffer.u_angleStart) / 0.5)); + float _243 = buffer.u_smoothness * buffer.u_smoothness; + if (_243 > 0.300000011920928955078125) + { + _t13 = fast::max((_t13 * sqrt(length(in.v_uv - _210))) * 4.0, 6.0); + } + float _272 = _t13; + float _284 = floor(mix(2.0, fast::max(2.0, fast::max(length((buffer.u_offsetStart - buffer.u_offsetEnd) * (buffer.u_ScreenParams.xy / float2(fast::min(buffer.u_ScreenParams.y, buffer.u_ScreenParams.x)))) * 450.0, _272) * buffer.u_globalTransform), fast::clamp(_243, 0.0, 1.0))); + _t13 = _284; + float _291 = buffer.u_angleStart * buffer.u_globalTransform; + float param = ((buffer.u_angleEnd * buffer.u_globalTransform) - _291) / _284; + float2x2 _296 = _f0(param); + float2 param_1 = in.v_uv; + float2 param_2 = _210; + float param_3 = _291; + float2 _t15 = _f1(param_1, param_2, param_3, buffer.u_ScreenParams); + float2 _311 = (buffer.u_offsetStart - float2(0.5)) * buffer.u_globalTransform; + float2 _316 = (buffer.u_offsetEnd - float2(0.5)) * buffer.u_globalTransform; + for (int _t18 = 0; _t18 <= 1024; _t18++) + { + float _331 = float(_t18); + if (_331 > _t13) + { + break; + } + float _341 = _331 / _t13; + float2 _343 = _t15; + float2 _345 = _343 - _210; + float2 _368 = float2(_341); + float2 param_4 = _343; + float2 param_5 = _210; + float2x2 param_6 = _296; + _t15 = _f2(param_4, param_5, param_6, buffer.u_ScreenParams); + float _390 = 1.0 - _341; + float3 param_7 = buffer.u_colorStart; + float3 param_8 = buffer.u_colorMid; + float3 param_9 = buffer.u_colorEnd; + float param_10 = _390; + float3 _t24 = mix(float3(0.00999999977648258209228515625), _f5(param_7, param_8, param_9, param_10), float3(fast::clamp(buffer.u_weight, 0.0, 1.0))); + float _t25 = 0.00999999977648258209228515625; + if (buffer.u_scaleStart > buffer.u_scaleEnd) + { + _t25 = pow(fast::clamp(_390, 0.001000000047497451305389404296875, 1.0), 1.0 + ((buffer.u_scaleStart - buffer.u_scaleEnd) * 2.0)); + } + else + { + _t25 = pow(fast::clamp(_341, 0.001000000047497451305389404296875, 1.0), 1.0 + (_227 * 2.0)); + } + _t24 *= _t25; + float2 param_11 = mix((_345 / float2(mix(1.0, buffer.u_scaleStart, buffer.u_globalTransform))) + _210, (_345 / float2(mix(1.0, buffer.u_scaleEnd, buffer.u_globalTransform))) + _210, _368) - mix(_311, _316, _368); + float4 _453 = u_inputTexture.sample(u_inputTextureSmplr, _f3(param_11)); + float4 _459 = float4(_t24, 1.0); + _t7 += ((_453 * _459) * float4(float3(mix(1.0 - buffer.u_fallOff, 1.0 + buffer.u_fallOff, _341)), 1.0)); + _t8 += _459; + _t9 += (_453 * _t25); + _t10 += float4(_t25); + } + float4 _489 = _t7; + float4 _490 = _489 / _t8; + _t7 = _490; + float4 _492 = _t9; + float4 _493 = _492 / _t10; + _t9 = _493; + out.o_fragColor = float4(mix(_493, _490, float4(buffer.u_weight))); + return out; +} + diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiBCC_Prism/xshader/shaderLib/shaderMetal/bafaa0ad87de182eb87df42c43abae73.vert b/scripts/7681552231262326017/AmazingFeature/effects/LumiBCC_Prism/xshader/shaderLib/shaderMetal/bafaa0ad87de182eb87df42c43abae73.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiBCC_Prism/xshader/shaderLib/shaderMetal/bafaa0ad87de182eb87df42c43abae73.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiChromaticAberration/lua/LumiChromaticAberration.lua b/scripts/7681552231262326017/AmazingFeature/effects/LumiChromaticAberration/lua/LumiChromaticAberration.lua new file mode 100644 index 0000000000000000000000000000000000000000..557a0157b2a39971c8163433ef916da4b625134a --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiChromaticAberration/lua/LumiChromaticAberration.lua @@ -0,0 +1,75 @@ +---@class LumiChromaticAberration: ScriptComponent +---@field offsetX number [UI(Range={-1., 1.}, Drag)] +---@field offsetY number [UI(Range={-1., 1.}, Drag)] +---@field InputTex Texture +---@field OutputTex Texture + +local exports = exports or {} +local LumiChromaticAberration = LumiChromaticAberration or {} +LumiChromaticAberration.__index = LumiChromaticAberration + +------------ util functions ------------ +local function clamp(value, min, max) + --[[ + Description: clamp value between [min, max] + ]] + return math.min(math.max(value, min), max) +end + +------------ class functions for ScriptComponent ------------ +function LumiChromaticAberration.new(construct, ...) + local self = setmetatable({}, LumiChromaticAberration) + + if construct and LumiChromaticAberration.constructor then LumiChromaticAberration.constructor(self, ...) end + -- user parameters + self.offsetX = 0. + self.offsetY = 0. + + -- other parameters + self.OffsetScale = 0.2 + + self.InputTex = nil + self.OutputTex = nil + + return self +end + +function LumiChromaticAberration:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value, _comp) + if self[_key] ~= nil then + self[_key] = _value + if _comp and _comp.properties ~= nil then + _comp.properties:set(_key, _value) + end + end + end + + if key == "offsetX" or key == "offsetY" then + _setEffectAttr(key, value, comp) + else + _setEffectAttr(key, value, comp) + end +end + +function LumiChromaticAberration:onStart(comp) + self.camOffset = comp.entity:searchEntity("CameraOffset"):getComponent("Camera") + self.matOffset= comp.entity:searchEntity("EntityOffset"):getComponent("MeshRenderer").material +end + +function LumiChromaticAberration:onUpdate(comp, deltaTime) + -- prepare parameters + self.offsetX = clamp(self.offsetX, -1., 1.) + self.offsetY = clamp(self.offsetY, -1., 1.) + local offsetX = self.offsetX * self.OffsetScale + local offsetY = self.offsetY * self.OffsetScale + + -- set InputTex, OutputTex + self.matOffset:setTex("u_inputTexture", self.InputTex) + self.camOffset.renderTexture = self.OutputTex + + self.matOffset:setFloat("u_offsetX", offsetX) + self.matOffset:setFloat("u_offsetY", offsetY) +end + +exports.LumiChromaticAberration = LumiChromaticAberration +return exports diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiChromaticAberration/xshader/shaderLib/shaderGLES/28ca007346d7379f4aebbb10fc2fa522.frag b/scripts/7681552231262326017/AmazingFeature/effects/LumiChromaticAberration/xshader/shaderLib/shaderGLES/28ca007346d7379f4aebbb10fc2fa522.frag new file mode 100644 index 0000000000000000000000000000000000000000..36d8f09f1bbd33f9a98e12d19661530420907421 --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiChromaticAberration/xshader/shaderLib/shaderGLES/28ca007346d7379f4aebbb10fc2fa522.frag @@ -0,0 +1,21 @@ +precision highp float; +precision highp int; + +uniform mediump sampler2D u_inputTexture; +uniform float u_offsetX; +uniform float u_offsetY; + +varying vec2 v_uv; + +void main() +{ + vec4 _t0 = texture2D(u_inputTexture, v_uv); + vec2 _34 = (vec2(u_offsetX, u_offsetY) * (vec2(1.0) - v_uv)) * v_uv; + vec4 _t3 = texture2D(u_inputTexture, v_uv + _34); + _t0.x = _t3.x; + vec4 _t5 = texture2D(u_inputTexture, v_uv - _34); + _t0.z = _t5.z; + _t0.w = ((_t3.w + _t0.w) + _t5.w) / 3.0; + gl_FragData[0] = _t0; +} + diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiChromaticAberration/xshader/shaderLib/shaderGLES/28ca007346d7379f4aebbb10fc2fa522.vert b/scripts/7681552231262326017/AmazingFeature/effects/LumiChromaticAberration/xshader/shaderLib/shaderGLES/28ca007346d7379f4aebbb10fc2fa522.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiChromaticAberration/xshader/shaderLib/shaderGLES/28ca007346d7379f4aebbb10fc2fa522.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiChromaticAberration/xshader/shaderLib/shaderMetal/28ca007346d7379f4aebbb10fc2fa522.frag b/scripts/7681552231262326017/AmazingFeature/effects/LumiChromaticAberration/xshader/shaderLib/shaderMetal/28ca007346d7379f4aebbb10fc2fa522.frag new file mode 100644 index 0000000000000000000000000000000000000000..8e67560deade7b62f66bce42ecfa0f762645b131 --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiChromaticAberration/xshader/shaderLib/shaderMetal/28ca007346d7379f4aebbb10fc2fa522.frag @@ -0,0 +1,35 @@ +#include +#include + +using namespace metal; + +struct buffer_t +{ + float u_offsetX; + float u_offsetY; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTexture [[texture(0)]], sampler u_inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _t0 = u_inputTexture.sample(u_inputTextureSmplr, in.v_uv); + float2 _34 = (float2(buffer.u_offsetX, buffer.u_offsetY) * (float2(1.0) - in.v_uv)) * in.v_uv; + float4 _t3 = u_inputTexture.sample(u_inputTextureSmplr, (in.v_uv + _34)); + _t0.x = _t3.x; + float4 _t5 = u_inputTexture.sample(u_inputTextureSmplr, (in.v_uv - _34)); + _t0.z = _t5.z; + _t0.w = ((_t3.w + _t0.w) + _t5.w) / 3.0; + out.o_fragColor = _t0; + return out; +} + diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiChromaticAberration/xshader/shaderLib/shaderMetal/28ca007346d7379f4aebbb10fc2fa522.vert b/scripts/7681552231262326017/AmazingFeature/effects/LumiChromaticAberration/xshader/shaderLib/shaderMetal/28ca007346d7379f4aebbb10fc2fa522.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiChromaticAberration/xshader/shaderLib/shaderMetal/28ca007346d7379f4aebbb10fc2fa522.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua b/scripts/7681552231262326017/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua new file mode 100644 index 0000000000000000000000000000000000000000..438a547f7d5c96047e2f183309e2a7d7200347e7 --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua @@ -0,0 +1,416 @@ +local exports = exports or {} +local LumiLayer = LumiLayer or {} +LumiLayer.__index = LumiLayer +---@class LumiLayer : ScriptComponent +---@field hasTransform boolean +---@field active_cam_fovx number +---@field compositeSize Vector2f +---@field layerSize Vector2f +---@field anchorPoint Vector3f +---@field orientation Vector3f +---@field position Vector3f +---@field scale Vector3f +---@field xRotation number [UI(Range={-360, 360}, Drag)] +---@field yRotation number [UI(Range={-360, 360}, Drag)] +---@field rotation number [UI(Range={-360, 360}, Drag)] +---@field opacity number [UI(Range={0, 100}, Drag)] +---@field mirrorEdge boolean +---@field hasMatte boolean +---@field matteMode string [UI(Option={"Alpha Matte", "Luma Matte", "Alpha Inverted Matte", "Luma Inverted Matte"})] +---@field maskTex Texture +---@field hasBlend boolean +---@field blendMode string [UI(Option={"Normal", "Add", "Multiply", "Difference", "Overlay", "Darken", "Lighten", "Soft Light", "Hard Light", "Hue", "Saturation", "Color", "Screen", "Color Burn", "Linear Burn", "Color Dodge", "Linear Dodge", "Vivid Light", "Linear Light", "Pin Light", "Hard Mix", "Exclusion", "Subtract", "Divide", "Luminosity", "Lighter Color", "Darker Color", "Dissolve"})] +---@field layerType string [UI(Option={"Adjustment", "Precomp", "Solid", "Image", "Video", "Sequence"})] +---@field baseTex Texture +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local MatteMode = { + "Alpha Matte", "Luma Matte", "Alpha Inverted Matte", "Luma Inverted Matte", +} +setmetatable(MatteMode, {__index = function(_, _) return MatteMode[1] end}) + +local MatteModeIndex = {} +for index, value in ipairs(MatteMode) do MatteModeIndex[value] = index - 1 end +setmetatable(MatteModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported matte mode: " .. key) + return 0 + end +}) + +local BlendMode = { + "Normal", "Add", "Multiply", "Difference", "Overlay", "Darken", "Lighten", "Soft Light", "Hard Light", "Hue", "Saturation", "Color", "Screen", "Color Burn", "Linear Burn", "Color Dodge", "Linear Dodge", "Vivid Light", "Linear Light", "Pin Light", "Hard Mix", "Exclusion", "Subtract", "Divide", "Luminosity", "Lighter Color", "Darker Color", "Dissolve", +} +setmetatable(BlendMode, {__index = function(_, _) return BlendMode[1] end}) + +local BlendModeIndex = {} +for index, value in ipairs(BlendMode) do BlendModeIndex[value] = index - 1 end +setmetatable(BlendModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported blend mode: " .. key) + return 0 + end +}) + +local LayerType = { + "Adjustment", "Precomp", "Solid", "Image", "Video", "Sequence", +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +function LumiLayer.new(construct, ...) + local self = setmetatable({}, LumiLayer) + + self.TAG = AE_EFFECT_TAG + + self.InputTex = nil + self.OutputTex = nil + self.aeTime = -1 + + -- TRS + self.hasTransform = false + self.active_cam_fovx = 39.6 + self.compositeSize = Amaz.Vector2f(1080, 1080) + self.layerSize = Amaz.Vector2f(1080, 1080) + + self.anchorPoint = Amaz.Vector3f(0, 0, 0) + self.position = Amaz.Vector3f(0, 0, 0) + self.scale = Amaz.Vector3f(100, 100, 100) + self.orientation = Amaz.Vector3f(0, 0, 0) + self.rotation = 0 + self.xRotation = 0 + self.yRotation = 0 + self.opacity = 100 + + self.p0_anchorPoint = Amaz.Vector3f(0, 0, 0) + self.p0_position = Amaz.Vector3f(0, 0, 0) + self.p0_scale = Amaz.Vector3f(100, 100, 100) + self.p0_orientation = Amaz.Vector3f(0, 0, 0) + self.p0_rotation = 0 + self.p0_xRotation = 0 + self.p0_yRotation = 0 + + self.p1_anchorPoint = Amaz.Vector3f(0, 0, 0) + self.p1_position = Amaz.Vector3f(0, 0, 0) + self.p1_scale = Amaz.Vector3f(100, 100, 100) + self.p1_orientation = Amaz.Vector3f(0, 0, 0) + self.p1_rotation = 0 + self.p1_xRotation = 0 + self.p1_yRotation = 0 + + self.expandRight = 0.0 + self.expandLeft = 0.0 + self.expandUp = 0.0 + self.expandDown = 0.0 + self.mirrorEdge = false + + -- Matte + self.hasMatte = false + self.matteMode = "Alpha" + self.matteDuration = {} + self.maskTex = nil + + -- Blend + self.hasBlend = true + self.blendMode = "Normal" + self.isVisible = true + self.layerType = 'Adjustment' + self.baseTex = nil + self.srcDuration = {} + self.baseDuration = {} + + -- for test + if false then + self.aeTime = 1 + self.srcDuration = {{0, 6}} + self.baseDuration = {{0, 6}} + end + + return self +end + +function LumiLayer:setVisible(visible) + self.isVisible = visible +end + +function LumiLayer:setEntityVisible(entity, visible) + local transforms = entity:getComponentsRecursive("Transform") + for i = 0, transforms:size() - 1 do + local transform = transforms:get(i) + if transform then + transform.entity.visible = visible + end + end + entity.visible = visible +end + +function LumiLayer:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.layerEntity = self.entity:searchEntity('LayerCamera'); + self.camera = self.layerEntity:getComponent('Camera') + self.expand_tile_trans = self.entity:searchEntity("expand_tile"):getComponent("Transform") + self.father_trans = self.entity:searchEntity("father_trans"):getComponent("Transform") + self.child_trans = self.entity:searchEntity("child_trans"):getComponent("Transform") + self.p0_father_trans = self.entity:searchEntity("p0_father_trans"):getComponent("Transform") + self.p0_child_trans = self.entity:searchEntity("p0_child_trans"):getComponent("Transform") + self.p1_father_trans = self.entity:searchEntity("p1_father_trans"):getComponent("Transform") + self.p1_child_trans = self.entity:searchEntity("p1_child_trans"):getComponent("Transform") + self.renderer = self.entity:searchEntity('expand_tile'):getComponent('MeshRenderer') + self.renderer.useFrustumCulling = false + self.material = self.renderer.material +end + +local PositionDict = { + xPosition = {'position', 'x'}, + yPosition = {'position', 'y'}, + zPosition = {'position', 'z'}, + p0_xPosition = {'p0_position', 'x'}, + p0_yPosition = {'p0_position', 'y'}, + p0_zPosition = {'p0_position', 'z'}, + p1_xPosition = {'p1_position', 'x'}, + p1_yPosition = {'p1_position', 'y'}, + p1_zPosition = {'p1_position', 'z'}, +} + +function LumiLayer:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value) + if self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if key == 'position' + or key == 'anchorPoint' + or key == 'scale' + or key == 'orientation' + or key == 'p0_position' + or key == 'p0_anchorPoint' + or key == 'p0_scale' + or key == 'p0_orientation' + or key == 'p1_position' + or key == 'p1_anchorPoint' + or key == 'p1_scale' + or key == 'p1_orientation' + then + if value.z ~= nil then + _setEffectAttr(key, value) + else + -- Vector2f to Vector3f + _setEffectAttr(key, Amaz.Vector3f(value.x, value.y, 0)) + end + elseif PositionDict[key] ~= nil then + local newKey = PositionDict[key][1] + local dimension = PositionDict[key][2] + self[newKey][dimension] = value + _setEffectAttr(newKey, self[newKey]) + elseif key == 'blendMode' then + _setEffectAttr(key, BlendMode[value + 1]) + elseif key == 'matteMode' then + _setEffectAttr(key, MatteMode[value + 1]) + elseif key == 'layerType' then + if type(value) == 'string' then + _setEffectAttr(key, value) + else + _setEffectAttr(key, LayerType[value + 1]) + end + else + _setEffectAttr(key, value) + end +end + +function LumiLayer:_rotateByAEAxis(_trans, _direction, _euler_angle) + -- ae xyz, editor yxz + local right = Amaz.Vector3f(1.0, 0.0, 0.0) + local up = Amaz.Vector3f(0.0, 1.0, 0.0) + local forward = Amaz.Vector3f(0.0, 0.0, 1.0) + + local cur_orientation = Amaz.Quaternionf.axisAngleToQuaternion(right, math.rad(_direction.x)) + * Amaz.Quaternionf.axisAngleToQuaternion(up, -math.rad(_direction.y)) + * Amaz.Quaternionf.axisAngleToQuaternion(forward, -math.rad(_direction.z)) + + up = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, up) + right = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, right) + forward = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, forward) + + cur_orientation = Amaz.Quaternionf.axisAngleToQuaternion(right, math.rad(_euler_angle.x)) + * Amaz.Quaternionf.axisAngleToQuaternion(up, -math.rad(_euler_angle.y)) + * Amaz.Quaternionf.axisAngleToQuaternion(forward, -math.rad(_euler_angle.z)) + * cur_orientation + + _trans.localOrientation = cur_orientation +end + +function LumiLayer:updateTRS(ratio) + self.expand_tile_trans.localScale = Amaz.Vector3f(1.0+self.expandRight+self.expandLeft, 1.0+self.expandUp+self.expandDown, 1.0) + self.expand_tile_trans.localPosition = Amaz.Vector3f( + self.expandRight-self.expandLeft, + self.expandUp-self.expandDown, + 0.0 + ) + + local ratio_c = self.compositeSize.x / self.compositeSize.y + local pos_z0 = ratio / math.tan(math.rad(self.active_cam_fovx * 0.5)) + local compositeSizeZ = self.compositeSize.y * ratio_c / ratio + -- Amaz.LOGE(self.TAG, "compositeSizeZ: "..compositeSizeZ) + self.camera.fovy = 2 * math.deg(math.atan(1 / pos_z0)) + + local rotate = Amaz.Vector3f(self.xRotation, self.yRotation, self.rotation) + self:_rotateByAEAxis(self.father_trans, self.orientation, rotate) + self.father_trans.localPosition = Amaz.Vector3f( + (self.position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.position.y / self.compositeSize.y - 0.5) * 2, + -self.position.z * 2 / compositeSizeZ + ) + self.child_trans.localPosition = Amaz.Vector3f( + -(self.anchorPoint.x / self.layerSize.x - 0.5) * 2 * ratio, + -(1.0 - self.anchorPoint.y / self.layerSize.y - 0.5) * 2, + self.anchorPoint.z * 2 / compositeSizeZ + ) + self.child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + -- parent 0 + rotate = Amaz.Vector3f(self.p0_xRotation, self.p0_yRotation, self.p0_rotation) + self:_rotateByAEAxis(self.p0_father_trans, self.p0_orientation, rotate) + self.p0_father_trans.localPosition = Amaz.Vector3f( + (self.p0_position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.p0_position.y / self.compositeSize.y - 0.5) * 2, + -self.p0_position.z * 2 / compositeSizeZ + ) + self.p0_child_trans.localPosition = Amaz.Vector3f( + -(self.p0_anchorPoint.x / self.compositeSize.x - 0.5) * 2 * ratio, + -(1.0 - self.p0_anchorPoint.y / self.compositeSize.y - 0.5) * 2, + self.p0_anchorPoint.z * 2 / compositeSizeZ + ) + self.p0_child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + -- parent 1 + rotate = Amaz.Vector3f(self.p1_xRotation, self.p1_yRotation, self.p1_rotation) + self:_rotateByAEAxis(self.p1_father_trans, self.p1_orientation, rotate) + self.p1_father_trans.localPosition = Amaz.Vector3f( + (self.p1_position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.p1_position.y / self.compositeSize.y - 0.5) * 2, + -pos_z0 - self.p1_position.z * 2 / compositeSizeZ + ) + self.p1_child_trans.localPosition = Amaz.Vector3f( + -(self.p1_anchorPoint.x / self.compositeSize.x - 0.5) * 2 * ratio, + -(1.0 - self.p1_anchorPoint.y / self.compositeSize.y - 0.5) * 2, + self.p1_anchorPoint.z * 2 / compositeSizeZ + ) + self.p1_child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + self.father_trans.localScale = Amaz.Vector3f( + self.scale.x / 100.0 * (self.layerSize.x / self.compositeSize.x), + self.scale.y / 100.0 * (self.layerSize.y / self.compositeSize.y), + self.scale.z / 100.0 + ) + self.child_trans.localScale = Amaz.Vector3f(ratio, 1, 1) + self.p0_father_trans.localScale = self.p0_scale / 100.0 + self.p1_father_trans.localScale = self.p1_scale / 100.0 + + local mMat = self.expand_tile_trans:getWorldMatrix() + local vMat = self.camera:getWorldToCameraMatrix() + local pMat = self.camera.projectionMatrix + + return {vMat * mMat, pMat:invert_Full()} +end + +function LumiLayer:onUpdate(comp, deltaTime) + self.opacity = clamp(self.opacity, 0, 100) + local trsOpacity = 1.0 + local blendOpacity = 1.0 + if self.layerType == 'Adjustment' then + blendOpacity = self.opacity / 100.0 + else + trsOpacity = self.opacity / 100.0 + end + + local hasSrcTexture = false + if self.isVisible then + for _, duration in ipairs(self.srcDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + hasSrcTexture = true + break + end + end + end + + local needTrs = self.hasTransform and hasSrcTexture + local visible = needTrs or self.hasMatte or self.hasBlend + if self.layerEntity.visible ~= visible then + self:setEntityVisible(self.layerEntity, visible) + end + if visible == false then + return + end + + self.camera.renderTexture = self.OutputTex + self.material:setTex('u_sourceTexture', self.InputTex) + self.material:setTex('u_baseTexure', self.baseTex) + self.material:setTex('u_maskTexture', self.maskTex) + self.material:setInt('u_layerType', self.layerType == 'Adjustment' and 1 or 0) + + if needTrs then + local ratio = self.OutputTex.width / self.OutputTex.height + local mvp = self:updateTRS(ratio) + self.material:setInt('u_hasTrs', 1) + self.material:setMat4('u_mvMat', mvp[1]) + self.material:setMat4('u_pMat', mvp[2]) + self.material:setFloat('u_alpha', trsOpacity) + self.material:setFloat('u_mirrorEdge', self.mirrorEdge and 1 or 0) + else + self.material:setInt('u_hasTrs', 0) + end + + if hasSrcTexture then + self.material:setInt("u_hasSourceTexture", 1) + else + self.material:setInt("u_hasSourceTexture", 0) + end + + local enableMatte = false + if self.hasMatte and self.maskTex then + for _, duration in ipairs(self.matteDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + enableMatte = true + break + end + end + end + + if self.hasBlend then + local hasBaseTexture = false + for _, duration in ipairs(self.baseDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + hasBaseTexture = true + break + end + end + self.material:setInt("u_hasBlend", 1) + self.material:setInt("u_hasBaseTexture", hasBaseTexture and 1 or 0) + self.material:setInt("u_blendMode", BlendModeIndex[self.blendMode]) + self.material:setFloat("u_layerOpacity", blendOpacity) + else + self.material:setInt("u_hasBlend", 0) + end + + if self.hasMatte then + self.material:setInt('u_hasMatte', 1) + self.material:setInt("u_enableMatte", enableMatte and 1 or 0) + self.material:setInt("u_matteMode", MatteModeIndex[self.matteMode]) + else + self.material:setInt('u_hasMatte', 0) + end +end + +exports.LumiLayer = LumiLayer +return exports diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag b/scripts/7681552231262326017/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag new file mode 100644 index 0000000000000000000000000000000000000000..01561dcc590f6fbe28e9efccd32698c72f5eeb0f --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag @@ -0,0 +1,240 @@ +precision highp float; +precision highp int; + +uniform mediump int u_enableMatte; +uniform mediump sampler2D u_maskTexture; +uniform mediump int u_matteMode; +uniform mediump int u_layerType; +uniform mediump int u_hasMatte; +uniform float u_layerOpacity; +uniform mediump int u_hasBlend; +uniform mediump int u_hasBaseTexture; +uniform mediump sampler2D u_baseTexure; +uniform mediump int u_hasSourceTexture; +uniform mediump int u_hasTrs; +uniform mat4 u_mvMat; +uniform mat4 u_pMat; +uniform float u_mirrorEdge; +uniform mediump sampler2D u_sourceTexture; +uniform float u_alpha; + +varying vec2 uv0; + +vec4 _f1(vec3 _p0, vec3 _p1, vec3 _p2, vec3 _p3, vec3 _p4) +{ + vec3 _61 = _p3 - _p2; + vec3 _65 = _p4 - _p2; + vec3 _69 = cross(_p1, _65); + float _74 = dot(_61, _69); + if (_74 <= 1.0000000116860974230803549289703e-07) + { + return vec4(-1.0); + } + vec3 _87 = _p0 - _p2; + float _93 = dot(_87, _69) / _74; + if ((_93 < 0.0) || (_93 > 1.0)) + { + return vec4(-1.0); + } + vec3 _107 = cross(_87, _61); + float _113 = dot(_p1, _107) / _74; + bool _115 = _113 < 0.0; + bool _123; + if (!_115) + { + _123 = (_93 + _113) > 1.0; + } + else + { + _123 = _115; + } + if (_123) + { + return vec4(-1.0); + } + return vec4(_93, _113, dot(_65, _107) / _74, 1.0); +} + +vec2 _f2(mat4 _p0, mat4 _p1, vec2 _p2) +{ + vec3 _162 = (_p0 * vec4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + vec3 _168 = (_p0 * vec4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _173 = (_p0 * vec4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _178 = (_p0 * vec4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + vec4 _189 = _p1 * vec4((_p2 * 2.0) - vec2(1.0), 0.0, 1.0); + vec4 _t17 = _189; + vec3 _206 = normalize((_189.xyz / vec3(_t17.w)) - vec3(0.0)); + vec3 param = vec3(0.0); + vec3 param_1 = _206; + vec3 _214 = (_p0 * vec4(-10.0, -10.0, 0.0, 1.0)).xyz; + vec3 param_2 = _214; + vec3 param_3 = _162; + vec3 param_4 = _173; + vec4 _t21 = _f1(param, param_1, param_2, param_3, param_4); + vec3 param_5 = vec3(0.0); + vec3 param_6 = _206; + vec3 param_7 = _178; + vec3 param_8 = _168; + vec3 _231 = (_p0 * vec4(10.0, 10.0, 0.0, 1.0)).xyz; + vec3 param_9 = _231; + vec4 _t22 = _f1(param_5, param_6, param_7, param_8, param_9); + vec3 param_10 = vec3(0.0); + vec3 param_11 = _206; + vec3 param_12 = _214; + vec3 param_13 = _173; + vec3 param_14 = _162; + vec4 _t23 = _f1(param_10, param_11, param_12, param_13, param_14); + vec3 param_15 = vec3(0.0); + vec3 param_16 = _206; + vec3 param_17 = _178; + vec3 param_18 = _231; + vec3 param_19 = _168; + vec4 _t24 = _f1(param_15, param_16, param_17, param_18, param_19); + vec2 _397 = (((((((vec2(-4.5) * ((1.0 - _t21.x) - _t21.y)) + (vec2(5.5, -4.5) * _t21.x)) + (vec2(-4.5, 5.5) * _t21.y)) * step(0.0, _t21.w)) + ((((vec2(-4.5, 5.5) * ((1.0 - _t22.x) - _t22.y)) + (vec2(5.5, -4.5) * _t22.x)) + (vec2(5.5) * _t22.y)) * (step(_t21.w, 0.0) * step(0.0, _t22.w)))) + ((((vec2(-4.5) * ((1.0 - _t23.x) - _t23.y)) + (vec2(-4.5, 5.5) * _t23.x)) + (vec2(5.5, -4.5) * _t23.y)) * ((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(0.0, _t23.w)))) + ((((vec2(-4.5, 5.5) * ((1.0 - _t24.x) - _t24.y)) + (vec2(5.5) * _t24.x)) + (vec2(5.5, -4.5) * _t24.y)) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(0.0, _t24.w)))) + (vec2(-10000.0) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(_t24.w, 0.0))); + return _397; +} + +vec2 _f4(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +float _f3(vec2 _p0) +{ + vec2 _t30 = step(vec2(0.0), _p0) * step(_p0, vec2(1.0)); + return _t30.x * _t30.y; +} + +float _f0(vec3 _p0) +{ + return dot(_p0, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +vec4 _f5(vec4 _p0) +{ + vec4 _t31 = vec4(0.0); + if (u_enableMatte == 1) + { + _t31 = texture2D(u_maskTexture, uv0); + } + float _t32 = _t31.w; + if (u_matteMode == 1) + { + vec3 param = _t31.xyz; + _t32 = _f0(param); + } + else + { + if (u_matteMode == 2) + { + _t32 = 1.0 - _t31.w; + } + else + { + if (u_matteMode == 3) + { + vec3 param_1 = _t31.xyz; + _t32 = 1.0 - _f0(param_1); + } + } + } + return _p0 * _t32; +} + +vec4 _f6(inout vec4 _p0, inout vec4 _p1) +{ + float _483 = _p0.w; + vec4 _486 = _p0; + vec3 _489 = _486.xyz / vec3(max(_483, 9.9999997473787516355514526367188e-06)); + _p0.x = _489.x; + _p0.y = _489.y; + _p0.z = _489.z; + float _498 = _p1.w; + vec4 _500 = _p1; + vec3 _503 = _500.xyz / vec3(max(_498, 9.9999997473787516355514526367188e-06)); + _p1.x = _503.x; + _p1.y = _503.y; + _p1.z = _503.z; + vec4 _t33 = _p1; + _t33.x = _p0.xyz.x; + _t33.y = _p0.xyz.y; + _t33.z = _p0.xyz.z; + vec4 _t34 = vec4(0.0); + if (u_layerType == 1) + { + float _t35 = 1.0; + if (u_hasMatte == 1) + { + vec4 param = vec4(1.0); + _t35 = _f5(param).w; + } + vec4 _551 = mix(_p1, vec4(_t33.xyz, _p0.w), vec4(u_layerOpacity * _t35)); + _t34 = _551; + float _553 = _t34.w; + vec3 _556 = _551.xyz * _553; + _t34.x = _556.x; + _t34.y = _556.y; + _t34.z = _556.z; + } + else + { + vec3 _591 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t33.xyz * (_p0.w * _p1.w)); + _t34.x = _591.x; + _t34.y = _591.y; + _t34.z = _591.z; + _t34.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t34; +} + +void main() +{ + vec4 _t36 = vec4(0.0); + bool _614 = u_hasBlend == 1; + if (_614) + { + if (u_hasBaseTexture == 1) + { + _t36 = texture2D(u_baseTexure, uv0); + } + if (u_hasSourceTexture == 0) + { + gl_FragData[0] = _t36; + return; + } + } + vec4 _t37 = vec4(0.0); + if (u_hasTrs == 1) + { + mat4 param = u_mvMat; + mat4 param_1 = u_pMat; + vec2 param_2 = uv0; + vec2 _652 = _f2(param, param_1, param_2); + float _656 = step(u_mirrorEdge, 0.5); + vec2 param_3 = _652; + vec2 _666 = (_652 * _656) + (_f4(param_3) * (1.0 - _656)); + vec2 param_4 = _666; + _t37 = (texture2D(u_sourceTexture, _666) * u_alpha) * _f3(param_4); + } + else + { + if (u_hasSourceTexture == 1) + { + _t37 = texture2D(u_sourceTexture, uv0); + } + } + if ((u_layerType != 1) && (u_hasMatte == 1)) + { + vec4 param_5 = _t37; + _t37 = _f5(param_5); + } + if (_614) + { + vec4 param_6 = _t37; + vec4 param_7 = _t36; + vec4 _704 = _f6(param_6, param_7); + _t37 = _704; + } + gl_FragData[0] = _t37; +} + diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681552231262326017/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..705dd9f8b691def7eaafc9c1b6e2528c0b0c0165 --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag b/scripts/7681552231262326017/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag new file mode 100644 index 0000000000000000000000000000000000000000..7b5f204904818053699abc060be6bfa62f2ab74e --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag @@ -0,0 +1,268 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + int u_enableMatte; + int u_matteMode; + int u_layerType; + int u_hasMatte; + float u_layerOpacity; + int u_hasBlend; + int u_hasBaseTexture; + int u_hasSourceTexture; + int u_hasTrs; + float4x4 u_mvMat; + float4x4 u_pMat; + float u_mirrorEdge; + float u_alpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f1(thread const float3& _p0, thread const float3& _p1, thread const float3& _p2, thread const float3& _p3, thread const float3& _p4) +{ + float3 _61 = _p3 - _p2; + float3 _65 = _p4 - _p2; + float3 _69 = cross(_p1, _65); + float _74 = dot(_61, _69); + if (_74 <= 1.0000000116860974230803549289703e-07) + { + return float4(-1.0); + } + float3 _87 = _p0 - _p2; + float _93 = dot(_87, _69) / _74; + if ((_93 < 0.0) || (_93 > 1.0)) + { + return float4(-1.0); + } + float3 _107 = cross(_87, _61); + float _113 = dot(_p1, _107) / _74; + bool _115 = _113 < 0.0; + bool _123; + if (!_115) + { + _123 = (_93 + _113) > 1.0; + } + else + { + _123 = _115; + } + if (_123) + { + return float4(-1.0); + } + return float4(_93, _113, dot(_65, _107) / _74, 1.0); +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float4x4& _p0, thread const float4x4& _p1, thread const float2& _p2) +{ + float3 _162 = (_p0 * float4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + float3 _168 = (_p0 * float4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _173 = (_p0 * float4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _178 = (_p0 * float4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + float4 _189 = _p1 * float4((_p2 * 2.0) - float2(1.0), 0.0, 1.0); + float4 _t17 = _189; + float3 _206 = fast::normalize((_189.xyz / float3(_t17.w)) - float3(0.0)); + float3 param = float3(0.0); + float3 param_1 = _206; + float3 _214 = (_p0 * float4(-10.0, -10.0, 0.0, 1.0)).xyz; + float3 param_2 = _214; + float3 param_3 = _162; + float3 param_4 = _173; + float4 _t21 = _f1(param, param_1, param_2, param_3, param_4); + float3 param_5 = float3(0.0); + float3 param_6 = _206; + float3 param_7 = _178; + float3 param_8 = _168; + float3 _231 = (_p0 * float4(10.0, 10.0, 0.0, 1.0)).xyz; + float3 param_9 = _231; + float4 _t22 = _f1(param_5, param_6, param_7, param_8, param_9); + float3 param_10 = float3(0.0); + float3 param_11 = _206; + float3 param_12 = _214; + float3 param_13 = _173; + float3 param_14 = _162; + float4 _t23 = _f1(param_10, param_11, param_12, param_13, param_14); + float3 param_15 = float3(0.0); + float3 param_16 = _206; + float3 param_17 = _178; + float3 param_18 = _231; + float3 param_19 = _168; + float4 _t24 = _f1(param_15, param_16, param_17, param_18, param_19); + float2 _397 = (((((((float2(-4.5) * ((1.0 - _t21.x) - _t21.y)) + (float2(5.5, -4.5) * _t21.x)) + (float2(-4.5, 5.5) * _t21.y)) * step(0.0, _t21.w)) + ((((float2(-4.5, 5.5) * ((1.0 - _t22.x) - _t22.y)) + (float2(5.5, -4.5) * _t22.x)) + (float2(5.5) * _t22.y)) * (step(_t21.w, 0.0) * step(0.0, _t22.w)))) + ((((float2(-4.5) * ((1.0 - _t23.x) - _t23.y)) + (float2(-4.5, 5.5) * _t23.x)) + (float2(5.5, -4.5) * _t23.y)) * ((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(0.0, _t23.w)))) + ((((float2(-4.5, 5.5) * ((1.0 - _t24.x) - _t24.y)) + (float2(5.5) * _t24.x)) + (float2(5.5, -4.5) * _t24.y)) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(0.0, _t24.w)))) + (float2(-10000.0) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(_t24.w, 0.0))); + return _397; +} + +static inline __attribute__((always_inline)) +float2 _f4(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0) +{ + float2 _t30 = step(float2(0.0), _p0) * step(_p0, float2(1.0)); + return _t30.x * _t30.y; +} + +static inline __attribute__((always_inline)) +float _f0(thread const float3& _p0) +{ + return dot(_p0, float3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread const float4& _p0, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode) +{ + float4 _t31 = float4(0.0); + if (u_enableMatte == 1) + { + _t31 = u_maskTexture.sample(u_maskTextureSmplr, uv0); + } + float _t32 = _t31.w; + if (u_matteMode == 1) + { + float3 param = _t31.xyz; + _t32 = _f0(param); + } + else + { + if (u_matteMode == 2) + { + _t32 = 1.0 - _t31.w; + } + else + { + if (u_matteMode == 3) + { + float3 param_1 = _t31.xyz; + _t32 = 1.0 - _f0(param_1); + } + } + } + return _p0 * _t32; +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, thread float4& _p1, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode, constant int& u_layerType, constant int& u_hasMatte, constant float& u_layerOpacity) +{ + float _483 = _p0.w; + float4 _486 = _p0; + float3 _489 = _486.xyz / float3(fast::max(_483, 9.9999997473787516355514526367188e-06)); + _p0.x = _489.x; + _p0.y = _489.y; + _p0.z = _489.z; + float _498 = _p1.w; + float4 _500 = _p1; + float3 _503 = _500.xyz / float3(fast::max(_498, 9.9999997473787516355514526367188e-06)); + _p1.x = _503.x; + _p1.y = _503.y; + _p1.z = _503.z; + float4 _t33 = _p1; + _t33.x = _p0.xyz.x; + _t33.y = _p0.xyz.y; + _t33.z = _p0.xyz.z; + float4 _t34 = float4(0.0); + if (u_layerType == 1) + { + float _t35 = 1.0; + if (u_hasMatte == 1) + { + float4 param = float4(1.0); + _t35 = _f5(param, u_enableMatte, u_maskTexture, u_maskTextureSmplr, uv0, u_matteMode).w; + } + float4 _551 = mix(_p1, float4(_t33.xyz, _p0.w), float4(u_layerOpacity * _t35)); + _t34 = _551; + float _553 = _t34.w; + float3 _556 = _551.xyz * _553; + _t34.x = _556.x; + _t34.y = _556.y; + _t34.z = _556.z; + } + else + { + float3 _591 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t33.xyz * (_p0.w * _p1.w)); + _t34.x = _591.x; + _t34.y = _591.y; + _t34.z = _591.z; + _t34.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t34; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_maskTexture [[texture(0)]], texture2d u_baseTexure [[texture(1)]], texture2d u_sourceTexture [[texture(2)]], sampler u_maskTextureSmplr [[sampler(0)]], sampler u_baseTexureSmplr [[sampler(1)]], sampler u_sourceTextureSmplr [[sampler(2)]]) +{ + main0_out out = {}; + float4 _t36 = float4(0.0); + bool _614 = buffer.u_hasBlend == 1; + if (_614) + { + if (buffer.u_hasBaseTexture == 1) + { + _t36 = u_baseTexure.sample(u_baseTexureSmplr, in.uv0); + } + if (buffer.u_hasSourceTexture == 0) + { + out.o_fragColor = _t36; + return out; + } + } + float4 _t37 = float4(0.0); + if (buffer.u_hasTrs == 1) + { + float4x4 param = buffer.u_mvMat; + float4x4 param_1 = buffer.u_pMat; + float2 param_2 = in.uv0; + float2 _652 = _f2(param, param_1, param_2); + float _656 = step(buffer.u_mirrorEdge, 0.5); + float2 param_3 = _652; + float2 _666 = (_652 * _656) + (_f4(param_3) * (1.0 - _656)); + float2 param_4 = _666; + _t37 = (u_sourceTexture.sample(u_sourceTextureSmplr, _666) * buffer.u_alpha) * _f3(param_4); + } + else + { + if (buffer.u_hasSourceTexture == 1) + { + _t37 = u_sourceTexture.sample(u_sourceTextureSmplr, in.uv0); + } + } + if ((buffer.u_layerType != 1) && (buffer.u_hasMatte == 1)) + { + float4 param_5 = _t37; + _t37 = _f5(param_5, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode); + } + if (_614) + { + float4 param_6 = _t37; + float4 param_7 = _t36; + float4 _704 = _f6(param_6, param_7, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode, buffer.u_layerType, buffer.u_hasMatte, buffer.u_layerOpacity); + _t37 = _704; + } + out.o_fragColor = _t37; + return out; +} + diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681552231262326017/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..d7349349d1805ff40c01eddcceaf24b19c0e17d2 --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiMotionBlur2D/MotionBlur2D.lua b/scripts/7681552231262326017/AmazingFeature/effects/LumiMotionBlur2D/MotionBlur2D.lua new file mode 100644 index 0000000000000000000000000000000000000000..d83978c2f9b31ed6ad4750add08f35d33541be09 --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiMotionBlur2D/MotionBlur2D.lua @@ -0,0 +1,199 @@ +local exports = exports or {} +local MotionBlur2D = MotionBlur2D or {} +MotionBlur2D.__index = MotionBlur2D +---@class MotionBlur2D: ScriptComponent +---@field currRotate double [UI(Range={0, 360}, Slider)] +---@field currAnchor Vector2f [UI(Drag=0.01)] +---@field currPosition Vector2f [UI(Drag=0.01)] +---@field unifiedScale boolean +---@field currScale Vector2f [UI(Drag=0.01)] +---@field vIntensity double [UI(Range={0, 2}, Slider)] +---@field vCenter double [UI(Range={-1, 1}, Slider)] +---@field minSamples double [UI(Range={0, 256}, Slider)] +---@field maxSamples double [UI(Range={0, 256}, Slider)] +---@field dither double [UI(Range={0, 1}, Slider)] +---@field mirrorEdge boolean +---@field InputTex Texture +---@field OutputTex Texture + +function MotionBlur2D.new(construct, ...) + local self = setmetatable({}, MotionBlur2D) + if construct and MotionBlur2D.constructor then + MotionBlur2D.constructor(self, ...) + end + self.startTime = 0.0 + self.endTime = 1.0 + self.curTime = 0.0 + self.firstSeek = true + + self.prevRotate = 0 + self.prevPosition = Amaz.Vector2f(0., 0.) + self.prevScale = Amaz.Vector2f(1, 1) + self.prevAnchor = Amaz.Vector2f(0., 0.) + self.currRotate = 0 + self.currPosition = Amaz.Vector2f(0., 0.) + self.currScale = Amaz.Vector2f(1, 1) + self.currAnchor = Amaz.Vector2f(0., 0.) + self.positionVec2Vector = Amaz.Vec2Vector() + + self.vIntensity = 1.0 + self.vCenter = 0.0 + self.minSamples = 2.0 + self.maxSamples = 24.0 + self.dither = 1.0 + self.mirrorEdge = false + self.unifiedScale = false + + self.InputTex = nil + self.OutputTex = nil + return self +end + +function MotionBlur2D:constructor() +end + +function MotionBlur2D:onUpdate(comp, detalTime) + self:seekToTime(comp, detalTime) + + self.material:setTex("u_inputImageTexture", self.InputTex) + self.cam.renderTexture = self.OutputTex +end + +function MotionBlur2D:start(comp) + self.first = true + self.material = comp.entity:searchEntity("motion_blur_2d"):getComponent("MeshRenderer").material + self.cam = comp.entity:searchEntity("cam"):getComponent("Camera") +end + +function MotionBlur2D:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value) + if self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if key == "maxSamples" or key == "minSamples" then + _setEffectAttr(key, math.floor(value * 100)) + elseif key == "rotate" then + _setEffectAttr("currRotate", value) + elseif key == "ae_pre_rotate" then + _setEffectAttr("prevRotate", value) + elseif key == "scale_x" or key == "scale_y" then + local currScale = self["currScale"] + if currScale then + if math.abs(value)<0.001 then value = 0.001 end + if key == "scale_x" then + currScale.x = value + else + currScale.y = value + end + _setEffectAttr("currScale", currScale) + end + elseif key == "position" then + local currPosition = self["currPosition"] + if currPosition then + currPosition.x = value.x - 0.5 + currPosition.y = value.y - 0.5 + _setEffectAttr("currPosition", currPosition) + end + elseif key == "ae_pre_position" then + local prevPosition = self["prevPosition"] + if prevPosition then + prevPosition.x = value.x - 0.5 + prevPosition.y = value.y - 0.5 + _setEffectAttr("prevPosition", prevPosition) + end + elseif key == "anchor" then + local currAnchor = self["currAnchor"] + if currAnchor then + currAnchor.x = value.x - 0.5 + currAnchor.y = value.y - 0.5 + _setEffectAttr("currAnchor", currAnchor) + end + elseif key == "ae_pre_anchor" then + local prevAnchor = self["prevAnchor"] + if prevAnchor then + prevAnchor.x = value.x - 0.5 + prevAnchor.y = value.y - 0.5 + _setEffectAttr("prevAnchor", prevAnchor) + end + elseif key == "ae_pre_scale_x" or key == "ae_pre_scale_y" then + local prevScale = self["prevScale"] + if prevScale then + if math.abs(value)<0.001 then value = 0.001 end + if key == "ae_pre_scale_x" then + prevScale.x = value + else + prevScale.y = value + end + _setEffectAttr("prevScale", prevScale) + end + else + _setEffectAttr(key, value) + end + +end + +function MotionBlur2D:seekToTime(comp, time) + if self.first == nil then + self:start(comp) + end + + self.curTime = (self.curTime + time)%(self.endTime - self.startTime) + + local pointSize = 5; + local pivotVec2Vector = Amaz.Vec2Vector() + local positionVec2Vector = Amaz.Vec2Vector() + local scaleVec2Vector = Amaz.Vec2Vector() + local rotationFloatVector = Amaz.FloatVector() + for i=0,pointSize,1 do + local w = (self.vIntensity * (i/pointSize) + self.vCenter + 1.0); + -- Offset keyframe with curve + -- local frameTime = 1./ 90.0 + -- local AEprogress = progress + frameTime*(w-1.0) + -- positionVec2Vector:pushBack(self:getOffset(AEprogress)) + local pivot = self.prevAnchor * (1.0-w) + self.currAnchor * w; + local position = self.prevPosition * (1.0-w) + self.currPosition * w; + local scale = self.prevScale * (1.0-w) + self.currScale * w; + if self.unifiedScale then + scale.y = scale.x + end + local rotation = self.prevRotate * (1.0-w) + self.currRotate * w; + pivotVec2Vector:pushBack(pivot) + positionVec2Vector:pushBack(position) + scaleVec2Vector:pushBack(scale) + rotationFloatVector:pushBack(rotation) + end + self.material:setVec2Vector("u_pivotVec2Vector", pivotVec2Vector) + if self.positionVec2Vector:empty() then + self.material:setVec2Vector("u_positionVec2Vector", positionVec2Vector) + else + self.material:setVec2Vector("u_positionVec2Vector", self.positionVec2Vector) + end + self.material:setVec2Vector("u_scaleVec2Vector", scaleVec2Vector) + self.material:setFloatVector("u_rotationFloatVector", rotationFloatVector) + + self.material:setFloat("u_minSamples", self.minSamples); + self.material:setFloat("u_maxSamples", self.maxSamples); + self.material:setFloat("u_dither", self.dither); + self.material:setFloat("u_mirrorEdge", self.mirrorEdge and 1 or 0) + if math.abs(self.vIntensity) < 0.001 then + self.material:setInt("u_skipSample", 1) + else + self.material:setInt("u_skipSample", 0) + end +end + +function MotionBlur2D:onLateUpdate(comp, detalTime) + +end + +local function clamp(val, min, max) + return math.max(math.min(val, max), min) +end + +exports.MotionBlur2D = MotionBlur2D +return exports diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiMotionBlur2D/shaderLib/shaderGLES/93ab10f0e935e0bc691355370bc4cc5d.frag b/scripts/7681552231262326017/AmazingFeature/effects/LumiMotionBlur2D/shaderLib/shaderGLES/93ab10f0e935e0bc691355370bc4cc5d.frag new file mode 100644 index 0000000000000000000000000000000000000000..f312dbc929647fba08987c5bceaa20ae2ebd5a11 --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiMotionBlur2D/shaderLib/shaderGLES/93ab10f0e935e0bc691355370bc4cc5d.frag @@ -0,0 +1,142 @@ +precision highp float; +precision highp int; + +uniform vec4 u_ScreenParams; +uniform mediump int u_skipSample; +uniform float u_rotationFloatVector[6]; +uniform vec2 u_positionVec2Vector[6]; +uniform vec2 u_pivotVec2Vector[6]; +uniform vec2 u_scaleVec2Vector[6]; +uniform float u_mirrorEdge; +uniform mediump sampler2D u_inputImageTexture; +uniform float u_minSamples; +uniform float u_maxSamples; +uniform float u_dither; + +varying vec2 uv0; + +vec2 _f0(inout vec2 _p0, float _p1, vec2 _p2, vec2 _p3, vec2 _p4) +{ + _p0 -= _p2; + _p0 -= vec2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _66 = sin(_p1); + float _69 = cos(_p1); + _p0 = mat2(vec2(_69, _66), vec2(-_66, _69)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 *= (vec2(1.0) / _p4); + _p0 += vec2(0.5); + _p0 += _p3; + return _p0; +} + +vec2 _f1(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +float _f2(vec2 _p0) +{ + return ((step(0.0, _p0.x) * step(0.0, _p0.y)) * step(_p0.x, 1.0)) * step(_p0.y, 1.0); +} + +float _f4(float _p0, float _p1) +{ + vec2 _218 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t3 = _218 + vec2(dot(_218, _218.yx + vec2(22.5410003662109375))); + return fract((_t3.x + _t3.y) * _t3.y); +} + +vec2 _f3(float _p0, vec2 _p1, vec2 _p2, vec2 _p3, vec2 _p4, vec2 _p5, vec2 _p6) +{ + return ((((mix(_p1, _p2, vec2(_p0 * 5.0)) * step(_p0, 0.20000000298023223876953125)) + ((mix(_p2, _p3, vec2((_p0 * 5.0) - 1.0)) * (1.0 - step(_p0, 0.20000000298023223876953125))) * step(_p0, 0.4000000059604644775390625))) + ((mix(_p3, _p4, vec2((_p0 * 5.0) - 2.0)) * (1.0 - step(_p0, 0.4000000059604644775390625))) * step(_p0, 0.60000002384185791015625))) + ((mix(_p4, _p5, vec2((_p0 * 5.0) - 3.0)) * (1.0 - step(_p0, 0.60000002384185791015625))) * step(_p0, 0.800000011920928955078125))) + (mix(_p5, _p6, vec2((_p0 * 5.0) - 4.0)) * (1.0 - step(_p0, 0.800000011920928955078125))); +} + +void main() +{ + if (u_skipSample == 1) + { + vec2 param = uv0; + float param_1 = (u_rotationFloatVector[0] * 3.141592502593994140625) / 180.0; + vec2 param_2 = u_positionVec2Vector[0]; + vec2 param_3 = u_pivotVec2Vector[0]; + vec2 param_4 = u_scaleVec2Vector[0]; + vec2 _281 = _f0(param, param_1, param_2, param_3, param_4); + float _284 = step(u_mirrorEdge, 0.5); + vec2 param_5 = _281; + vec2 _294 = (_281 * _284) + (_f1(param_5) * (1.0 - _284)); + vec2 param_6 = _294; + gl_FragData[0] = texture2D(u_inputImageTexture, _294) * _f2(param_6); + return; + } + vec2 param_7 = uv0; + float param_8 = (u_rotationFloatVector[0] * 3.141592502593994140625) / 180.0; + vec2 param_9 = u_positionVec2Vector[0]; + vec2 param_10 = u_pivotVec2Vector[0]; + vec2 param_11 = u_scaleVec2Vector[0]; + vec2 _326 = _f0(param_7, param_8, param_9, param_10, param_11); + vec2 param_12 = uv0; + float param_13 = (u_rotationFloatVector[1] * 3.141592502593994140625) / 180.0; + vec2 param_14 = u_positionVec2Vector[1]; + vec2 param_15 = u_pivotVec2Vector[1]; + vec2 param_16 = u_scaleVec2Vector[1]; + vec2 _344 = _f0(param_12, param_13, param_14, param_15, param_16); + vec2 param_17 = uv0; + float param_18 = (u_rotationFloatVector[2] * 3.141592502593994140625) / 180.0; + vec2 param_19 = u_positionVec2Vector[2]; + vec2 param_20 = u_pivotVec2Vector[2]; + vec2 param_21 = u_scaleVec2Vector[2]; + vec2 _363 = _f0(param_17, param_18, param_19, param_20, param_21); + vec2 param_22 = uv0; + float param_23 = (u_rotationFloatVector[3] * 3.141592502593994140625) / 180.0; + vec2 param_24 = u_positionVec2Vector[3]; + vec2 param_25 = u_pivotVec2Vector[3]; + vec2 param_26 = u_scaleVec2Vector[3]; + vec2 _382 = _f0(param_22, param_23, param_24, param_25, param_26); + vec2 param_27 = uv0; + float param_28 = (u_rotationFloatVector[4] * 3.141592502593994140625) / 180.0; + vec2 param_29 = u_positionVec2Vector[4]; + vec2 param_30 = u_pivotVec2Vector[4]; + vec2 param_31 = u_scaleVec2Vector[4]; + vec2 _401 = _f0(param_27, param_28, param_29, param_30, param_31); + vec2 param_32 = uv0; + float param_33 = (u_rotationFloatVector[5] * 3.141592502593994140625) / 180.0; + vec2 param_34 = u_positionVec2Vector[5]; + vec2 param_35 = u_pivotVec2Vector[5]; + vec2 param_36 = u_scaleVec2Vector[5]; + vec2 _420 = _f0(param_32, param_33, param_34, param_35, param_36); + float _424 = max(u_minSamples, 2.0); + float _442 = floor(_424 + ((max(u_maxSamples, _424) - _424) * smoothstep(0.0, 0.20000000298023223876953125, length(_420 - _326)))); + vec4 _t14 = vec4(0.0); + for (float _t15 = 0.0; _t15 <= 256.0; _t15 += 1.0) + { + if (_t15 >= _442) + { + break; + } + float _t16 = _t15 / (_442 - 1.0); + float param_37 = _t15 + uv0.x; + float param_38 = _t15 * uv0.y; + float _484 = _t16; + float _485 = _484 + ((u_dither * (_f4(param_37, param_38) - 0.5)) / _442); + _t16 = _485; + float param_39 = _485; + vec2 param_40 = _326; + vec2 param_41 = _344; + vec2 param_42 = _363; + vec2 param_43 = _382; + vec2 param_44 = _401; + vec2 param_45 = _420; + vec2 _501 = _f3(param_39, param_40, param_41, param_42, param_43, param_44, param_45); + float _503 = step(u_mirrorEdge, 0.5); + vec2 param_46 = _501; + vec2 _513 = (_501 * _503) + (_f1(param_46) * (1.0 - _503)); + vec2 param_47 = _513; + _t14 += (texture2D(u_inputImageTexture, _513) * _f2(param_47)); + } + vec4 _526 = _t14; + vec4 _528 = _526 / vec4(_442); + _t14 = _528; + gl_FragData[0] = _528; +} + diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiMotionBlur2D/shaderLib/shaderGLES/93ab10f0e935e0bc691355370bc4cc5d.vert b/scripts/7681552231262326017/AmazingFeature/effects/LumiMotionBlur2D/shaderLib/shaderGLES/93ab10f0e935e0bc691355370bc4cc5d.vert new file mode 100644 index 0000000000000000000000000000000000000000..6f2b17f0434964051cb3004b8be4c637742a6fe9 --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiMotionBlur2D/shaderLib/shaderGLES/93ab10f0e935e0bc691355370bc4cc5d.vert @@ -0,0 +1,11 @@ + +attribute vec3 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = vec4(a_position, 1.0); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiMotionBlur2D/shaderLib/shaderMetal/93ab10f0e935e0bc691355370bc4cc5d.frag b/scripts/7681552231262326017/AmazingFeature/effects/LumiMotionBlur2D/shaderLib/shaderMetal/93ab10f0e935e0bc691355370bc4cc5d.frag new file mode 100644 index 0000000000000000000000000000000000000000..e2be9b1215be7570e295b1465464f7fe3ffd363a --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiMotionBlur2D/shaderLib/shaderMetal/93ab10f0e935e0bc691355370bc4cc5d.frag @@ -0,0 +1,209 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + float4 u_ScreenParams; + int u_skipSample; + spvUnsafeArray u_rotationFloatVector; + spvUnsafeArray u_positionVec2Vector; + spvUnsafeArray u_pivotVec2Vector; + spvUnsafeArray u_scaleVec2Vector; + float u_mirrorEdge; + float u_minSamples; + float u_maxSamples; + float u_dither; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f0(thread float2& _p0, thread const float& _p1, thread const float2& _p2, thread const float2& _p3, thread const float2& _p4, constant float4& u_ScreenParams) +{ + _p0 -= _p2; + _p0 -= float2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _66 = sin(_p1); + float _69 = cos(_p1); + _p0 = float2x2(float2(_69, _66), float2(-_66, _69)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 *= (float2(1.0) / _p4); + _p0 += float2(0.5); + _p0 += _p3; + return _p0; +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float _f2(thread const float2& _p0) +{ + return ((step(0.0, _p0.x) * step(0.0, _p0.y)) * step(_p0.x, 1.0)) * step(_p0.y, 1.0); +} + +static inline __attribute__((always_inline)) +float _f4(thread const float& _p0, thread const float& _p1) +{ + float2 _218 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t3 = _218 + float2(dot(_218, _218.yx + float2(22.5410003662109375))); + return fract((_t3.x + _t3.y) * _t3.y); +} + +static inline __attribute__((always_inline)) +float2 _f3(thread const float& _p0, thread const float2& _p1, thread const float2& _p2, thread const float2& _p3, thread const float2& _p4, thread const float2& _p5, thread const float2& _p6) +{ + return ((((mix(_p1, _p2, float2(_p0 * 5.0)) * step(_p0, 0.20000000298023223876953125)) + ((mix(_p2, _p3, float2((_p0 * 5.0) - 1.0)) * (1.0 - step(_p0, 0.20000000298023223876953125))) * step(_p0, 0.4000000059604644775390625))) + ((mix(_p3, _p4, float2((_p0 * 5.0) - 2.0)) * (1.0 - step(_p0, 0.4000000059604644775390625))) * step(_p0, 0.60000002384185791015625))) + ((mix(_p4, _p5, float2((_p0 * 5.0) - 3.0)) * (1.0 - step(_p0, 0.60000002384185791015625))) * step(_p0, 0.800000011920928955078125))) + (mix(_p5, _p6, float2((_p0 * 5.0) - 4.0)) * (1.0 - step(_p0, 0.800000011920928955078125))); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputImageTexture [[texture(0)]], sampler u_inputImageTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + if (buffer.u_skipSample == 1) + { + float2 param = in.uv0; + float param_1 = (buffer.u_rotationFloatVector[0] * 3.141592502593994140625) / 180.0; + float2 param_2 = buffer.u_positionVec2Vector[0]; + float2 param_3 = buffer.u_pivotVec2Vector[0]; + float2 param_4 = buffer.u_scaleVec2Vector[0]; + float2 _281 = _f0(param, param_1, param_2, param_3, param_4, buffer.u_ScreenParams); + float _284 = step(buffer.u_mirrorEdge, 0.5); + float2 param_5 = _281; + float2 _294 = (_281 * _284) + (_f1(param_5) * (1.0 - _284)); + float2 param_6 = _294; + out.o_fragColor = u_inputImageTexture.sample(u_inputImageTextureSmplr, _294) * _f2(param_6); + return out; + } + float2 param_7 = in.uv0; + float param_8 = (buffer.u_rotationFloatVector[0] * 3.141592502593994140625) / 180.0; + float2 param_9 = buffer.u_positionVec2Vector[0]; + float2 param_10 = buffer.u_pivotVec2Vector[0]; + float2 param_11 = buffer.u_scaleVec2Vector[0]; + float2 _326 = _f0(param_7, param_8, param_9, param_10, param_11, buffer.u_ScreenParams); + float2 param_12 = in.uv0; + float param_13 = (buffer.u_rotationFloatVector[1] * 3.141592502593994140625) / 180.0; + float2 param_14 = buffer.u_positionVec2Vector[1]; + float2 param_15 = buffer.u_pivotVec2Vector[1]; + float2 param_16 = buffer.u_scaleVec2Vector[1]; + float2 _344 = _f0(param_12, param_13, param_14, param_15, param_16, buffer.u_ScreenParams); + float2 param_17 = in.uv0; + float param_18 = (buffer.u_rotationFloatVector[2] * 3.141592502593994140625) / 180.0; + float2 param_19 = buffer.u_positionVec2Vector[2]; + float2 param_20 = buffer.u_pivotVec2Vector[2]; + float2 param_21 = buffer.u_scaleVec2Vector[2]; + float2 _363 = _f0(param_17, param_18, param_19, param_20, param_21, buffer.u_ScreenParams); + float2 param_22 = in.uv0; + float param_23 = (buffer.u_rotationFloatVector[3] * 3.141592502593994140625) / 180.0; + float2 param_24 = buffer.u_positionVec2Vector[3]; + float2 param_25 = buffer.u_pivotVec2Vector[3]; + float2 param_26 = buffer.u_scaleVec2Vector[3]; + float2 _382 = _f0(param_22, param_23, param_24, param_25, param_26, buffer.u_ScreenParams); + float2 param_27 = in.uv0; + float param_28 = (buffer.u_rotationFloatVector[4] * 3.141592502593994140625) / 180.0; + float2 param_29 = buffer.u_positionVec2Vector[4]; + float2 param_30 = buffer.u_pivotVec2Vector[4]; + float2 param_31 = buffer.u_scaleVec2Vector[4]; + float2 _401 = _f0(param_27, param_28, param_29, param_30, param_31, buffer.u_ScreenParams); + float2 param_32 = in.uv0; + float param_33 = (buffer.u_rotationFloatVector[5] * 3.141592502593994140625) / 180.0; + float2 param_34 = buffer.u_positionVec2Vector[5]; + float2 param_35 = buffer.u_pivotVec2Vector[5]; + float2 param_36 = buffer.u_scaleVec2Vector[5]; + float2 _420 = _f0(param_32, param_33, param_34, param_35, param_36, buffer.u_ScreenParams); + float _424 = fast::max(buffer.u_minSamples, 2.0); + float _442 = floor(_424 + ((fast::max(buffer.u_maxSamples, _424) - _424) * smoothstep(0.0, 0.20000000298023223876953125, length(_420 - _326)))); + float4 _t14 = float4(0.0); + for (float _t15 = 0.0; _t15 <= 256.0; _t15 += 1.0) + { + if (_t15 >= _442) + { + break; + } + float _t16 = _t15 / (_442 - 1.0); + float param_37 = _t15 + in.uv0.x; + float param_38 = _t15 * in.uv0.y; + float _484 = _t16; + float _485 = _484 + ((buffer.u_dither * (_f4(param_37, param_38) - 0.5)) / _442); + _t16 = _485; + float param_39 = _485; + float2 param_40 = _326; + float2 param_41 = _344; + float2 param_42 = _363; + float2 param_43 = _382; + float2 param_44 = _401; + float2 param_45 = _420; + float2 _501 = _f3(param_39, param_40, param_41, param_42, param_43, param_44, param_45); + float _503 = step(buffer.u_mirrorEdge, 0.5); + float2 param_46 = _501; + float2 _513 = (_501 * _503) + (_f1(param_46) * (1.0 - _503)); + float2 param_47 = _513; + _t14 += (u_inputImageTexture.sample(u_inputImageTextureSmplr, _513) * _f2(param_47)); + } + float4 _526 = _t14; + float4 _528 = _526 / float4(_442); + _t14 = _528; + out.o_fragColor = _528; + return out; +} + diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiMotionBlur2D/shaderLib/shaderMetal/93ab10f0e935e0bc691355370bc4cc5d.vert b/scripts/7681552231262326017/AmazingFeature/effects/LumiMotionBlur2D/shaderLib/shaderMetal/93ab10f0e935e0bc691355370bc4cc5d.vert new file mode 100644 index 0000000000000000000000000000000000000000..025cf392753da0f3945510ac9a3bf1cc3e8b2a6d --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiMotionBlur2D/shaderLib/shaderMetal/93ab10f0e935e0bc691355370bc4cc5d.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float3 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = float4(in.a_position, 1.0); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiRoundCorner/lua/LumiRoundCorner.lua b/scripts/7681552231262326017/AmazingFeature/effects/LumiRoundCorner/lua/LumiRoundCorner.lua new file mode 100644 index 0000000000000000000000000000000000000000..f60af0ad7203a74e8e004c38663cf066f0f3c041 --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiRoundCorner/lua/LumiRoundCorner.lua @@ -0,0 +1,114 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiRoundCorner = LumiRoundCorner or {} +LumiRoundCorner.__index = LumiRoundCorner +---@class LumiRoundCorner : ScriptComponent +---@field fadeType string [UI(Option={"Outer", "Inner", "Both"})] +---@field radius double [UI(Display="Radius", Range={0, 256}, Drag)] +---@field fade double [UI(Display="Fade", Range={0, 256}, Drag)] +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local function createRenderTexture(width, height, filterMag, filterMin) + local rt = Amaz.RenderTexture() + rt.width = width + rt.height = height + rt.depth = 1 + rt.filterMag = filterMag or Amaz.FilterMode.LINEAR + rt.filterMin = filterMin or Amaz.FilterMode.LINEAR + rt.filterMipmap = Amaz.FilterMipmapMode.NONE + rt.attachment = Amaz.RenderTextureAttachment.NONE + return rt +end + +local function updateTexSize(rt, width, height) + if rt == nil or width <= 0 or height <= 0 then return end + if rt.width ~= width or rt.height ~= height then + rt.width = width + rt.height = height + end +end + +function LumiRoundCorner.new(construct, ...) + local self = setmetatable({}, LumiRoundCorner) + + self.__lumi_type = "lumi_obj" + self.__lumi_rt_pingpong_type = "custom" + + self.InputTex = nil + self.OutputTex = nil + self.radius = 0 + self.fade = 0 + self.fadeType = "Outer" + + self.FADE_QUERY = { + [0] = "Outer", + "Inner", + "Both", + ["Outer"] = 0, + ["Inner"] = 1, + ["Both"] = 2 + } + return self +end + +function LumiRoundCorner:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value, _force) + if _force or self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if key == "fadeType" then + value = math.max(0, math.min(value, #self.FADE_QUERY)) + value = self.FADE_QUERY[value] + _setEffectAttr(key, value) + else + _setEffectAttr(key, value) + end +end + +function LumiRoundCorner:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + Amaz.LOGI(self.TAG, 'onStart') + + self.camera = self.entity:searchEntity("RoundCornerCamera"):getComponent( + "Camera") + self.material = self.entity:searchEntity("RoundCornerPass"):getComponent( + "MeshRenderer").material +end + +function LumiRoundCorner:onUpdate(comp, deltaTime) + local w = self.OutputTex.width + local h = self.OutputTex.height + if self.OutputTex then self.camera.renderTexture = self.OutputTex end + self.material:setTex("u_inputTexture", self.InputTex) + + local halfMinEdge = math.min(w, h) * 0.5 + local radius = halfMinEdge * (self.radius / 256) + self.material:setFloat("u_radius", radius) + + local fade0, fade1 + local type = self.FADE_QUERY[self.fadeType] + if type == 2 then + fade0 = -(halfMinEdge * 0.5 * self.fade / 256) - 0.05 + fade1 = halfMinEdge * 0.5 * self.fade / 256 + 0.05 + elseif type == 1 then + fade0 = 0 + fade1 = halfMinEdge * self.fade / 256 + 0.1 + else + fade0 = -(halfMinEdge * self.fade / 256) - 0.1 + fade1 = 0 + end + self.material:setFloat("u_fade0", fade0) + self.material:setFloat("u_fade1", fade1) +end + +exports.LumiRoundCorner = LumiRoundCorner +return exports diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiRoundCorner/xshader/shaderLib/shaderGLES/7094e5583224dcba9aeac6c665d38b34.frag b/scripts/7681552231262326017/AmazingFeature/effects/LumiRoundCorner/xshader/shaderLib/shaderGLES/7094e5583224dcba9aeac6c665d38b34.frag new file mode 100644 index 0000000000000000000000000000000000000000..2ae87f8b162d49f97dafac2db4e97ec2b89348ed --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiRoundCorner/xshader/shaderLib/shaderGLES/7094e5583224dcba9aeac6c665d38b34.frag @@ -0,0 +1,19 @@ +precision highp float; +precision highp int; + +uniform vec4 u_ScreenParams; +uniform float u_radius; +uniform float u_fade0; +uniform float u_fade1; +uniform mediump sampler2D u_inputTexture; + +varying vec2 v_p; + +void main() +{ + vec2 _16 = u_ScreenParams.xy * 0.5; + vec2 _30 = abs(v_p - _16) - (_16 - vec2(u_radius)); + vec2 _t1 = _30; + gl_FragData[0] = texture2D(u_inputTexture, v_p / u_ScreenParams.xy) * smoothstep(u_fade0, u_fade1, -((length(max(_30, vec2(0.0))) + min(max(_t1.x, _t1.y), 0.0)) - u_radius)); +} + diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiRoundCorner/xshader/shaderLib/shaderGLES/7094e5583224dcba9aeac6c665d38b34.vert b/scripts/7681552231262326017/AmazingFeature/effects/LumiRoundCorner/xshader/shaderLib/shaderGLES/7094e5583224dcba9aeac6c665d38b34.vert new file mode 100644 index 0000000000000000000000000000000000000000..bd44d07bb9be748d50c620b0454b21633e38a058 --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiRoundCorner/xshader/shaderLib/shaderGLES/7094e5583224dcba9aeac6c665d38b34.vert @@ -0,0 +1,13 @@ + +uniform vec4 u_ScreenParams; + +attribute vec4 a_position; +varying vec2 v_p; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = a_position; + v_p = a_texcoord0 * u_ScreenParams.xy; +} + diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiRoundCorner/xshader/shaderLib/shaderMetal/7094e5583224dcba9aeac6c665d38b34.frag b/scripts/7681552231262326017/AmazingFeature/effects/LumiRoundCorner/xshader/shaderLib/shaderMetal/7094e5583224dcba9aeac6c665d38b34.frag new file mode 100644 index 0000000000000000000000000000000000000000..544c3d915133447782d76498b51c102f7c14c29e --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiRoundCorner/xshader/shaderLib/shaderMetal/7094e5583224dcba9aeac6c665d38b34.frag @@ -0,0 +1,33 @@ +#include +#include + +using namespace metal; + +struct buffer_t +{ + float4 u_ScreenParams; + float u_radius; + float u_fade0; + float u_fade1; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_p [[user(locn0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTexture [[texture(0)]], sampler u_inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float2 _16 = buffer.u_ScreenParams.xy * 0.5; + float2 _30 = abs(in.v_p - _16) - (_16 - float2(buffer.u_radius)); + float2 _t1 = _30; + out.o_fragColor = u_inputTexture.sample(u_inputTextureSmplr, (in.v_p / buffer.u_ScreenParams.xy)) * smoothstep(buffer.u_fade0, buffer.u_fade1, -((length(fast::max(_30, float2(0.0))) + fast::min(fast::max(_t1.x, _t1.y), 0.0)) - buffer.u_radius)); + return out; +} + diff --git a/scripts/7681552231262326017/AmazingFeature/effects/LumiRoundCorner/xshader/shaderLib/shaderMetal/7094e5583224dcba9aeac6c665d38b34.vert b/scripts/7681552231262326017/AmazingFeature/effects/LumiRoundCorner/xshader/shaderLib/shaderMetal/7094e5583224dcba9aeac6c665d38b34.vert new file mode 100644 index 0000000000000000000000000000000000000000..8a7859f3de5660580c1339d6670966c4fdf72393 --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/effects/LumiRoundCorner/xshader/shaderLib/shaderMetal/7094e5583224dcba9aeac6c665d38b34.vert @@ -0,0 +1,31 @@ +#include +#include + +using namespace metal; + +struct buffer_t +{ + float4 u_ScreenParams; +}; + +struct main0_out +{ + float2 v_p [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float4 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer) +{ + main0_out out = {}; + out.gl_Position = in.a_position; + out.v_p = in.a_texcoord0 * buffer.u_ScreenParams.xy; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681552231262326017/AmazingFeature/lua/LumiFamily/AETools.lua b/scripts/7681552231262326017/AmazingFeature/lua/LumiFamily/AETools.lua new file mode 100644 index 0000000000000000000000000000000000000000..07ad317cd97ebb4ef6a4b329cdda5e775c5c2b2c --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/lua/LumiFamily/AETools.lua @@ -0,0 +1,273 @@ +local AETools = AETools or {} +AETools.__index = AETools + +-- AE PropertyValueType +local ThreeD_SPATIAL = 6413 +local ThreeD = 6414 +local TwoD_SPATIAL = 6415 +local TwoD = 6416 +local OneD = 6417 + +local function deepcopy(orig) + local copy + if type(orig) == "table" then + copy = {} + for orig_key, orig_value in next, orig, nil do + copy[deepcopy(orig_key)] = deepcopy(orig_value) + end + -- setmetatable(copy, deepcopy(getmetatable(orig))) + else + copy = orig + end + return copy +end + +function AETools.new(attrs) + if attrs == nil then return nil end + + local self = setmetatable({}, AETools) + self.attrs = attrs + + local max_frame = 0 + local min_frame = 100000 + for _,v in pairs(attrs) do + for i = 1, #v do + local content = v[i] + local cur_frame_min = content[2][1] + local cur_frame_max = content[2][2] + max_frame = math.max(cur_frame_max, max_frame) + min_frame = math.min(cur_frame_min, min_frame) + + if content[4] ~= nil + and content[5] ~= nil + and (content[4][1] == ThreeD_SPATIAL or content[4][1] == TwoD_SPATIAL) + and content[5][1] == 0 + then + local p0 = content[3][1] + local totalLen = 0 + local lenInfo = {} + lenInfo[0] = 0 + for test=1,200,1 do + local coord = self._cubicBezier3D(content[3][1], content[3][3], content[3][4], content[3][2], test/200) + local length = 0 + if #p0 >= 3 then + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])+(coord[3]-p0[3])*(coord[3]-p0[3])) + else + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])) + end + p0 = coord + totalLen = totalLen + length + lenInfo[test] = totalLen + -- print(test/200 .. " coord: "..coord[1].." - "..coord[2]) + end + for test=1,200,1 do + lenInfo[test] = lenInfo[test]/(lenInfo[200]+0.000001) + -- print(test/200 .. " "..lenInfo[test]) + end + content['lenInfo'] = lenInfo + end + end + end + + self.all_frame = max_frame - min_frame + self.min_frame = min_frame + + return self +end + +function AETools:CurFrame(_p) + local frame = math.floor(_p*self.all_frame) + return frame + self.min_frame +end + +function AETools:AllFrame(_p) + return self.all_frame +end + +function AETools._remap01(a,b,x) + if x < a then return 0 end + if x > b then return 1 end + return (x-a)/(b-a) +end + +function AETools._cubicBezier(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + return { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + } +end + +function AETools._cubicBezier3D(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + local value = { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + 0, + } + if #p1 >= 3 then + value[3] = p1[3] * _t3 + 3 * p2[3] * _t2 * t + 3 * p3[3] * _t * t2 + p4[3] * t3 + end + return value +end + +function AETools:_cubicBezierSpatial(lenInfo, p1, p2, p3, p4, t) + local p = 0 + if t <= 0 then + p = 0 + elseif t >= 1 then + p = 1 + else + local ts = 199 + local te = 200 + for i=1,200,1 do + if lenInfo[i] >= t then + te = i + ts = i-1 + break + end + end + p = ts/200. + 0.005*(t-lenInfo[ts])/(lenInfo[te]-lenInfo[ts]+0.000001) + end + return self._cubicBezier3D(p1, p2, p3, p4, p) +end + +function AETools:_cubicBezier01(_bezier_val, p, y_len) + local x = self:_getBezier01X(_bezier_val, p, y_len) + return self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + x + )[2] +end + +function AETools:AllFrame() + return self.all_frame +end + +function AETools:_getBezier01X(_bezier_val, x, y_len) + local ts = 0 + local te = 1 + -- divide and conque + local times = 1 + repeat + local tm = (ts+te)*0.5 + local value = self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + tm) + if(value[1]>x) then + te = tm + else + ts = tm + end + times = times +1 + until(te-ts < 0.001 and times < 50) + + return (te+ts)*0.5 +end + +function AETools._mix(a, b, x, type) + if type == 1 then + return a * (1-x) + b * x + end + return a + x +end + +function AETools:GetVal(_name, _progress) + local content = self.attrs[_name] + if content == nil then + return nil + end + + -- local cur_frame = _progress * self.all_frame + self.min_frame + local cur_frame = _progress + + for i = 1, #content do + local info = content[i] + local start_frame = info[2][1] + local end_frame = info[2][2] + if cur_frame >= start_frame and cur_frame < end_frame then + local cur_progress = self._remap01(start_frame, end_frame, cur_frame) + local bezier = info[1] + local value_range = info[3] + local y_len = 1 + if (value_range[2][1] == value_range[1][1] and info[5] and info[5][1]==0 and #(value_range[1])==1) then + y_len = 0 + end + + if info[5] and info[5][1] == 2 then + return deepcopy(info[3][1]) + end + + if #bezier > 4 then + -- currently scale attrs contains more than 4 bezier values + local res = {} + for k = 1, 3 do + local cur_bezier = {bezier[k], bezier[k+3], bezier[k+3*2], bezier[k+3*3]} + local p = self:_cubicBezier01(cur_bezier, cur_progress, y_len) + res[k] = self._mix(value_range[1][k], value_range[2][k], p, y_len) + end + return res + + else + local p = self:_cubicBezier01(bezier, cur_progress, y_len) + if info[4] ~= nil + and info[5] ~= nil + and (info[4][1] == ThreeD_SPATIAL or info[4][1] == TwoD_SPATIAL) + and info[5][1] == 0 + then + local coord = self:_cubicBezierSpatial( + info['lenInfo'], + value_range[1], + value_range[3], + value_range[4], + value_range[2], + p + ) + if info[4][1] == TwoD_SPATIAL then + return {coord[1], coord[2]} + end + return coord + end + + if type(value_range[1]) == "table" then + local res = {} + for j = 1, #value_range[1] do + res[j] = self._mix(value_range[1][j], value_range[2][j], p, y_len) + end + return res + end + return self._mix(value_range[1], value_range[2], p, y_len) + end + end + end + + local first_info = content[1] + local start_frame = first_info[2][1] + if cur_frame=end_frame then + return deepcopy(last_info[3][2]) + end + + return nil +end + +return AETools diff --git a/scripts/7681552231262326017/AmazingFeature/lua/LumiFamily/LumiEffect.lua b/scripts/7681552231262326017/AmazingFeature/lua/LumiFamily/LumiEffect.lua new file mode 100644 index 0000000000000000000000000000000000000000..bee4c14190a8231d06c80826ceaa131067ca8ad2 --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/lua/LumiFamily/LumiEffect.lua @@ -0,0 +1,32 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiEffect = LumiEffect or {} +LumiEffect.__index = LumiEffect +---@class LumiEffect : ScriptComponent + +function LumiEffect.new(construct, ...) + local self = setmetatable({}, LumiEffect) + + self.__lumi_type = "lumi_effect" + self.__lumi_rt_pingpong_type = "custom" + + return self +end + +function LumiEffect:constructor() +end + +function LumiEffect:onStart(comp) +end + +function LumiEffect:onDestroy(comp) +end + +function LumiEffect:updateMaterials(comp, deltaTime) +end + +function LumiEffect:onUpdate(comp, deltaTime) +end + +exports.LumiEffect = LumiEffect +return exports diff --git a/scripts/7681552231262326017/AmazingFeature/lua/LumiFamily/LumiExportData.lua b/scripts/7681552231262326017/AmazingFeature/lua/LumiFamily/LumiExportData.lua new file mode 100644 index 0000000000000000000000000000000000000000..f5a594a729c29b37c8d03c3c2c08c6ecff9133cf --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/lua/LumiFamily/LumiExportData.lua @@ -0,0 +1,645 @@ +local data = {} + +local ae_compDurations = {0, 2} +data.ae_compDurations = ae_compDurations + +local ae_effectType = 'transition' +data.ae_effectType = ae_effectType + +local ae_transitionInputIndex = { + {'LumiMotionBlur2D_533-effect0', 'InputTex', 1}, + {'LumiRoundCorner_532-effect0', 'InputTex', 0}, +} +data.ae_transitionInputIndex = ae_transitionInputIndex + +local ae_durations = { + ['LumiMotionBlur2D_533-effect0'] = { + ['nodeDuration'] = {{0, 3.33333333333333}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 3.33333333333333}, }, + }, + }, + ['LumiRoundCorner_532-effect0'] = { + ['nodeDuration'] = {{0, 3.33333333333333}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 3.33333333333333}, }, + }, + }, + ['LumiAnimSeqLoadAndCrop_531-effect0'] = { + ['nodeDuration'] = {{0, 3.33333333333333}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 3.33333333333333}, }, + ['seqTex_1_1'] = {{0, 3.33333333333333}, }, + ['seqTex_9_16'] = {{0, 3.33333333333333}, }, + ['seqTex_16_9'] = {{0, 3.33333333333333}, }, + }, + }, + ['LumiLayer_532-trs-blend'] = { + ['nodeDuration'] = {{0, 3.33333333333333}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 3.33333333333333}, }, + ['baseTex'] = {{0, 3.33333333333333}, }, + }, + }, + ['LumiAnimSeqLoadAndCrop_534-effect0'] = { + ['nodeDuration'] = {{0, 3.33333333333333}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 3.33333333333333}, }, + ['seqTex_1_1'] = {{0, 3.33333333333333}, }, + ['seqTex_9_16'] = {{0, 3.33333333333333}, }, + ['seqTex_16_9'] = {{0, 3.33333333333333}, }, + }, + }, + ['LumiLayer_533-matte-blend'] = { + ['nodeDuration'] = {{0, 3.33333333333333}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 3.33333333333333}, }, + ['baseTex'] = {{0, 3.33333333333333}, }, + ['maskTex'] = {{0, 3.33333333333333}, }, + }, + }, + ['LumiBCC_Prism_536-effect0'] = { + ['nodeDuration'] = {{0, 3.33333333333333}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 3.33333333333333}, }, + }, + }, + ['LumiChromaticAberration_536-effect1'] = { + ['nodeDuration'] = {{0, 3.33333333333333}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 3.33333333333333}, }, + }, + }, + ['LumiLayer_536-blend'] = { + ['nodeDuration'] = {{0, 3.33333333333333}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 3.33333333333333}, }, + ['baseTex'] = {{0, 3.33333333333333}, }, + }, + }, +} +data.ae_durations = ae_durations + +local ae_attribute = { + ['LumiMotionBlur2D_533-effect0'] = { + ['rotate'] = 0, + ['ae_pre_rotate'] = 0, + ['anchor'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_anchor'] = Amaz.Vector2f(0.5, 0.5), + ['position'] = Amaz.Vector2f(0.4903638860728, 0.5), + ['ae_pre_position'] = Amaz.Vector2f(0.4903638860728, 0.5), + ['unifiedScale'] = true, + ['scale_x'] = 1, + ['ae_pre_scale_x'] = 1, + ['scale_y'] = 1, + ['ae_pre_scale_y'] = 1, + ['vIntensity'] = 0.5, + ['vCenter'] = -0.25, + ['minSamples'] = 0.12, + ['maxSamples'] = 0.24, + ['mirrorEdge'] = true, + ['dither'] = 1, + ['AEDesignSize'] = Amaz.Vector2f(1920, 1080), + }, + ['LumiRoundCorner_532-effect0'] = { + ['radius'] = 48.9156776306401, + ['fade'] = 0, + ['fadeType'] = 0, + ['AEDesignSize'] = Amaz.Vector2f(1920, 1080), + }, + ['LumiAnimSeqLoadAndCrop_531-effect0'] = { + ['specify_1_1'] = true, + ['animSeqType_1_1'] = 0, + ['cropType_1_1'] = 1, + ['edgeType_1_1'] = 0, + ['enableVideoAlphaBlend_1_1'] = true, + ['pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1_1'] = 0, + ['scale_1_1'] = 1, + ['opacity_1_1'] = 1, + ['speed_1_1'] = 1, + ['playMode_1_1'] = 0, + ['specify_9_16'] = true, + ['animSeqType_9_16'] = 0, + ['cropType_9_16'] = 1, + ['edgeType_9_16'] = 0, + ['enableVideoAlphaBlend_9_16'] = true, + ['pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_9_16'] = 0, + ['scale_9_16'] = 1, + ['opacity_9_16'] = 1, + ['speed_9_16'] = 1, + ['playMode_9_16'] = 0, + ['specify_16_9'] = true, + ['animSeqType_16_9'] = 0, + ['cropType_16_9'] = 1, + ['edgeType_16_9'] = 0, + ['enableVideoAlphaBlend_16_9'] = true, + ['pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_16_9'] = 0, + ['scale_16_9'] = 1, + ['opacity_16_9'] = 1, + ['speed_16_9'] = 1, + ['playMode_16_9'] = 0, + ['specify_5.8'] = false, + ['animSeqType_5.8'] = 2, + ['cropType_5.8'] = 1, + ['edgeType_5.8'] = 0, + ['enableVideoAlphaBlend_5.8'] = false, + ['pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_5.8'] = 0, + ['scale_5.8'] = 1, + ['opacity_5.8'] = 1, + ['speed_5.8'] = 1, + ['playMode_5.8'] = 0, + ['specify_2_1'] = false, + ['animSeqType_2_1'] = 2, + ['cropType_2_1'] = 1, + ['edgeType_2_1'] = 0, + ['enableVideoAlphaBlend_2_1'] = false, + ['pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2_1'] = 0, + ['scale_2_1'] = 1, + ['opacity_2_1'] = 1, + ['speed_2_1'] = 1, + ['playMode_2_1'] = 0, + ['specify_3_4'] = false, + ['animSeqType_3_4'] = 2, + ['cropType_3_4'] = 1, + ['edgeType_3_4'] = 0, + ['enableVideoAlphaBlend_3_4'] = false, + ['pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_3_4'] = 0, + ['scale_3_4'] = 1, + ['opacity_3_4'] = 1, + ['speed_3_4'] = 1, + ['playMode_3_4'] = 0, + ['specify_4_3'] = false, + ['animSeqType_4_3'] = 2, + ['cropType_4_3'] = 1, + ['edgeType_4_3'] = 0, + ['enableVideoAlphaBlend_4_3'] = false, + ['pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_4_3'] = 0, + ['scale_4_3'] = 1, + ['opacity_4_3'] = 1, + ['speed_4_3'] = 1, + ['playMode_4_3'] = 0, + ['specify_1.85_1'] = false, + ['animSeqType_1.85_1'] = 2, + ['cropType_1.85_1'] = 1, + ['edgeType_1.85_1'] = 0, + ['enableVideoAlphaBlend_1.85_1'] = false, + ['pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1.85_1'] = 0, + ['scale_1.85_1'] = 1, + ['opacity_1.85_1'] = 1, + ['speed_1.85_1'] = 1, + ['playMode_1.85_1'] = 0, + ['specify_2.35_1'] = false, + ['animSeqType_2.35_1'] = 2, + ['cropType_2.35_1'] = 1, + ['edgeType_2.35_1'] = 0, + ['enableVideoAlphaBlend_2.35_1'] = false, + ['pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2.35_1'] = 0, + ['scale_2.35_1'] = 1, + ['opacity_2.35_1'] = 1, + ['speed_2.35_1'] = 1, + ['playMode_2.35_1'] = 0, + ['globalRotation'] = 0, + ['globalScale'] = 1, + ['globalOpacity'] = 1, + ['globalSpeed'] = 1, + ['lite_mode'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1920, 1080), + }, + ['LumiLayer_532-trs-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = true, + ['layerType'] = 'Precomp', + ['anchorPoint'] = Amaz.Vector3f(960, 540, 0), + ['position'] = Amaz.Vector3f(3506.85570932213, 540, 0), + ['scale'] = Amaz.Vector3f(77.432932909196, 77.432932909196, 100), + ['orientation'] = Amaz.Vector3f(0, 0, 0), + ['xRotation'] = 0, + ['yRotation'] = 0, + ['rotation'] = 14.6539396693532, + ['opacity'] = 100, + ['active_cam_fovx'] = 39.6, + ['compositeSize'] = Amaz.Vector2f(1920, 1080), + ['layerSize'] = Amaz.Vector2f(1920, 1080), + ['mirrorEdge'] = false, + ['blendMode'] = 0, + }, + ['LumiAnimSeqLoadAndCrop_534-effect0'] = { + ['specify_1_1'] = true, + ['animSeqType_1_1'] = 0, + ['cropType_1_1'] = 1, + ['edgeType_1_1'] = 0, + ['enableVideoAlphaBlend_1_1'] = true, + ['pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1_1'] = 0, + ['scale_1_1'] = 1, + ['opacity_1_1'] = 1, + ['speed_1_1'] = 1, + ['playMode_1_1'] = 0, + ['specify_9_16'] = true, + ['animSeqType_9_16'] = 0, + ['cropType_9_16'] = 1, + ['edgeType_9_16'] = 0, + ['enableVideoAlphaBlend_9_16'] = true, + ['pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_9_16'] = 0, + ['scale_9_16'] = 1, + ['opacity_9_16'] = 1, + ['speed_9_16'] = 1, + ['playMode_9_16'] = 0, + ['specify_16_9'] = true, + ['animSeqType_16_9'] = 0, + ['cropType_16_9'] = 1, + ['edgeType_16_9'] = 0, + ['enableVideoAlphaBlend_16_9'] = true, + ['pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_16_9'] = 0, + ['scale_16_9'] = 1, + ['opacity_16_9'] = 1, + ['speed_16_9'] = 1, + ['playMode_16_9'] = 0, + ['specify_5.8'] = false, + ['animSeqType_5.8'] = 2, + ['cropType_5.8'] = 1, + ['edgeType_5.8'] = 0, + ['enableVideoAlphaBlend_5.8'] = false, + ['pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_5.8'] = 0, + ['scale_5.8'] = 1, + ['opacity_5.8'] = 1, + ['speed_5.8'] = 1, + ['playMode_5.8'] = 0, + ['specify_2_1'] = false, + ['animSeqType_2_1'] = 2, + ['cropType_2_1'] = 1, + ['edgeType_2_1'] = 0, + ['enableVideoAlphaBlend_2_1'] = false, + ['pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2_1'] = 0, + ['scale_2_1'] = 1, + ['opacity_2_1'] = 1, + ['speed_2_1'] = 1, + ['playMode_2_1'] = 0, + ['specify_3_4'] = false, + ['animSeqType_3_4'] = 2, + ['cropType_3_4'] = 1, + ['edgeType_3_4'] = 0, + ['enableVideoAlphaBlend_3_4'] = false, + ['pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_3_4'] = 0, + ['scale_3_4'] = 1, + ['opacity_3_4'] = 1, + ['speed_3_4'] = 1, + ['playMode_3_4'] = 0, + ['specify_4_3'] = false, + ['animSeqType_4_3'] = 2, + ['cropType_4_3'] = 1, + ['edgeType_4_3'] = 0, + ['enableVideoAlphaBlend_4_3'] = false, + ['pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_4_3'] = 0, + ['scale_4_3'] = 1, + ['opacity_4_3'] = 1, + ['speed_4_3'] = 1, + ['playMode_4_3'] = 0, + ['specify_1.85_1'] = false, + ['animSeqType_1.85_1'] = 2, + ['cropType_1.85_1'] = 1, + ['edgeType_1.85_1'] = 0, + ['enableVideoAlphaBlend_1.85_1'] = false, + ['pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1.85_1'] = 0, + ['scale_1.85_1'] = 1, + ['opacity_1.85_1'] = 1, + ['speed_1.85_1'] = 1, + ['playMode_1.85_1'] = 0, + ['specify_2.35_1'] = false, + ['animSeqType_2.35_1'] = 2, + ['cropType_2.35_1'] = 1, + ['edgeType_2.35_1'] = 0, + ['enableVideoAlphaBlend_2.35_1'] = false, + ['pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2.35_1'] = 0, + ['scale_2.35_1'] = 1, + ['opacity_2.35_1'] = 1, + ['speed_2.35_1'] = 1, + ['playMode_2.35_1'] = 0, + ['globalRotation'] = 0, + ['globalScale'] = 1, + ['globalOpacity'] = 1, + ['globalSpeed'] = 1, + ['lite_mode'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1920, 1080), + }, + ['LumiLayer_533-matte-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = true, + ['hasTransform'] = false, + ['layerType'] = 'Precomp', + ['matteMode'] = 0, + ['blendMode'] = 0, + }, + ['LumiBCC_Prism_536-effect0'] = { + ['globalTransform'] = 40, + ['smoothness'] = 1, + ['center'] = Amaz.Vector2f(0.5, 0.5), + ['weight'] = 0.57142857142857, + ['scaleStart'] = 102, + ['scaleEnd'] = 98, + ['angleStart'] = 0, + ['angleEnd'] = 0, + ['falloff'] = 0, + ['offsetStart'] = Amaz.Vector2f(0.5, 0.5), + ['offsetEnd'] = Amaz.Vector2f(0.5, 0.5), + ['colorStart'] = Amaz.Color(1, 0, 0, 1), + ['colorMid'] = Amaz.Color(0, 1, 0, 1), + ['colorEnd'] = Amaz.Color(0, 0, 1, 1), + ['AEDesignSize'] = Amaz.Vector2f(1920, 1080), + }, + ['LumiChromaticAberration_536-effect1'] = { + ['offsetX'] = 0.01142857117312, + ['offsetY'] = 0.01142857117312, + ['AEDesignSize'] = Amaz.Vector2f(1920, 1080), + }, + ['LumiLayer_536-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = false, + ['layerType'] = 'Adjustment', + ['blendMode'] = 0, + }, +} +data.ae_attribute = ae_attribute + +local ae_keyframes = { + ['LumiMotionBlur2D_533-effect0#ae_pre_position#vector'] = +{ + { + {0.12, 0, 0.2, 1, }, + {0.03333333333333, 1.83333333333333, }, + {{-1.5625, 0.5, }, {0.5, 0.5, }, {-1.5625, 0.5, }, {0.5, 0.5, }, }, + {6415, }, + {0, }, + }, +}, + ['LumiMotionBlur2D_533-effect0#position#vector'] = +{ + { + {0.12, 0, 0.2, 1, }, + {0, 1.8, }, + {{-1.5625, 0.5, }, {0.5, 0.5, }, {-1.5625, 0.5, }, {0.5, 0.5, }, }, + {6415, }, + {0, }, + }, +}, + ['LumiRoundCorner_532-effect0#radius#number'] = +{ + { + {0.12, 0, 0.2, 1, }, + {0.3, 1.966667, }, + {{3, }, {50, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiAnimSeqLoadAndCrop_531-effect0#seqTime#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 3.33333333333333, }, + {{0, }, {3.33333333333333, }, }, + {6417, }, + {1, }, + }, +}, + ['LumiLayer_532-trs-blend#position#vector'] = +{ + { + {0.12, 0, 0.2, 1, }, + {0.3, 1.966667, }, + {{960, 540, 0, }, {3567, 540, 0, }, {960, 540, 0, }, {3567, 540, 0, }, }, + {6413, }, + {0, }, + }, +}, + ['LumiLayer_532-trs-blend#scale#vector'] = +{ + { + {0.12,0.12,0.12, 0,0,0.12, 0.2,0.2,0.2, 1,1,0.2, }, + {0.3, 1.966667, }, + {{100, 100, 100, }, {76.9, 76.9, 100, }, }, + {6414, }, + {0, }, + }, +}, + ['LumiLayer_532-trs-blend#rotation#number'] = +{ + { + {0.12, 0, 0.2, 1, }, + {0.3, 1.966667, }, + {{0, }, {15, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiAnimSeqLoadAndCrop_534-effect0#seqTime#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 3.33333333333333, }, + {{0, }, {3.33333333333333, }, }, + {6417, }, + {1, }, + }, +}, + ['LumiBCC_Prism_536-effect0#globalTransform#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 0.466667, }, + {{0, }, {70, }, }, + {6417, }, + {1, }, + }, + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0.466667, 1.433333, }, + {{70, }, {70, }, }, + {6417, }, + {1, }, + }, + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {1.433333, 1.9, }, + {{70, }, {0, }, }, + {6417, }, + {1, }, + }, +}, + ['LumiBCC_Prism_536-effect0#weight#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 0.466667, }, + {{0, }, {1, }, }, + {6417, }, + {1, }, + }, + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0.466667, 1.433333, }, + {{1, }, {1, }, }, + {6417, }, + {1, }, + }, + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {1.433333, 1.9, }, + {{1, }, {0, }, }, + {6417, }, + {1, }, + }, +}, + ['LumiChromaticAberration_536-effect1#offsetX#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 0.466667, }, + {{0, }, {0.02, }, }, + {6417, }, + {1, }, + }, + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0.466667, 1.433333, }, + {{0.02, }, {0.02, }, }, + {6417, }, + {1, }, + }, + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {1.433333, 1.9, }, + {{0.02, }, {0, }, }, + {6417, }, + {1, }, + }, +}, + ['LumiChromaticAberration_536-effect1#offsetY#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 0.466667, }, + {{0, }, {0.02, }, }, + {6417, }, + {1, }, + }, + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0.466667, 1.433333, }, + {{0.02, }, {0.02, }, }, + {6417, }, + {1, }, + }, + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {1.433333, 1.9, }, + {{0.02, }, {0, }, }, + {6417, }, + {1, }, + }, +}, +} +data.ae_keyframes = ae_keyframes + +local ae_reverseKeyframes = false +data.ae_reverseKeyframes = ae_reverseKeyframes + +local ae_sliderInfos = { +} +data.ae_sliderInfos = ae_sliderInfos + +local ae_fadeinInfos = { + time = 0, + infos = { + } +} +data.ae_fadeinInfos = ae_fadeinInfos + +local ae_fadeoutInfos = { + time = 0, + infos = { + } +} +data.ae_fadeoutInfos = ae_fadeoutInfos + +local ae_animationInfos = { + animationMode = 0, + loopStart = 0, + speedInfo = {1, 0, 1, }, +} +data.ae_animationInfos = ae_animationInfos + +return data diff --git a/scripts/7681552231262326017/AmazingFeature/lua/LumiFamily/LumiManager.lua b/scripts/7681552231262326017/AmazingFeature/lua/LumiFamily/LumiManager.lua new file mode 100644 index 0000000000000000000000000000000000000000..7a07ee24e9b82500e89114ce8cb3a85474915e38 --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/lua/LumiFamily/LumiManager.lua @@ -0,0 +1,554 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiManager = LumiManager or {} +LumiManager.__index = LumiManager +---@class LumiManager : ScriptComponent +---@field debugTime number [UI(Range={0, 6}, Drag)] +---@field autoPlay boolean +---@field lumiEffectRoot Transform +---@field start_render_layer int +---@field start_render_order int + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local EffectType = { + Effect = 'effect', + Transition = 'transition', + VideoAnimation = 'videoAnimation', + EffectXT = 'xtEffect', + FilterXT = 'xtFilter', +} + +local AnimationMode = { + Once = 0, + Loop = 1, + StretchOnce = 2, + StretchLoop = 3, +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +local function remap(value, srcMin, srcMax, dstMin, dstMax) + return dstMin + (value - srcMin) * (dstMax - dstMin) / (srcMax - srcMin) +end + +local function handleAllEntityBySingleParent(_trans, func, ...) + if _trans.children:size() > 0 then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i - 1) + handleAllEntityBySingleParent(child, func, ...) + end + end + func(_trans, ...) +end + +local function intervalIntersection(intervals1, intervals2) + local result = {} + local i = 1 + local j = 1 + + while i <= #intervals1 and j <= #intervals2 do + local start1 = intervals1[i][1] + local end1 = intervals1[i][2] + local start2 = intervals2[j][1] + local end2 = intervals2[j][2] + + local start = math.max(start1, start2) + local end_ = math.min(end1, end2) + + if start <= end_ then + table.insert(result, {start, end_}) + end + if end1 < end2 then + i = i + 1 + else + j = j + 1 + end + end + return result +end + +function LumiManager.new(construct, ...) + local self = setmetatable({}, LumiManager) + + self.lumiEffectRoot = nil + self.start_render_layer = 1 + self.start_render_order = 1 + + self.InputTex = nil + self.OutputTex = nil + self.PingPongTex = nil + + self.startTime = 0.0 + self.endTime = 6.0 + self.curTime = 0.0 + + self.speed = 1.0 + self.animationMode = AnimationMode.Once + self.autoPlay = true + self.debugTime = 0.0 + + -- for XT + self.cameraStartTime = 0 + self.lastCycle = -1 + + return self +end + +function LumiManager:getKeyframeAeTime(aeTime) + if self.isReverseKeyframes ~= true then + return aeTime + end + return self.compDurations[1] + self.compDurations[2] - aeTime +end + +function LumiManager:onStart(comp) + self.entity = comp.entity + + self.lumi_obj_extension = includeRelativePath("LumiObjectExtension") + self.lumi_obj = nil + + self.keyframes = nil + self.durations = nil + self.params = nil + self.compDurations = {0, 6} + self.animationInfos = 0 + self.sliderInfos = {} + self.fadeinInfos = {} + self.fadeoutInfos = {} + self.effectType = "effect" + self.transitionInputIndex = {} + + self.LumiParamsSetter = includeRelativePath("LumiParamsSetter") + local ae_export_data = includeRelativePath("LumiExportData") + if ae_export_data then + if ae_export_data.ae_keyframes then + local ae_tools = includeRelativePath("AETools") + if ae_tools then + self.keyframes = ae_tools.new(ae_export_data.ae_keyframes) + end + end + if ae_export_data.ae_reverseKeyframes ~= nil then + self.isReverseKeyframes = ae_export_data.ae_reverseKeyframes + end + if ae_export_data.ae_durations ~= nil then + self.durations = ae_export_data.ae_durations + end + if ae_export_data.ae_attribute ~= nil then + self.params = ae_export_data.ae_attribute + end + if ae_export_data.ae_compDurations ~= nil then + self.compDurations = ae_export_data.ae_compDurations + self.compDurations[2] = self.compDurations[2] + end + if ae_export_data.ae_animationInfos ~= nil then + self.animationInfos = ae_export_data.ae_animationInfos + self.animationMode = self.animationInfos.animationMode + self.loopStart = self.animationInfos.loopStart + self.speed = self.animationInfos.speedInfo[1] + end + if ae_export_data.ae_sliderInfos ~= nil then + self.sliderInfos = ae_export_data.ae_sliderInfos + end + if ae_export_data.ae_fadeinInfos ~= nil then + self.fadeinInfos = ae_export_data.ae_fadeinInfos + end + if ae_export_data.ae_fadeoutInfos ~= nil then + self.fadeoutInfos = ae_export_data.ae_fadeoutInfos + end + if ae_export_data.ae_effectType ~= nil then + self.effectType = ae_export_data.ae_effectType + end + if ae_export_data.ae_cameraMode ~= nil then + self.cameraMode = ae_export_data.ae_cameraMode + end + if ae_export_data.ae_transitionInputIndex ~= nil then + self.transitionInputIndex = ae_export_data.ae_transitionInputIndex + end + end + if self.LumiParamsSetter then + self.lumi_params_setter = self.LumiParamsSetter.new( + self, + self.params, + self.keyframes, + self.effectType, + self.sliderInfos, + self.fadeinInfos, + self.fadeoutInfos + ) + end + + if self.effectType == EffectType.VideoAnimation then + local baseEntity = self.entity:searchEntity('base') + local videoCamera = baseEntity:searchEntity('videoCamera'):getComponent('Camera') + local videoRenderer = baseEntity:searchEntity('video'):getComponent('MeshRenderer') + local modelCamera = baseEntity:searchEntity('modelCamera'):getComponent('Camera') + local modelRenderer = baseEntity:searchEntity('model'):searchEntity('quad'):getComponent('MeshRenderer') + local fxaaCamera = baseEntity:searchEntity('fxaaCamera'):getComponent('Camera') + local fxaaRenderer = baseEntity:searchEntity('fxaa'):getComponent('MeshRenderer') + local bgCamera = baseEntity:searchEntity('bgCamera'):getComponent('Camera') + local bgRenderer = baseEntity:searchEntity('bg'):getComponent('MeshRenderer') + local blendCamera = baseEntity:searchEntity('blendCamera'):getComponent('Camera') + local blendRenderer = baseEntity:searchEntity('blend'):getComponent('MeshRenderer') + self.videoAnimationCameraAndRenderer = { + { camera = videoCamera, renderer = videoRenderer }, + { camera = modelCamera, renderer = modelRenderer }, + { camera = fxaaCamera, renderer = fxaaRenderer }, + { camera = bgCamera, renderer = bgRenderer }, + { camera = blendCamera, renderer = blendRenderer }, + } + end +end + +function LumiManager:onDestroy(comp) + if self.lumiEffectRoot and self.lumi_obj_extension then + self.lumi_obj_extension.deregister(self.lumiEffectRoot.entity) + end + self.lumi_obj = nil + self.LumiParamsSetter = nil +end + +function LumiManager:getCameraCount() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return 0 + end + + self.lumi_obj = nil + self:ReRender() + + local cam_count = 0 + if self.lumi_obj then + cam_count = self.lumi_obj:getCameraCount() + Amaz.LOGI(AE_EFFECT_TAG, self.lumi_obj.entity.name .. " camera_count: " .. tostring(cam_count)) + end + return cam_count +end + +function LumiManager:ReRender() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + -- re register + self.lumi_obj = nil + self:registerLumiObj(self.lumiEffectRoot, 1) + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'No lumi_obj register') + return + end + + -- change layer & order + self:updateCameraLayerAndOrder() + + -- change rt pingpong + self:updateRtPingpong() +end + +function LumiManager:registerLumiObj(_trans, _idx) + if _trans == nil then return end + local script_comp = _trans.entity:getComponent("ScriptComponent") + if script_comp then + local lua_obj = Amaz.ScriptUtils.getLuaObj(script_comp:getScript()) + if lua_obj then + self.lumi_obj_extension.deregister(_trans.entity) + self.lumi_obj = self.lumi_obj_extension.register(_trans.entity) + end + end +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str .. "0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiManager:updateCameraLayerAndOrder() + if self.lumi_obj then + local cur_start_layer, cur_start_order = self.lumi_obj:updateCameraLayerAndOrder(self.start_render_layer, self.start_render_order) + + if self.effectType == EffectType.VideoAnimation then + cur_start_layer = cur_start_layer + 10 + cur_start_order = cur_start_order + 10 + + for i = 1, #self.videoAnimationCameraAndRenderer do + local cameraAndRenderer = self.videoAnimationCameraAndRenderer[i] + local camera = cameraAndRenderer.camera + local renderer = cameraAndRenderer.renderer + camera.renderOrder = cur_start_order + _setLayer(camera, cur_start_layer) + renderer.entity.layer = cur_start_layer + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end +end + +function LumiManager:updateRtPingpong() + if self.lumi_obj then + self.lumi_obj:updateRt(self.InputTex, self.OutputTex, self.PingPongTex) + end +end + +function LumiManager:updateOutputRtSize() + if self.lumi_obj then + self.lumi_obj:updateOutputRtSize(self.width, self.height) + end +end + +function LumiManager:initVideoAnimationLua(comp) + local modelEntity = comp.entity:searchEntity("model") + if modelEntity then + local scriptComp = modelEntity:getComponent("ScriptComponent") + if scriptComp then + self.videoAnimationLua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + end + end +end + +function LumiManager:onUpdate(comp, deltaTime) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.durations and not self.isSetDuration then + for entityName, durationMap in pairs(self.durations) do + local isLumiLayer = string.sub(entityName, 1, string.len('LumiLayer')) == 'LumiLayer' + if isLumiLayer then + local texDuration = durationMap['texDuration'] + local srcDuration = texDuration['InputTex'] + local baseDuration = texDuration['baseTex'] + local maskDuration = texDuration['maskTex'] + if srcDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'srcDuration', srcDuration) + end + if baseDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'baseDuration', baseDuration) + end + if maskDuration then + local matteDuration = intervalIntersection(maskDuration, srcDuration) + self.lumi_obj:setSubEffectAttr(entityName, 'matteDuration', matteDuration) + end + end + end + self.isSetDuration = true + end + + local w = Amaz.BuiltinObject.getInputTextureWidth() + local h = Amaz.BuiltinObject.getInputTextureHeight() + if self.InputTex then + w = self.InputTex.width + h = self.InputTex.height + end + if self.OutputTex and (self.OutputTex.width ~= w or self.OutputTex.height ~= h) then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid rt size, input: ' .. w .. 'x' .. h .. ', output: ' .. self.OutputTex.width .. 'x' .. self.OutputTex.height) + end + if self.width == nil or self.width ~= w or self.height == nil or self.height ~= h then + self.width = w + self.height = h + self:updateOutputRtSize() + end + + self.curTime = self.curTime + deltaTime + if isEditor then + self.curTime = self.curTime % self.endTime + end + local curTime = (self.curTime - self.startTime) * self.speed + self.startTime + local startTime = self.startTime + local endTime = (self.endTime - self.startTime) * self.speed + self.startTime + + if self.cameraMode then + if self.animationMode ~= AnimationMode.Loop then + Amaz.LOGE(AE_EFFECT_TAG, 'Camera mode is not support animationMode: ' .. tostring(self.animationMode)) + return + end + curTime = self.curTime - self.cameraStartTime + endTime = math.huge + elseif self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT then -- deprecated after 1810 in XT + startTime = 0 + if self.isVideo == 1 then + endTime = self.videoTime + else + curTime = 0 + endTime = 3 + end + end + + local aeTime = curTime; + local aeDuration = math.max(0.001, self.compDurations[2] - self.compDurations[1]) + if endTime < curTime then + aeTime = math.max(self.compDurations[1], self.compDurations[2] - (self.endTime - self.curTime)) + else + local lvDuration = math.max(0.001, endTime - startTime) + if self.animationMode == AnimationMode.Once then + aeTime = self.compDurations[1] + curTime - startTime + aeTime = math.min(aeTime, self.compDurations[2]) + elseif self.animationMode == AnimationMode.Loop then + if self.cameraMode then + local cycle = math.floor((curTime - startTime) / aeDuration) + if self.lastCycle ~= cycle then + self.lastCycle = cycle + comp.entity.scene:sendMessage(4999, 1, 0, '') + end + end + if math.floor((curTime - startTime) / aeDuration) < 1 then + aeTime = self.compDurations[1] + (curTime - startTime) % aeDuration + else + local curLoopStart = (self.loopStart - self.compDurations[1]) * self.speed + self.compDurations[1] + aeTime = self.loopStart + (curTime - startTime - curLoopStart) % (aeDuration - self.loopStart) + end + elseif self.animationMode == AnimationMode.StretchOnce then + aeTime = remap(curTime, startTime, self.endTime, self.compDurations[1], self.compDurations[2]) + aeTime = clamp(aeTime, self.compDurations[1], self.compDurations[2]) + elseif self.animationMode == AnimationMode.StretchLoop then + local newCurTime = startTime + (curTime - startTime) * self.speed % lvDuration + aeTime = remap(newCurTime, startTime, endTime, self.compDurations[1], self.compDurations[2]) + + if math.floor((curTime - startTime) * self.speed / lvDuration) >= 1 then + aeTime = self.compDurations[1] + (aeTime - self.compDurations[1]) % (self.compDurations[2] - self.loopStart) + self.loopStart + end + end + end + + if self.effectType == EffectType.Transition then + local input1 = Amaz.BuiltinObject.getUserTexture("#TransitionInput0") + local input2 = Amaz.BuiltinObject.getUserTexture("#TransitionInput1") + if input1 and input2 then + for index, transitionInputInfo in ipairs(self.transitionInputIndex) do + local entityName = transitionInputInfo[1] + local texName = transitionInputInfo[2] + local inputIndex = transitionInputInfo[3] + if inputIndex == 0 then + self.lumi_obj:setSubEffectAttr(entityName, texName, input1) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 0) + else + self.lumi_obj:setSubEffectAttr(entityName, texName, input2) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 1) + end + end + aeTime = Amaz.Input.frameTimestamp * (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + end + elseif self.effectType == EffectType.VideoAnimation then + if self.videoAnimationLua == nil then + self:initVideoAnimationLua(comp) + end + if self.videoAnimationLua ~= nil then + aeTime = remap(self.videoAnimationLua.curTime, 0, self.videoAnimationLua.duration, self.compDurations[1], self.compDurations[2]) + end + end + + if isEditor then + if self.autoPlay then + self.debugTime = curTime % (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + aeTime = self.debugTime + else + aeTime = self.debugTime + end + elseif self.effectType == EffectType.VideoAnimation or self.effectType == EffectType.Transition then + self.curTime = aeTime + end + + if self.lumi_obj then + self.lumi_obj:setEffectAttrRecursively("startTime", self.startTime) + self.lumi_obj:setEffectAttrRecursively("endTime", self.endTime) + self.lumi_obj:setEffectAttrRecursively("curTime", self.curTime) + self.lumi_obj:setEffectAttrRecursively("aeTime", aeTime) + self.lumi_obj:setEffectAttrRecursively("aeDuration", aeDuration) + end + + if self.lumi_params_setter and self.lumi_params_setter.initParams then + self.lumi_params_setter:initParams(self.lumi_obj) + end + if self.lumi_params_setter and self.lumi_params_setter.updateKeyFrameData then + self.lumi_params_setter:updateKeyFrameData(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateSlider then + self.lumi_params_setter:updateSlider(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateFade then + if self.effectType == EffectType.Effect then + self.lumi_params_setter:updateFade(self.lumi_obj, self.startTime, self.endTime, self.curTime, self.compDurations, aeTime) + end + end + + if self.lumi_obj and self.durations ~= nil then + aeTime = math.min(math.max(aeTime, self.compDurations[1]), self.compDurations[2]) + for entityName, durationMap in pairs(self.durations) do + local nodeDuration = durationMap['nodeDuration'] + local visible = false + for j = 1, #nodeDuration do + if nodeDuration[j][1] <= aeTime and aeTime < nodeDuration[j][2] then + visible = true + break + end + end + self.lumi_obj:setVisible(entityName, visible) + end + end + if self.lumi_obj and self.lumi_obj.updateMaterials then + self.lumi_obj:updateMaterials(deltaTime) + end +end + +-- function LumiManager:onLateUpdate(comp, deltaTime) +-- collectgarbage("collect") +-- end + +function LumiManager:onEvent(comp, event) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Failed to find lumi_obj') + return + end + + if self.effectType == EffectType.Effect then + if event.args:get(0) == 'effects_adjust_speed' then + local value = event.args:get(1) + if self.animationInfos then + if value < 0 or value > 1 then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid effects_adjust_speed value: ' .. value) + end + self.speed = remap(clamp(value, 0, 1), 0, 1, self.animationInfos.speedInfo[2], self.animationInfos.speedInfo[3]) + else + self.speed = value + end + end + elseif event.args:get(0) == 'start_time' and self.cameraMode then + self.cameraStartTime = event.args:get(2) + elseif event.args:get(0) == 'is_video' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.isVideo = event.args:get(2) + elseif event.args:get(0) == 'video_time' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.videoTime = event.args:get(2) + end + + if self.lumi_params_setter and self.lumi_params_setter.onEvent then + self.lumi_params_setter:onEvent(self.lumi_obj, event) + end +end + +exports.LumiManager = LumiManager +return exports diff --git a/scripts/7681552231262326017/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua b/scripts/7681552231262326017/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua new file mode 100644 index 0000000000000000000000000000000000000000..c1e528b6007352c9831b71df7a92892be83703dc --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua @@ -0,0 +1,436 @@ + +local LumiObjectExtension = {} +LumiObjectExtension.__index = LumiObjectExtension + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag-LumiObjectExtension' + +local function handleAllEntityBySingleParent(_trans, func, func2, ...) + if _trans.children:size() > 0 and func2(_trans, ...) then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i-1) + handleAllEntityBySingleParent(child, func, func2, ...) + end + end + func(_trans, ...) +end + +local function CreateRenderTexture(width, height) + local rt = Amaz.RenderTexture() + rt.width = width + rt.height = height + rt.depth = 1 + rt.filterMag = Amaz.FilterMode.LINEAR + rt.filterMin = Amaz.FilterMode.LINEAR + rt.filterMipmap = Amaz.FilterMipmapMode.NONE + rt.attachment = Amaz.RenderTextureAttachment.NONE + return rt +end + +function LumiObjectExtension.register(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + + local self = setmetatable({}, LumiObjectExtension) + self.entity = _ent + self.scriptComp = scriptComp + self.trans = _ent:getComponent("Transform") + self.effect_lua = effect_lua + if effect_lua.__lumi_type~= nil then + self.__lumi_type = effect_lua.__lumi_type + else + self.__lumi_type = "lumi_obj" + end + if effect_lua.__lumi_rt_pingpong_type~= nil then + self.__lumi_rt_pingpong_type = effect_lua.__lumi_rt_pingpong_type + else + self.__lumi_rt_pingpong_type = "custom" + end + + if self.entity:getComponents("Camera"):size() > 0 then + Amaz.LOGE(AE_EFFECT_TAG, "Error: root entity has camera attached") + return nil + end + self.subLumiObjExt = {} + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local objExt = LumiObjectExtension.register(child.entity) + if objExt and child.entity.name ~= '' then + self.subLumiObjExt[child.entity.name] = objExt + end + end + end + effect_lua.__lumi_obj_ext = self + return self +end + +function LumiObjectExtension.deregister(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + local lumi_obj = effect_lua.__lumi_obj_ext + if lumi_obj == nil then return nil end + + if lumi_obj.__lumi_type == "lumi_effect" then + for i = 1, lumi_obj.trans.children:size() do + local child = lumi_obj.trans.children:get(i-1) + LumiObjectExtension.deregister(child.entity) + end + end + lumi_obj.entity = nil + lumi_obj.trans = nil + lumi_obj.effect_lua = nil + lumi_obj.scriptComp = nil + lumi_obj.subLumiObjExt = nil + lumi_obj.__lumi_type = nil + lumi_obj.__lumi_rt_pingpong_type = nil + effect_lua.__lumi_obj_ext = nil +end + +function LumiObjectExtension.getLumiObjExt(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + return effect_lua.__lumi_obj_ext +end + +function LumiObjectExtension:searchSubLumiObjExt(name) + if self.trans.entity.name == name then + return self + end + if name and self.subLumiObjExt[name] then + return self.subLumiObjExt[name] + end + for _, subObj in pairs(self.subLumiObjExt) do + local obj = subObj:searchSubLumiObjExt(name) + if obj then + return obj + end + end + return nil +end + +function LumiObjectExtension:setInputTex(_tex) + if self.effect_lua then + self.effect_lua.InputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('InputTex', _tex) + end + end +end + +function LumiObjectExtension:setOutputTex(_tex) + if self.effect_lua then + self.effect_lua.OutputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('OutputTex', _tex) + end + end +end + +function LumiObjectExtension:getInputTex() + if self.effect_lua then + return self.effect_lua.InputTex + end + return nil +end + +function LumiObjectExtension:getOutputTex() + if self.effect_lua then + return self.effect_lua.OutputTex + end + return nil +end + +function LumiObjectExtension:setInputTexSizes(inputSize, originalSize) + assert(type(inputSize)=="table", "inputSize should be table") + if self.effect_lua and self.effect_lua.setInputTexSize then + self.effect_lua:setInputTexSize(inputSize) + end + if self.effect_lua and self.effect_lua.setInputOriginalTexSize then + self.effect_lua:setInputOriginalTexSize(originalSize) + end + self._inputTexSize, self._originalTexSize = inputSize, originalSize +end + +function LumiObjectExtension:getOutputTexSizes() + local inputSize = (self.effect_lua and self.effect_lua.getOutputTexSize) and self.effect_lua:getOutputTexSize() or self._inputTexSize + local originalSize = (self.effect_lua and self.effect_lua.getOutputOriginalTexSize) and self.effect_lua:getOutputOriginalTexSize() or self._originalTexSize + return inputSize, originalSize +end + +function LumiObjectExtension:needChangeOutputTexSize() + if self.effect_lua and self.effect_lua.__lumi_will_change_out_size then + return self.effect_lua.__lumi_will_change_out_size + end + if self._inputTexSize~=nil and self.effect_lua and self.effect_lua.getOutputTexSize then + local outSize = self.effect_lua:getOutputTexSize() + return (outSize[1] ~= self._inputTexSize[1] or outSize[2] ~= self._inputTexSize[2]) + end + return false +end + +function LumiObjectExtension:updateRt(_input_tex, _output_tex, _pingpong_tex) + self:setInputTex(_input_tex) + self:setOutputTex(_output_tex) + if self.effect_lua and self.effect_lua.updateRenderTexture ~= nil then + self.effect_lua:updateRenderTexture() + end + if self.__lumi_type == "lumi_effect" and self.__lumi_rt_pingpong_type == "auto" then + local lumi_obj_list = {} + local function collect_lumi_obj(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and (lumi_obj_ext.__lumi_type == "lumi_obj" or lumi_obj_ext.__lumi_rt_pingpong_type == "custom") then + table.insert(lumi_obj_list, lumi_obj_ext) + end + end + local function collect_lumi_obj_flag(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and lumi_obj_ext.__lumi_type == "lumi_effect" and lumi_obj_ext.__lumi_rt_pingpong_type == "auto" then + return true + end + return false + end + handleAllEntityBySingleParent(self.trans, collect_lumi_obj, collect_lumi_obj_flag) + + if _pingpong_tex then + self._pingpong_tex = _pingpong_tex + elseif #lumi_obj_list > 1 then + self._pingpong_tex = CreateRenderTexture(_output_tex.width, _output_tex.height) + end + local pingpong = { _output_tex, self._pingpong_tex } + if #lumi_obj_list%2 == 0 then + pingpong = { self._pingpong_tex, _output_tex } + end + for i = 1, #lumi_obj_list do + local lumi_obj = lumi_obj_list[i] + if lumi_obj then + local idx1 = (i-1)%2+1 + local idx2 = (i)%2+1 + if i == 1 then + lumi_obj:setInputTex(_input_tex) + lumi_obj:setOutputTex(pingpong[idx1]) + else + lumi_obj:setInputTex(pingpong[idx2]) + lumi_obj:setOutputTex(pingpong[idx1]) + end + if lumi_obj.effect_lua and lumi_obj.effect_lua.updateRenderTexture ~= nil then + lumi_obj.effect_lua:updateRenderTexture() + end + end + end + end +end + +function LumiObjectExtension:updateOutputRtSize(width, height) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i - 1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateOutputRtSize(width, height) + end + end + end + local tex = self:getOutputTex() + if tex then + tex.width = width + tex.height = height + end +end + +function LumiObjectExtension:getCameraCount() + local cam_count = 0 + + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + cam_count = cam_count + lumi_obj_ext:getCameraCount() + else + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + elseif self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + + return cam_count +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str.."0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiObjectExtension:updateCameraLayerAndOrder(_start_layer, _start_order) + function updateRendererEntityLayer(trans, layer) + local renderers = trans.entity:getComponentsRecursive("Renderer") + for i = 0, renderers:size() - 1 do + local renderer = renderers:get(i) + if renderer then + renderer.entity.layer = layer + end + end + end + + local lastCamera = nil + + local cur_start_layer = _start_layer + local cur_start_order = _start_order + + if self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local curTrans = self.trans.children:get(i-1) + local cam = curTrans.entity:getComponent("Camera") + if cam then + if lastCamera then + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + lastCamera = cam + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, curTrans.children:size() do + local rendererTrans = curTrans.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + elseif lastCamera then + updateRendererEntityLayer(curTrans, cur_start_layer) + end + end + + elseif self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateCameraLayerAndOrder(cur_start_layer, cur_start_order) + local cam_count = lumi_obj_ext:getCameraCount() + cur_start_layer = cur_start_layer + cam_count + cur_start_order = cur_start_order + cam_count + else + local cam = child.entity:getComponent("Camera") + if cam then + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, child.children:size() do + local rendererTrans = child.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end + end + + return cur_start_layer, cur_start_order +end + +function LumiObjectExtension:setEffectAttr(key, value) + if self.effect_lua and self.effect_lua.setEffectAttr ~= nil then + self.effect_lua:setEffectAttr(key, value, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + self.effect_lua[key] = value + if self.scriptComp and self.scriptComp.properties ~= nil then + self.scriptComp.properties:set(key, value) + end + end + end +end + +function LumiObjectExtension:getEffectAttr(key) + if self.effect_lua and self.effect_lua.getEffectAttr ~= nil then + return self.effect_lua:getEffectAttr(key, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + return self.effect_lua[key] + end + end + return nil +end + +function LumiObjectExtension:setSubEffectAttr(subName, key, value) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + subObj:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:getSubEffectAttr(subName, key) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + return subObj:getEffectAttr(key) + end + return nil +end + +function LumiObjectExtension:setEffectAttrRecursively(key, value) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:setEffectAttrRecursively(key, value) + end + end + self:setEffectAttr(key, value) + elseif self.__lumi_type == "lumi_obj" then + self:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:updateMaterials(time) + if self.effect_lua and self.scriptComp and self.entity and self.entity.visible then + if self.effect_lua.updateMaterial ~= nil then + self.effect_lua:updateMaterial(self.scriptComp, time) + elseif self.effect_lua.onUpdate ~= nil then + self.effect_lua:onUpdate(self.scriptComp, time) + end + + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateMaterials(time) + end + end + end +end + +function LumiObjectExtension:setVisible(subName, visible) + local subObj = self:searchSubLumiObjExt(subName) + if subObj and subObj.effect_lua then + if subObj.effect_lua.setVisible then + subObj.effect_lua:setVisible(visible) + else + subObj.entity.visible = visible + end + end +end + +return LumiObjectExtension diff --git a/scripts/7681552231262326017/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua b/scripts/7681552231262326017/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua new file mode 100644 index 0000000000000000000000000000000000000000..91587ae17803e82e95608198114893dfe226a5c9 --- /dev/null +++ b/scripts/7681552231262326017/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua @@ -0,0 +1,388 @@ +local LumiParamsSetter = {} +LumiParamsSetter.__index = LumiParamsSetter + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +function LumiParamsSetter.new(lumiManager, params, keyframes, effectType, sliderInfos, fadeinInfos, fadeoutInfos) + local self = setmetatable({}, LumiParamsSetter) + self.lumiManager = lumiManager + self.params = params + self.keyframes = keyframes + self.sliderInfos = sliderInfos + self.sliderParams = {} + self.XTEvent = (effectType == 'xtFilter' or effectType == 'xtEffect') + self.fadeinInfos = fadeinInfos + self.fadeoutInfos = fadeoutInfos + self.afterSliderParams = {} + + return self +end + +local function clamp(val, min, max) + return math.max(math.min(val, max), min) +end + +local function mix(a, b, t) + return a * (1 - t) + b * t +end + +local function cvtTable2Amaz(attrType, v) + local value = nil + if attrType == "number" then + if #v == 1 then + value = v[1] + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "vector" then + if #v == 2 then + value = Amaz.Vector2f(v[1], v[2]) + elseif #v == 3 then + value = Amaz.Vector3f(v[1], v[2], v[3]) + elseif #v == 4 then + value = Amaz.Vector4f(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "color" then + if #v == 3 then + value = Amaz.Color(v[1], v[2], v[3], 1.0) + elseif #v == 4 then + value = Amaz.Color(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. "unsupported type: " .. attrType) + end + return value +end + +local function getValueType(value) + local valueType = type(value) + if valueType == 'userdata' then + local str = tostring(value) + if string.sub(str, 1, 6) == 'Vector' then + valueType = 'vector' + elseif string.sub(str, 1, 5) == 'Color' then + valueType = 'color' + end + end + + return valueType +end + +local function add(value, number) + local type = getValueType(value) + if type == 'number' then + return value + number + elseif type == 'vector' then + local ret = value:copy() + ret.x = ret.x + number + ret.y = ret.y + number + if ret.z then ret.z = ret.z + number end + if ret.w then ret.w = ret.w + number end + return ret + elseif type == 'color' then + return Amaz.Color( + value.r + number, + value.g + number, + value.b + number, + value.a + number + ) + end + return nil +end + +local function mul(value, number) + local type = getValueType(value) + if type == 'color' then + return Amaz.Color( + value.r * number, + value.g * number, + value.b * number, + value.a * number + ) + end + return value * number +end + +function LumiParamsSetter:getCurrentDefaultParam(entityName, key, aeTime) + local keyframeName = nil + local keyframeType = 'number' + if self.keyframes ~= nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'number' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'vector' + keyframeType = 'vector' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'color' + keyframeType = 'color' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = nil + end + end + end + + if keyframeName == nil then + if entityName:sub(1, #'LumiLayer') == 'LumiLayer' and key:sub(-#'position') == 'position' then + local entity = self.params[entityName] + if entity ~= nil then + local position = entity[key] + if position ~= nil then + local hasSeparated = false + local newPosition = position:copy() + + local newKey = string.gsub(key, 'position', 'xPosition') + local newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.x = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'yPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.y = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'zPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.z = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + if hasSeparated then + return newPosition + end + end + end + end + end + end + + local value = nil + if keyframeName ~= nil then + value = cvtTable2Amaz(keyframeType, self.keyframes:GetVal(keyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + else + local entity = self.params[entityName] + if entity ~= nil then + value = entity[key] + end + end + return value +end + +function LumiParamsSetter:updateSlider(lumi_obj, aeTime) + -- local sliderIntensity = self.sliderParams['effects_adjust_blur'] + -- local gaussianIntensity = self:getCurrentDefaultParam("Gaussian_Blur_Root_353-effect2", 'intensity', aeTime) + -- if sliderIntensity and gaussianIntensity then + -- lumi_obj:setSubEffectAttr("Gaussian_Blur_Root_353-effect2", 'intensity', gaussianIntensity*sliderIntensity) + -- end + + local function fsub(value, slider, valueA, valueB) + -- (param - sliderValue) * valueA + valueB + return (value - slider) * valueA + valueB + end + + local function fmul(value, slider, valueA, valueB) + -- (param - valueA) * sliderValue + valueB + return (value - valueA) * slider + valueB + end + + local function fadd(value, slider, valueA, valueB) + -- (param - valueA) * valueB + sliderValue + return (value - valueA) * valueB + slider + end + + self.afterSliderParams = {} + for sliderKey, paramsInfos in pairs(self.sliderInfos) do + if self.sliderParams[sliderKey] ~= nil then + for index, value in ipairs(paramsInfos) do + local sliderIntensity = self.sliderParams[sliderKey] + local entityName = value[1] + local paramKey = value[2] + local paramType = value[3] + local paramDimensionFlag = value[4] + local calcType = value[5] + local maxValue = value[6] + local minValue = value[7] + local defaultValue = value[8] + local valueA = value[9] + local valueB = value[10] + sliderIntensity = sliderIntensity * (maxValue - minValue) + minValue + local oriValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + oriValue = self.afterSliderParams[entityName .. '#' .. paramKey] + end + local newValue = oriValue + local calcFunc = nil + if calcType == 0 then + calcFunc = fsub + elseif calcType == 1 then + calcFunc = fmul + elseif calcType == 2 then + calcFunc = fadd + else + Amaz.LOGE(AE_EFFECT_TAG, 'Unknown calcType: ' .. calcType) + return + end + if paramType == 'number' then + if paramDimensionFlag[1] then newValue = calcFunc(oriValue, sliderIntensity, valueA[1], valueB[1]) end + elseif paramType == 'color' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.r = calcFunc(oriValue.r, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.g = calcFunc(oriValue.g, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.b = calcFunc(oriValue.b, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.a = calcFunc(oriValue.a, sliderIntensity, valueA[4], valueB[4]) end + elseif paramType == 'vector' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.x = calcFunc(oriValue.x, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.y = calcFunc(oriValue.y, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.z = calcFunc(oriValue.z, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.w = calcFunc(oriValue.w, sliderIntensity, valueA[4], valueB[4]) end + end + lumi_obj:setSubEffectAttr(entityName, paramKey, newValue) + self.afterSliderParams[entityName .. '#' .. paramKey] = newValue + end + end + end +end + +function LumiParamsSetter:updateFadeParams(lumi_obj, fadeInfos, factor, aeTime) + for i = 1, #fadeInfos.infos do + local entityName = fadeInfos.infos[i][1] + local paramKey = fadeInfos.infos[i][2] + local valueType = fadeInfos.infos[i][3] + local value = fadeInfos.infos[i][4] + + local curValue = nil + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + curValue = self.afterSliderParams[entityName .. '#' .. paramKey] + else + curValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + end + + if curValue ~= nil then + local needRenew = true + if valueType == 'number' then + curValue = mix(value[1], curValue, factor) + elseif valueType == 'color' then + curValue.r = mix(value[1], curValue.r, factor) + curValue.g = mix(value[2], curValue.g, factor) + curValue.b = mix(value[3], curValue.b, factor) + curValue.a = mix(value[4], curValue.a, factor) + elseif valueType == 'vector' then + if #value <= 1 or #value >= 5 then + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid value size: ' .. #value) + else + if #value >= 2 then + curValue.x = mix(value[1], curValue.x, factor) + curValue.y = mix(value[2], curValue.y, factor) + end + if #value >= 3 then + curValue.z = mix(value[3], curValue.z, factor) + end + if #value >= 4 then + curValue.w = mix(value[4], curValue.w, factor) + end + end + else + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid valye type: ' .. valueType) + end + if needRenew then + lumi_obj:setSubEffectAttr(entityName, paramKey, curValue) + end + end + end +end + +function LumiParamsSetter:updateFade(lumi_obj, startTime, endTime, curTime, compDurations, aeTime) + local scale = (endTime - startTime) / (compDurations[2] - compDurations[1]) + scale = clamp(scale, 0, 1) + local runningTime = curTime - startTime + local remainingTime = endTime - curTime + + local isInFadein = false + if self.fadeinInfos + and self.fadeinInfos.time and self.fadeinInfos.time > 0 + and self.fadeinInfos.infos and #self.fadeinInfos.infos > 0 + then + local fadeinTime = self.fadeinInfos.time * scale + if runningTime <= fadeinTime then + isInFadein = true + local factor = runningTime / fadeinTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeinInfos, factor, aeTime) + end + end + + if self.fadeoutInfos + and self.fadeoutInfos.time and self.fadeoutInfos.time > 0 + and self.fadeoutInfos.infos and #self.fadeoutInfos.infos > 0 + then + local fadeoutTime = self.fadeoutInfos.time * scale + if remainingTime <= fadeoutTime or not isInFadein then + local factor = remainingTime / fadeoutTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeoutInfos, factor, aeTime) + end + end +end + +function LumiParamsSetter:onEvent(lumi_obj, event) + if lumi_obj == nil or event == nil then return end + local key = event.args:get(0) + if self.sliderInfos[key] ~= nil then + if self.XTEvent then + self.sliderParams[key] = event.args:get(2); + else + self.sliderParams[key] = event.args:get(1); + end + end +end + +function LumiParamsSetter:initParams(lumi_obj) + if lumi_obj == nil then return end + if self.params == nil then return end + if self.init then return end + + for entityName, params in pairs(self.params) do + for key, value in pairs(params) do + lumi_obj:setSubEffectAttr(entityName, key, value) + end + end + + self.init = true +end + +function LumiParamsSetter:updateKeyFrameData(lumi_obj, aeTime) + if lumi_obj == nil then return end + if self.keyframes == nil then return end + + local p = aeTime + for key, _ in pairs(self.keyframes.attrs) do + local keys = {} + for substr in string.gmatch(key, "[^#]+") do + table.insert(keys, substr) + end + if #keys == 3 then + local entityName = keys[1] + local attrName = keys[2] + local attrType = keys[3] + local v = self.keyframes:GetVal(key, self.lumiManager:getKeyframeAeTime(p)) + local value = cvtTable2Amaz(attrType, v) + if value then + lumi_obj:setSubEffectAttr(entityName, attrName, value) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key) + end + end +end + +return LumiParamsSetter diff --git a/scripts/7681552231262326017/config.json b/scripts/7681552231262326017/config.json new file mode 100644 index 0000000000000000000000000000000000000000..440115e0e5310bac2421711b9df3d8cad8d1f6c7 --- /dev/null +++ b/scripts/7681552231262326017/config.json @@ -0,0 +1,16 @@ +{ + "ae_tool": "AEExporter:1.5.5", + "bALG_BACH_CONFIG": false, + "effect": { + "Link": [ + { + "path": "AmazingFeature/", + "type": "AmazingFeature", + "zorder": 8029 + } + ] + }, + "name": "AE2Effect_20260904131613592", + "version": "14.8.0", + "item_source": "user_post_pc_le" +} \ No newline at end of file diff --git a/scripts/7681552231262326017/extra.json b/scripts/7681552231262326017/extra.json new file mode 100644 index 0000000000000000000000000000000000000000..f4e6b748e1b7b1b6f1c714fedd8c7b87ebaef725 --- /dev/null +++ b/scripts/7681552231262326017/extra.json @@ -0,0 +1,6 @@ +{ + "transition": { + "defaultDura": 2.000001, + "isOverlap": true + } +} \ No newline at end of file diff --git a/scripts/7681559524355968264/AmazingFeature/content.json b/scripts/7681559524355968264/AmazingFeature/content.json new file mode 100644 index 0000000000000000000000000000000000000000..df43720515b1b6981b24c4268c902195fa613d43 --- /dev/null +++ b/scripts/7681559524355968264/AmazingFeature/content.json @@ -0,0 +1,7 @@ +{ + "ae_tool" : "AmazingEditor", + "content" : {}, + "needblend" : false, + "tag" : "AMG_1515088281693380358513659446614427937212", + "version" : "1.0" +} \ No newline at end of file diff --git a/scripts/7681559524355968264/AmazingFeature/js/JSSys.js b/scripts/7681559524355968264/AmazingFeature/js/JSSys.js new file mode 100644 index 0000000000000000000000000000000000000000..bbcbf36f0f75c1beebe88c33dd0464bb4477158e --- /dev/null +++ b/scripts/7681559524355968264/AmazingFeature/js/JSSys.js @@ -0,0 +1,89 @@ +const effect_api = "undefined" != typeof effect ? effect : "undefined" != typeof tt ? tt : "undefined" != typeof lynx ? lynx : {}; +const Amaz = effect_api.getAmaz(); + +const { ScriptScene } = require('./ThreeJS/scriptScene'); +const THREE = require('./ThreeJS/three-amg-wrapper').THREE; + +class JSSys { + constructor() { + this.name = "JSSys"; + this.comps = {} + this.compsdirty = true + } + + onComponentAdded(comp) { + // console.log("running:JSSys:onComponentAdded"); + } + onComponentRemoved(comp) { + // console.log("running:JSSys:onComponentRemoved"); + } + + onStart() { + console.log("running:JSSys:onStart"); + + this.renderTexture = this.scene.assetMgr.SyncLoad('rt/outputTex.rt'); + + // 添加光源到场景 + console.log('JSSys: 创建ScriptScene实例'); + this.scriptScene = new ScriptScene(this.scene); + + this.input = Amaz.AmazingManager.getSingleton("Input"); + const builtinObject = Amaz.AmazingManager.getSingleton("BuiltinObject"); + + if (builtinObject.getUserTexture("#TransitionInput0") && builtinObject.getUserTexture("#TransitionInput1")) { + this.scriptScene.texture1 = new THREE.Texture(); + this.scriptScene.texture1.setImage(builtinObject.getUserTexture("#TransitionInput0")); + this.scriptScene.texture2 = new THREE.Texture(); + this.scriptScene.texture2.setImage(builtinObject.getUserTexture("#TransitionInput1")); + console.log("JSSys: 获取到纹理"); + } + else + { + this.scriptScene.texture1 = new THREE.Texture(); + this.scriptScene.texture1.setImage(this.scene.assetMgr.SyncLoad('image/Sample1.jpg')); + this.scriptScene.texture2 = new THREE.Texture(); + this.scriptScene.texture2.setImage(this.scene.assetMgr.SyncLoad('image/Sample2.jpg')); + console.log("JSSys: 未获取到纹理,使用默认纹理"); + } + + this.scriptScene.setupScene(); + // 初始化后处理效果 + if (this.scriptScene.initPostProcessing != null) { + this.scriptScene.initPostProcessing(); + } + } + + onUpdate(deltaTime) { + this.time = this.input.getFrameTimestamp(); + // this.time = this.time % 2; + // this.time = this.time / 2.0; + this.scriptScene.seekToTime(this.time * this.scriptScene.Duration); + // this.scriptScene.updateScene(); + } + onLateUpdate(deltaTime) { + // console.log("running:JSSys:onLateUpdate"); + this.scriptScene.scene.seekToTime(this.time * this.scriptScene.Duration); + } + + onEvent(event) { + console.log("running:JSSys:onEvent"); + if (event.type == Amaz.EventType.VIEWER) { + // console.log("JSSys: 窗口大小改变"); + console.log("renderTexture.width",this.renderTexture.width); + console.log("renderTexture.height",this.renderTexture.height); + + window.innerWidth = this.renderTexture.width; + window.innerHeight = this.renderTexture.height; + // console.log("JSSys: 窗口大小改变"); + this.scriptScene.handleResize(); + } + } + + onDestroy() { + // console.log("running:JSSys:onDestroy"); + this.scriptScene.destroy(); + } +} + +exports.JSSys = JSSys; + diff --git a/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/EffectComposer.js b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/EffectComposer.js new file mode 100644 index 0000000000000000000000000000000000000000..e7d8fd7a3f3978d9da1a9bf29af1854806f60014 --- /dev/null +++ b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/EffectComposer.js @@ -0,0 +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{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-6*k)*Math.cos(12*k)};const springStiff=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(18*k)};const dampedOscillation=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(10*k)};const Physics=Object.freeze({SpringSoft:springSoft,SpringStiff:springStiff,DampedOscillation:dampedOscillation});const anticipate=k=>{if(k<=0)return 0;if(k>=1)return 1;const pullback=.1;if(k<.3){const p=k/.3;return-pullback*p*(2-p)}const p=(k-.3)/.7;return-pullback+(1+pullback)*p*p*(3-2*p)};const overshootFactory=peak=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return peak*p*(2-p)}const p=(k-.6)/.4;return peak+(1-peak)*(1-Math.pow(1-p,3))};const overshoot110=overshootFactory(1.1);const overshoot125=overshootFactory(1.25);const snapBack=k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return 1.05*(1-Math.pow(1-p,3))}const p=(k-.6)/.4;return 1.05-.05*p*p*(3-2*p)};const swing=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.cos(1.5*Math.PI*k)*Math.exp(-2.5*k)};const Motion=Object.freeze({Anticipate:anticipate,Overshoot110:overshoot110,Overshoot125:overshoot125,SnapBack:snapBack,Swing:swing});const makeStep=(n,jumpTerm="end")=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(jumpTerm==="start")return Math.ceil(k*n)/n;return Math.floor(k*n)/n};const Step=Object.freeze({Steps4End:makeStep(4,"end"),Steps8End:makeStep(8,"end"),Steps12End:makeStep(12,"end")});function buildCubicBezier(x1,y1,x2,y2){const cx=3*x1,bx=3*(x2-x1)-cx,ax=1-cx-bx;const cy=3*y1,by=3*(y2-y1)-cy,ay=1-cy-by;const sampleX=s=>((ax*s+bx)*s+cx)*s;const sampleY=s=>((ay*s+by)*s+cy)*s;const sampleDX=s=>(3*ax*s+2*bx)*s+cx;const solveS=x=>{let s=x;for(let i=0;i<8;i++){const cur=sampleX(s)-x;if(Math.abs(cur)<1e-6)return s;const d=sampleDX(s);if(Math.abs(d)<1e-6)break;s-=cur/d;if(s<0)s=0;if(s>1)s=1}let lo=0,hi=1;for(let i=0;i<32&&hi-lo>1e-6;i++){const mid=(lo+hi)/2;if(sampleX(mid){if(k<=0)return 0;if(k>=1)return 1;return sampleY(solveS(k))}}const BEZIER_PRESETS=Object.freeze({"Material.Standard":[.4,0,.2,1],"Material.Accelerate":[.4,0,1,1],"Material.Decelerate":[0,0,.2,1],"CSS.Ease":[.25,.1,.25,1]});const _bezierCache=new Map;function _cachedBezier(x1,y1,x2,y2){const key=x1+","+y1+","+x2+","+y2;let fn=_bezierCache.get(key);if(!fn){fn=buildCubicBezier(x1,y1,x2,y2);_bezierCache.set(key,fn)}return fn}function cubicBezier(a,b,c,d){if(typeof a==="string"){let preset=BEZIER_PRESETS[a];if(!preset){console.warn("[customEasings.cubicBezier] unknown preset, falling back to Material.Standard:",a);preset=BEZIER_PRESETS["Material.Standard"]}return _cachedBezier(preset[0],preset[1],preset[2],preset[3])}const clamp=(v,lo,hi)=>Math.max(lo,Math.min(hi,v));const x1=clamp(a,0,1);const y1=clamp(b,-.5,1.5);const x2=clamp(c,0,1);const y2=clamp(d,-.5,1.5);return _cachedBezier(x1,y1,x2,y2)}const libSpring=({stiffness=180,damping=12,mass=1}={})=>{const DT=1/240;const T=1.5;let x=0,v=0;const samples=[];for(let t=0;t<=T;t+=DT){const force=-stiffness*(x-1)-damping*v;v+=force/mass*DT;x+=v*DT;samples.push({t:t,x:x})}let T_end=T;for(let i=samples.length-1;i>=0;i--){if(Math.abs(samples[i].x-1)>.01){T_end=samples[i].t;break}}return k=>{if(k<=0)return 0;if(k>=1)return 1;const t=k*T_end;const idx=Math.min(samples.length-1,Math.floor(t/DT));return samples[idx].x}};const libHeartBeat=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c)=>Math.exp(-((t-c)**2)/(2*.07*.07));return peak*(bell(k,.2)+bell(k,.5))};const libSteps=(n=6)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return Math.floor(k*n)/n};const attentionPing=(peak=.35,decay=2)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(Math.PI*k)*Math.exp(-decay*k)};const attentionWiggle=(count=4,amplitude=.25)=>k=>{if(k<=0||k>=1)return 0;const env=1-k;return amplitude*env*Math.sin(k*Math.PI*2*count)};const attentionStrum=(notes=4,peak=.4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*.05*.05))}return peak*sum}};const Attention=Object.freeze({Ping:attentionPing(),Wiggle:attentionWiggle(),Strum:attentionStrum()});const breathNormal=(cycles=2,peak=.15)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(k*Math.PI*2*cycles)*Math.sin(k*Math.PI)};const breathDeep=(peak=.3,riseRatio=.35,holdRatio=.15)=>{const holdEnd=riseRatio+holdRatio;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const envelope=Math.sin(k*Math.PI);const wave=.5+.5*Math.sin(k*Math.PI*2*cycles-Math.PI/2);return peak*envelope*wave};const breathSigh=(peak=.25,riseRatio=.2)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return peak*Math.exp(-((k-center)**2)/(2*width*width))};const heartExcited=(beats=4,peak=.3,width=.04)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*width*width))}return peak*sum}};const heartLubDub=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return peak*(bell(k,.25,.045)+.6*bell(k,.42,.03))};const Heart=Object.freeze({Calm:heartCalm(),Excited:heartExcited(),LubDub:heartLubDub()});const mathJumpArc=()=>k=>{if(k<=0||k>=1)return 0;return 4*k*(1-k)};const mathPendulum=(damping=3,freq=2.5)=>k=>{if(k<=0||k>=1)return 0;return Math.sin(k*Math.PI)*Math.exp(-damping*k)*Math.cos(freq*Math.PI*k)};const mathTremor=(amplitude=.04,freq=22)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return k+amplitude*Math.sin(k*Math.PI*2*freq)};const mathBoomerang=fn=>k=>{if(k<=0||k>=1)return 0;return k<.5?fn(k*2):fn(2-k*2)};const MathExt=Object.freeze({JumpArc:mathJumpArc(),Pendulum:mathPendulum(),Tremor:mathTremor()});const explosionImpulse=(sharpness=6)=>{const tail=sharpness*Math.exp(1-sharpness);return k=>{if(k<=0||k>=1)return 0;const h=sharpness*k;return h*Math.exp(1-h)-tail*k}};const explosionFlash=(rise=.05,decay=5)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return-Math.exp(-decay*k)*Math.cos(freq*Math.PI*k)};const explosionImplosion=(charge=.3,depth=.4,burstPeak=1.2)=>{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const w=Math.sin(k*Math.PI*2*cycles)+.5*Math.sin(k*Math.PI*2*cycles*1.5+1.2)+.25*Math.sin(k*Math.PI*2*cycles*3+2.4);return amplitude*env*w*.6};const natureFlicker=(rate=15,intensity=.2,seed=7)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=rate+1;i++)samples.push(rand());return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*rate;const idx=Math.floor(pos);const t=pos-idx;const a=samples[idx];const b=samples[idx+1];const interp=a+(b-a)*t;return intensity*env*(interp-.5)*2}};const natureGust=(gusts=3,peak=.25)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*.08*.08))}return peak*sum/gusts*1.8}};const Nature=Object.freeze({Wave:natureWave(),Flicker:natureFlicker(),Gust:natureGust()});const impactRain=(impactAt=.7,rippleAmp=.08)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const liftEnd=.35,strikeEnd=.6;return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return t*t}const t=(k-.4)/.6;const env=Math.exp(-2.5*t);const wave=Math.abs(Math.sin(t*Math.PI*bounces));return 1-env*wave*rebound};const impactSlap=(contactAt=.3,holdRatio=.1)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return.4*Math.pow(t,2.5)}if(k<.48){const t=(k-.4)/.08;return.4-.2*t}if(k<.52){const t=(k-.48)/.04;return.2+.8*t}const t=(k-.52)/.48;return 1-.04*Math.sin(t*Math.PI*8)*(1-t)};const rhythmPunchCombo=(peak=.4)=>{const pattern=[{c:.15,w:.04,a:.75},{c:.35,w:.04,a:.75},{c:.7,w:.055,a:1}];return k=>{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of pattern){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return peak*sum}};const rhythmStaccato=(beats=4,duty=.3)=>k=>{if(k<=0||k>=1)return 0;const beatLen=1/beats;const phase=k/beatLen-Math.floor(k/beatLen);if(phase>duty)return 0;const t=phase/duty;return Math.sin(t*Math.PI)};const rhythmKick=(peak=1.2)=>k=>{if(k<=0||k>=1)return 0;if(k<.05)return peak*k/.05;const t=(k-.05)/.95;return peak*Math.exp(-4*t)};const rhythmCrescendo=(beats=4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return sum}};const rhythmDunDunDun=()=>{const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return k=>{if(k<=0||k>=1)return 0;return.3*bell(k,.15,.025)+.6*bell(k,.35,.03)+1*bell(k,.68,.09)}};const rhythmBellToll=(decay=3,freq=8)=>{const strike=.05;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.2){const t=k/.2;return-pressDepth*Math.sin(t*Math.PI/2)}if(k<.5){const t=(k-.2)/.3;return-pressDepth+(pressDepth+reboundPeak)*(1-Math.pow(1-t,3))}const t=(k-.5)/.5;return reboundPeak*Math.exp(-4*t)*Math.cos(t*Math.PI*3)};const uiHoverBloom=(riseRatio=.2,fallRatio=.3)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=1-k;const raw=Math.sin(k*Math.PI*2*count);const clipped=Math.sign(raw)*Math.min(1,Math.abs(raw)*1.8);return amplitude*env*clipped};const uiSuccessPop=(overshoot=.2)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return(1+overshoot)*(1-Math.pow(1-t,2))}const t=(k-.4)/.6;return 1+overshoot*Math.exp(-5*t)*Math.cos(t*Math.PI*3)};const uiRippleOut=()=>k=>{if(k<=0||k>=1)return 0;return 6.75*k*Math.pow(1-k,2)};const UI=Object.freeze({ClickSnap:uiClickSnap(),HoverBloom:uiHoverBloom(),ErrorShake:uiErrorShake(),SuccessPop:uiSuccessPop(),RippleOut:uiRippleOut()});const magicManaCharge=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;const base=(Math.exp(3*k)-1)/(Math.exp(3)-1);const pulse=.04*Math.sin(k*Math.PI*8)*k;return base+pulse};const magicSpellCast=(chargeEnd=.4)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.45){const t=k/.45;return t*t*t}if(k<.55)return 1;const t=(k-.55)/.45;return Math.pow(1-t,3)};const magicShield=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.3){const t=k/.3;return 1.2*(1-Math.pow(1-t,2))}if(k<.6){const t=(k-.3)/.3;return 1.2-.2*t}const t=(k-.6)/.4;return 1+.03*Math.sin(t*Math.PI*3)};const magicAura=(peak=.15)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const fundamental=.6*Math.sin(k*Math.PI*2);const harmonic=.3*Math.sin(k*Math.PI*4+1);const overtone=.1*Math.sin(k*Math.PI*6+2);return peak*env*(fundamental+harmonic+overtone)};const Magic=Object.freeze({ManaCharge:magicManaCharge(),SpellCast:magicSpellCast(),Teleport:magicTeleport(),Shield:magicShield(),MagicAura:magicAura()});const animalCatPounce=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.2){const t=k/.2;return-.2*Math.sin(t*Math.PI)}if(k<.3){const t=(k-.2)/.1;return.5*t*t}if(k<.8){const t=(k-.3)/.5;return.5+.5*t+.2*Math.sin(t*Math.PI)}const t=(k-.8)/.2;return 1+.05*Math.sin(t*Math.PI)};const animalBirdFlap=(flaps=4)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const phase=k*Math.PI*2*flaps;const wave=Math.sin(phase)-.3*Math.sin(phase*2);return.2*env*wave};const animalSnakeSlither=(waves=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const wave=Math.sin(k*Math.PI*2*waves);return.2*env*wave};const animalButterflyFlit=(seed=13)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=26;i++)samples.push(rand()-.5);return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*25;const idx=Math.floor(pos);const t=pos-idx;const smooth=t*t*(3-2*t);const interp=samples[idx]+(samples[idx+1]-samples[idx])*smooth;return.3*env*interp}};const animalHorseGallop=(cycles=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const cyclePos=k*cycles-Math.floor(k*cycles);const bell=(c,w=.04)=>Math.exp(-((cyclePos-c)**2)/(2*w*w));return.25*env*(bell(0)+bell(.18)+bell(.36)+bell(.54))};const Animal=Object.freeze({CatPounce:animalCatPounce(),BirdFlap:animalBirdFlap(),SnakeSlither:animalSnakeSlither(),ButterflyFlit:animalButterflyFlit(),HorseGallop:animalHorseGallop()});const Progress=Object.freeze({Physics:Object.freeze({...Physics,Spring:libSpring()}),Motion:Motion,Step:Object.freeze({...Step,Steps6:libSteps()}),Math:Object.freeze({Tremor:MathExt.Tremor}),Impact:Object.freeze({Rain:Impact.Rain,Hammer:Impact.Hammer,BounceDrop:Impact.BounceDrop,ArrowHit:Impact.ArrowHit,Shatter:Impact.Shatter}),Rhythm:Object.freeze({BassDrop:Rhythm.BassDrop}),UI:Object.freeze({SuccessPop:UI.SuccessPop}),Magic:Object.freeze({ManaCharge:Magic.ManaCharge,Shield:Magic.Shield}),Animal:Object.freeze({CatPounce:Animal.CatPounce})});const Pulse=Object.freeze({Attention:Object.freeze({Ping:Attention.Ping}),Breath:Object.freeze({Deep:Breath.Deep,Sigh:Breath.Sigh}),Heart:Object.freeze({Calm:Heart.Calm}),Math:Object.freeze({JumpArc:MathExt.JumpArc,BoomerangSharp:mathBoomerang(E.Cubic.In),BoomerangSoft:mathBoomerang(E.Cubic.Out)}),Explosion:Object.freeze({Impulse:Explosion.Impulse,Flash:Explosion.Flash,Recoil:Explosion.Recoil,Implosion:Explosion.Implosion}),Impact:Object.freeze({Slap:Impact.Slap}),Rhythm:Object.freeze({Kick:Rhythm.Kick}),UI:Object.freeze({ClickSnap:UI.ClickSnap,HoverBloom:UI.HoverBloom,RippleOut:UI.RippleOut}),Magic:Object.freeze({SpellCast:Magic.SpellCast,Teleport:Magic.Teleport})});const Wave=Object.freeze({Attention:Object.freeze({Wiggle:Attention.Wiggle,Strum:Attention.Strum}),Breath:Object.freeze({Normal:Breath.Normal,Panting:Breath.Panting}),Heart:Object.freeze({Excited:Heart.Excited,LubDub:Heart.LubDub,Beat:libHeartBeat()}),Math:Object.freeze({Pendulum:MathExt.Pendulum}),Nature:Nature,Rhythm:Object.freeze({PunchCombo:Rhythm.PunchCombo,Staccato:Rhythm.Staccato,Crescendo:Rhythm.Crescendo,DunDunDun:Rhythm.DunDunDun,BellToll:Rhythm.BellToll}),UI:Object.freeze({ErrorShake:UI.ErrorShake}),Magic:Object.freeze({MagicAura:Magic.MagicAura}),Animal:Object.freeze({BirdFlap:Animal.BirdFlap,SnakeSlither:Animal.SnakeSlither,ButterflyFlit:Animal.ButterflyFlit,HorseGallop:Animal.HorseGallop})});const customEasings=Object.freeze({makeOutIn:makeOutIn,OutIn:OutIn,Progress:Progress,Pulse:Pulse,Wave:Wave,cubicBezier:cubicBezier});exports.customEasings=customEasings;exports.default=customEasings; \ No newline at end of file diff --git a/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/scriptScene.js b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/scriptScene.js new file mode 100644 index 0000000000000000000000000000000000000000..3b51b6a658804d8fdd2813f23adf82e0cd82a301 --- /dev/null +++ b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/scriptScene.js @@ -0,0 +1,159 @@ +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)}addAnimations(){const duration=this.Duration;const tweens=[];const clampTime=time=>Math.max(50,Math.min(duration-50,time));const createPresetTween=(shaderPass,fromPreset,toPreset,startTime,endTime,easing)=>{if(typeof shaderPass.getPresetConfig!=="function"||typeof shaderPass.setParameter!=="function"){console.error(`${shaderPass.constructor.name} 中没有 getPresetConfig 或 setParameter 方法`);return null}const fromConfig=shaderPass.getPresetConfig(fromPreset);const toConfig=shaderPass.getPresetConfig(toPreset);if(!fromConfig){console.error(`${shaderPass.constructor.name} 中没有 ${fromPreset} 预设配置`);return null}if(!toConfig){console.error(`${shaderPass.constructor.name} 中没有 ${toPreset} 预设配置`);return null}const safeStart=clampTime(startTime);const safeEnd=clampTime(endTime);const tweenDuration=Math.max(0,safeEnd-safeStart);const tweenTarget={...fromConfig};for(const key in tweenTarget){shaderPass.setParameter(key,tweenTarget[key])}return new TWEEN.Tween(tweenTarget).to({...toConfig},tweenDuration).delay(safeStart).easing(easing).onUpdate(obj=>{for(const key in obj){shaderPass.setParameter(key,obj[key])}})};const applyPresetAtTime=(shaderPass,presetName,applyTime)=>{if(typeof shaderPass.getPresetConfig!=="function"||typeof shaderPass.setParameter!=="function"){console.error(`${shaderPass.constructor.name} 中没有 getPresetConfig 或 setParameter 方法`);return null}const presetConfig=shaderPass.getPresetConfig(presetName);if(!presetConfig){console.error(`${shaderPass.constructor.name} 中没有 ${presetName} 预设配置`);return null}const holder={t:0};const safeApplyTime=clampTime(applyTime);return new TWEEN.Tween(holder).to({t:1},1).delay(safeApplyTime).easing(TWEEN.Easing.Linear.None).onUpdate(()=>{for(const key in presetConfig){shaderPass.setParameter(key,presetConfig[key])}})};this.shaderPasses.forEach(shaderPass=>{if(shaderPass.constructor.name==="ChromaticAberrationShaderPass"){const tween1=createPresetTween(shaderPass,"none","glitch_split",50,380,TWEEN.Easing.Exponential.Out);const hold1=applyPresetAtTime(shaderPass,"glitch_split",380);const tween2=createPresetTween(shaderPass,"glitch_split","medium",1200,1650,TWEEN.Easing.Exponential.InOut);const tween3=createPresetTween(shaderPass,"medium","none",1650,1950,TWEEN.Easing.Circular.Out);[tween1,hold1,tween2,tween3].forEach(tween=>{if(tween)tweens.push(tween)})}});tweens.forEach(tween=>tween.start());return tweens}initPostProcessing(){if(!this.usePostProcessing)return;const shaderPassConfigs=[{name:"LumiChromaticAberration"}];this.setupPostProcessing(shaderPassConfigs);const tweens=this.addAnimations();if(tweens.length>0){if(!this.sceneObjects.tweens){this.sceneObjects.tweens=[]}this.sceneObjects.tweens.push(...tweens)}}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()}setupScene(){this.initSceneObjects();this.scene.background=new THREE.Color(1710618);this.createGlitchTransitionPlane();this.setupAnimations();return this.sceneObjects}initSceneObjects(){this.Duration=2e3;this.camera.position.set(0,0,10);this.camera.lookAt(0,0,0);this.sceneObjects={transitionPlane:null,transitionMaterial:null,tweens:[],shared:{gridSize:8}}}createGlitchTransitionPlane(){const geometry=new THREE.PlaneGeometry(10,10,1,1);geometry.name="glitch_transition_plane_geometry";const material=this.createGlitchTransitionMaterial();material.name="glitch_transition_shader_material";const plane=new THREE.Mesh(geometry,material);plane.name="glitch_transition_plane";plane.position.set(0,0,0);plane.scale.set(1,1,1);this.scene.add(plane);this.sceneObjects.transitionPlane=plane;this.sceneObjects.transitionMaterial=material}createGlitchTransitionMaterial(){const gridSize=this.sceneObjects.shared.gridSize;return new THREE.ShaderMaterial({uniforms:{texture1:{value:this.texture1},texture2:{value:this.texture2},u_brightness:{value:1},u_grayscale:{value:0},u_chromatic:{value:0},u_glitchStrength:{value:0},u_eraseProgress:{value:0},u_restoreProgress:{value:0},u_blurStrength:{value:0},u_gridSize:{value:gridSize}},vertexShader:` + varying vec2 vUv; + + void main() { + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); + } + `,fragmentShader:` + uniform sampler2D texture1; + uniform sampler2D texture2; + uniform float u_brightness; + uniform float u_grayscale; + uniform float u_chromatic; + uniform float u_glitchStrength; + uniform float u_eraseProgress; + uniform float u_restoreProgress; + uniform float u_blurStrength; + uniform float u_gridSize; + + varying vec2 vUv; + + float random(vec2 st) { + return fract(sin(dot(st, vec2(12.9898, 78.233))) * 43758.5453123); + } + + vec3 applyColdGray(vec3 color) { + float gray = dot(color, vec3(0.299, 0.587, 0.114)); + vec3 cold = vec3(gray * 0.85, gray * 0.92, gray * 1.08); + cold = clamp((cold - 0.5) * 1.35 + 0.5, 0.0, 1.0); + return cold; + } + + vec3 applySaturation(vec3 color, float sat) { + float l = dot(color, vec3(0.299, 0.587, 0.114)); + return mix(vec3(l), color, sat); + } + + vec2 quantizePixel(vec2 uv, float pixels) { + return (floor(uv * pixels) + 0.5) / pixels; + } + + vec2 glitchUv(vec2 uv, float strength) { + float band = floor(uv.y * 42.0) / 42.0; + float rnd1 = random(vec2(band, 0.17)); + float rnd2 = random(vec2(band, 3.71)); + float dir = sign(rnd1 - 0.5); + float shift = (rnd1 - 0.5) * 0.12 * strength; + float fine = sin(uv.y * 180.0 + rnd2 * 6.28318) * 0.006 * strength; + uv.x += shift + fine * dir; + return uv; + } + + vec4 sampleGlitchA(vec2 uv) { + vec2 gUv = glitchUv(uv, u_glitchStrength); + vec2 pixUv = quantizePixel(gUv, mix(220.0, 48.0, clamp(u_glitchStrength, 0.0, 1.0))); + + float band = floor(uv.y * 32.0) / 32.0; + float shiftR = (random(vec2(band, 1.13)) - 0.5) * 0.06 * u_glitchStrength; + float shiftB = (random(vec2(band, 2.31)) - 0.5) * 0.06 * u_glitchStrength; + + vec2 uvR = vec2(clamp(pixUv.x + shiftR, 0.0, 1.0), clamp(pixUv.y, 0.0, 1.0)); + vec2 uvG = vec2(clamp(pixUv.x, 0.0, 1.0), clamp(pixUv.y, 0.0, 1.0)); + vec2 uvB = vec2(clamp(pixUv.x + shiftB, 0.0, 1.0), clamp(pixUv.y, 0.0, 1.0)); + + vec3 color; + color.r = texture2D(texture1, uvR).r; + color.g = texture2D(texture1, uvG).g; + color.b = texture2D(texture1, uvB).b; + + vec3 blurMix = vec3(0.0); + float offsets[5]; + offsets[0] = -2.0; + offsets[1] = -1.0; + offsets[2] = 0.0; + offsets[3] = 1.0; + offsets[4] = 2.0; + + for (int i = 0; i < 5; i++) { + float ox = offsets[i] * 0.01 * u_glitchStrength; + vec2 suv = vec2(clamp(pixUv.x + ox, 0.0, 1.0), clamp(pixUv.y, 0.0, 1.0)); + blurMix += texture2D(texture1, suv).rgb; + } + blurMix /= 5.0; + + color = mix(color, blurMix, clamp(u_glitchStrength * 0.65, 0.0, 1.0)); + color *= u_brightness; + color = mix(color, vec3(max(max(color.r, color.g), color.b)), clamp((u_brightness - 1.0) / 1.6, 0.0, 1.0) * 0.65); + return vec4(clamp(color, 0.0, 1.0), 1.0); + } + + vec4 sampleBState(vec2 uv, vec2 cellId, float cellRnd) { + vec2 centered = uv - 0.5; + float scale = 1.0 + u_blurStrength * (0.06 + cellRnd * 0.06); + vec2 scaledUv = centered / scale + 0.5; + + float offsetMag = u_blurStrength * (0.02 + cellRnd * 0.02); + vec2 offsetDir = vec2( + (random(cellId + 4.11) - 0.5) * 2.0, + (random(cellId + 7.77) - 0.5) * 2.0 + ); + scaledUv += offsetDir * offsetMag; + scaledUv = clamp(scaledUv, 0.0, 1.0); + + vec2 pixelUv = quantizePixel(scaledUv, 64.0 + cellRnd * 36.0); + vec4 texColor = texture2D(texture2, pixelUv); + + vec3 coldGray = applyColdGray(texColor.rgb); + float localRestore = clamp((u_restoreProgress - cellRnd * 0.45) / max(1.0 - cellRnd * 0.45, 0.0001), 0.0, 1.0); + vec3 restored = mix(coldGray, texColor.rgb, localRestore); + + float grayscaleAmount = clamp(1.0 - u_grayscale, 0.0, 1.0); + vec3 finalColor = mix(restored, applyColdGray(restored), grayscaleAmount); + return vec4(finalColor, texColor.a); + } + + void main() { + vec2 uv = vUv; + vec2 cell = floor(uv * u_gridSize); + vec2 cellId = cell + vec2(0.5); + float cellRnd = random(cellId); + float stepped = clamp(u_eraseProgress, 0.0, 1.0); + float reveal = step(cellRnd, stepped); + + vec4 colorA = sampleGlitchA(uv); + vec4 colorB = sampleBState(uv, cellId, cellRnd); + + vec4 mixedColor = mix(colorA, colorB, reveal); + + vec2 mappedUv = uv; + vec2 dir = mappedUv - vec2(0.5); + float offset = u_chromatic * 0.02; + float r = mixedColor.r; + float g = mixedColor.g; + float b = mixedColor.b; + + if (u_chromatic > 0.0001) { + vec2 uvR = clamp(mappedUv + dir * offset, 0.0, 1.0); + vec2 uvB = clamp(mappedUv - dir * offset, 0.0, 1.0); + + vec2 cellR = floor(uvR * u_gridSize); + vec2 cellB = floor(uvB * u_gridSize); + float rndR = random(cellR + vec2(0.5)); + float rndB = random(cellB + vec2(0.5)); + float revealR = step(rndR, stepped); + float revealB = step(rndB, stepped); + + vec4 colorAR = sampleGlitchA(uvR); + vec4 colorBR = sampleBState(uvR, cellR + vec2(0.5), rndR); + vec4 colorAB = sampleGlitchA(uvB); + vec4 colorBB = sampleBState(uvB, cellB + vec2(0.5), rndB); + + r = mix(colorAR, colorBR, revealR).r; + g = mixedColor.g; + b = mix(colorAB, colorBB, revealB).b; + } + + gl_FragColor = vec4(r, g, b, 1.0); + } + `,transparent:false,side:THREE.DoubleSide})}setupAnimations(){const plane=this.sceneObjects.transitionPlane;const material=this.sceneObjects.transitionMaterial;const uniforms=material.uniforms;const baseLookAt=new THREE.Vector3(0,0,0);const brightnessStartState={value:1};const brightnessEndState={value:2.6};const brightnessTween=new TWEEN.Tween(brightnessStartState).to(brightnessEndState,230).delay(50).easing(TWEEN.Easing.Exponential.Out).onUpdate(obj=>{uniforms.u_brightness.value=obj.value;this.camera.lookAt(baseLookAt)}).start();this.sceneObjects.tweens.push(brightnessTween);const glitchStartState={value:0};const glitchEndState={value:1};const glitchInTween=new TWEEN.Tween(glitchStartState).to(glitchEndState,230).delay(50).easing(TWEEN.Easing.Cubic.Out).onUpdate(obj=>{uniforms.u_glitchStrength.value=obj.value;this.camera.lookAt(baseLookAt)}).start();this.sceneObjects.tweens.push(glitchInTween);const eraseStartState={value:0};const eraseEndState={value:1};const eraseTween=new TWEEN.Tween(eraseStartState).to(eraseEndState,920).delay(280).easing(customEasings.Progress.Step.Steps8End).onUpdate(obj=>{uniforms.u_eraseProgress.value=obj.value;this.camera.lookAt(baseLookAt)}).start();this.sceneObjects.tweens.push(eraseTween);const grayscaleStartState={value:0};const grayscaleEndState={value:1};const grayscaleTween=new TWEEN.Tween(grayscaleStartState).to(grayscaleEndState,580).delay(1200).easing(TWEEN.Easing.Sinusoidal.InOut).onUpdate(obj=>{uniforms.u_grayscale.value=obj.value;this.camera.lookAt(baseLookAt)}).start();this.sceneObjects.tweens.push(grayscaleTween);const blurStartState={value:1};const blurEndState={value:0};const blurTween=new TWEEN.Tween(blurStartState).to(blurEndState,580).delay(1200).easing(TWEEN.Easing.Circular.Out).onUpdate(obj=>{uniforms.u_blurStrength.value=obj.value;this.camera.lookAt(baseLookAt)}).start();this.sceneObjects.tweens.push(blurTween);const restoreStartState={value:0};const restoreEndState={value:1};const restoreTween=new TWEEN.Tween(restoreStartState).to(restoreEndState,580).delay(1200).easing(TWEEN.Easing.Sinusoidal.InOut).onUpdate(obj=>{uniforms.u_restoreProgress.value=obj.value;this.camera.lookAt(baseLookAt)}).start();this.sceneObjects.tweens.push(restoreTween);const brightnessResetStartState={value:2.6};const brightnessResetEndState={value:1};const brightnessResetTween=new TWEEN.Tween(brightnessResetStartState).to(brightnessResetEndState,580).delay(1200).easing(TWEEN.Easing.Circular.Out).onUpdate(obj=>{uniforms.u_brightness.value=obj.value;this.camera.lookAt(baseLookAt)}).start();this.sceneObjects.tweens.push(brightnessResetTween);const glitchResetStartState={value:1};const glitchResetEndState={value:0};const glitchResetTween=new TWEEN.Tween(glitchResetStartState).to(glitchResetEndState,580).delay(1200).easing(TWEEN.Easing.Circular.Out).onUpdate(obj=>{uniforms.u_glitchStrength.value=obj.value;this.camera.lookAt(baseLookAt)}).start();this.sceneObjects.tweens.push(glitchResetTween);const baseScale=1;const scalePulseState={offset:0};const scalePulseTween=new TWEEN.Tween(scalePulseState).to({offset:.03},450).delay(1200).easing(customEasings.Pulse.Explosion.Recoil).onUpdate(obj=>{const scaleValue=baseScale+obj.offset;plane.scale.set(scaleValue,scaleValue,scaleValue);this.camera.lookAt(baseLookAt)}).start();this.sceneObjects.tweens.push(scalePulseTween);const baseChromatic=0;const chromaticPulseState={offset:0};const chromaticPulseTween=new TWEEN.Tween(chromaticPulseState).to({offset:.28},450).delay(1200).easing(customEasings.Pulse.Explosion.Flash).onUpdate(obj=>{uniforms.u_chromatic.value=baseChromatic+obj.offset;this.camera.lookAt(baseLookAt)}).start();this.sceneObjects.tweens.push(chromaticPulseTween)}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; \ No newline at end of file diff --git a/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/three-amg-wrapper.js b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/three-amg-wrapper.js new file mode 100644 index 0000000000000000000000000000000000000000..c2037e314e032c4d36912923d4cc1258cba3ab19 --- /dev/null +++ b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/three-amg-wrapper.js @@ -0,0 +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;iobj.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; \ No newline at end of file diff --git a/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/tween.js b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/tween.js new file mode 100644 index 0000000000000000000000000000000000000000..690fb9e4284728629129deed5a5a3f4bcec291ed --- /dev/null +++ b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/tween.js @@ -0,0 +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=power1e4?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;_i0){this._tweensAddedDuringUpdate={};for(var i=0;i1){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[m1;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;itotalTime){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;ithis.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;ithis.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.xthis.max.x||box.max.ythis.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; \ No newline at end of file diff --git a/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Box3.js b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Box3.js new file mode 100644 index 0000000000000000000000000000000000000000..4100dc7442d3a622827c8a415e24557f68c491f1 --- /dev/null +++ b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Box3.js @@ -0,0 +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=3?array[offset+2]:0;if(xthis.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=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.xthis.max.x||box.max.ythis.max.y||box.max.zthis.max.z)}}exports.Box3=Box3; \ No newline at end of file diff --git a/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..be3b8b1334a62f5e88c45feee098063a199fca55 --- /dev/null +++ b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js @@ -0,0 +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=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; \ No newline at end of file diff --git a/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..af9a8a13a46500e78f082a35e18d0b5932061234 --- /dev/null +++ b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js @@ -0,0 +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;iObject.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;i1?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; \ No newline at end of file diff --git a/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Constants.js b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Constants.js new file mode 100644 index 0000000000000000000000000000000000000000..6b8adda19a4d67236719804f5170889b39fd4582 --- /dev/null +++ b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Constants.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js new file mode 100644 index 0000000000000000000000000000000000000000..29b0aad5599401be17f967ba1d48851acb70c2ac --- /dev/null +++ b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js @@ -0,0 +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;i0||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;i0?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;imaxX)maxX=p.x;if(p.ymaxY)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; \ No newline at end of file diff --git a/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..f3dee08bf1c089e040fcfef228902ab9a39c93cb --- /dev/null +++ b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Earcut.js b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Earcut.js new file mode 100644 index 0000000000000000000000000000000000000000..953abffdf38c2def26df73fed180eff8c7644ced --- /dev/null +++ b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Earcut.js @@ -0,0 +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;imaxX)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=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=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.x&&p.x>=mx&&hx!==p.x&&pointInTriangle(hym.x||p.x===m.x&§orContainsSector(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.xb.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;i0||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=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;i0){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;imaxX)maxX=contour[i].x;if(contour[i].ymaxY)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;layerIdx0?-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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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; \ No newline at end of file diff --git a/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Group.js b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Group.js new file mode 100644 index 0000000000000000000000000000000000000000..90c4dbef65aa04d7a3bb6b6d76ec3317ea65a228 --- /dev/null +++ b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Group.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");class Group extends Object3D{constructor(name="Group_w"){super(name)}dispose(){super.dispose()}}exports.Group=Group; \ No newline at end of file diff --git a/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Material.js b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Material.js new file mode 100644 index 0000000000000000000000000000000000000000..81b97053ad9d1e4b1ef05d5ac6ed992487b2ca8e --- /dev/null +++ b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Material.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..dcf34d4cffb9de0869382a24690f78f60dda6049 --- /dev/null +++ b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js new file mode 100644 index 0000000000000000000000000000000000000000..41e6cd0a0eee7dd7bc497be5deac584806b68dc3 --- /dev/null +++ b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Mesh.js b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Mesh.js new file mode 100644 index 0000000000000000000000000000000000000000..254d69b074e797dd34c16d7dad723bbcc3b4895d --- /dev/null +++ b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Mesh.js @@ -0,0 +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;imaterial,set:value=>{material=value;if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;im.dispose&&m.dispose());else if(this.material.dispose)this.material.dispose()}}}exports.MeshWrapper=MeshWrapper; \ No newline at end of file diff --git a/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..ac394f66efc4e113a7127ee0f50ec672e4c5e9eb --- /dev/null +++ b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Object3D.js b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Object3D.js new file mode 100644 index 0000000000000000000000000000000000000000..8532c6122f839460aab34fe88957802ff523318b --- /dev/null +++ b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Object3D.js @@ -0,0 +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{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&¤tScene._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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js new file mode 100644 index 0000000000000000000000000000000000000000..ba39801de50d38ec04424f3c2ebfa2ff5d28fded --- /dev/null +++ b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js @@ -0,0 +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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..bc595fb80ad9e7c2f4d8360c67dbef556f3d6cbe --- /dev/null +++ b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js @@ -0,0 +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;iy0){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; \ No newline at end of file diff --git a/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..02dc1be955bc766de744222a7e75c65bf147bb61 --- /dev/null +++ b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js @@ -0,0 +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&¶meters.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{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=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=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=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; \ No newline at end of file diff --git a/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Shape.js b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Shape.js new file mode 100644 index 0000000000000000000000000000000000000000..ecde48b5ceb30812c922aa5c7cfe2aa7b50cabe4 --- /dev/null +++ b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Shape.js @@ -0,0 +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;i0){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;i0||(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;imaxX)maxX=p.x;if(p.ymaxY)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;i0?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;ipoints.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;itwoPi)deltaAngle-=twoPi;if(deltaAngle>4;uuid[i]=chars[i===19?r&3|8:r]}}return uuid.join("")}exports.Shape=Shape; \ No newline at end of file diff --git a/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..3786abc7d64ed80b56101c4ac9d30ce9fcb8f941 --- /dev/null +++ b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js @@ -0,0 +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;i0){const bounds=calculateBounds(flatVertices);const vertexOffset=vertices.length/3;for(let j=0;j0){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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}function calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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; \ No newline at end of file diff --git a/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..1ea27a55fbce9fc3771c66840c068e5ff6347092 --- /dev/null +++ b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Texture.js b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Texture.js new file mode 100644 index 0000000000000000000000000000000000000000..35bff49d732c9884e07bfcb5682f18a860485e1f --- /dev/null +++ b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Texture.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Vector2.js b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Vector2.js new file mode 100644 index 0000000000000000000000000000000000000000..a30a2431264ee62cec937714dfa9e50932ddedeb --- /dev/null +++ b/scripts/7681559524355968264/AmazingFeature/js/ThreeJS/wrapper/Vector2.js @@ -0,0 +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)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)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){if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-6*k)*Math.cos(12*k)};const springStiff=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(18*k)};const dampedOscillation=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(10*k)};const Physics=Object.freeze({SpringSoft:springSoft,SpringStiff:springStiff,DampedOscillation:dampedOscillation});const anticipate=k=>{if(k<=0)return 0;if(k>=1)return 1;const pullback=.1;if(k<.3){const p=k/.3;return-pullback*p*(2-p)}const p=(k-.3)/.7;return-pullback+(1+pullback)*p*p*(3-2*p)};const overshootFactory=peak=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return peak*p*(2-p)}const p=(k-.6)/.4;return peak+(1-peak)*(1-Math.pow(1-p,3))};const overshoot110=overshootFactory(1.1);const overshoot125=overshootFactory(1.25);const snapBack=k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return 1.05*(1-Math.pow(1-p,3))}const p=(k-.6)/.4;return 1.05-.05*p*p*(3-2*p)};const swing=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.cos(1.5*Math.PI*k)*Math.exp(-2.5*k)};const Motion=Object.freeze({Anticipate:anticipate,Overshoot110:overshoot110,Overshoot125:overshoot125,SnapBack:snapBack,Swing:swing});const makeStep=(n,jumpTerm="end")=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(jumpTerm==="start")return Math.ceil(k*n)/n;return Math.floor(k*n)/n};const Step=Object.freeze({Steps4End:makeStep(4,"end"),Steps8End:makeStep(8,"end"),Steps12End:makeStep(12,"end")});function buildCubicBezier(x1,y1,x2,y2){const cx=3*x1,bx=3*(x2-x1)-cx,ax=1-cx-bx;const cy=3*y1,by=3*(y2-y1)-cy,ay=1-cy-by;const sampleX=s=>((ax*s+bx)*s+cx)*s;const sampleY=s=>((ay*s+by)*s+cy)*s;const sampleDX=s=>(3*ax*s+2*bx)*s+cx;const solveS=x=>{let s=x;for(let i=0;i<8;i++){const cur=sampleX(s)-x;if(Math.abs(cur)<1e-6)return s;const d=sampleDX(s);if(Math.abs(d)<1e-6)break;s-=cur/d;if(s<0)s=0;if(s>1)s=1}let lo=0,hi=1;for(let i=0;i<32&&hi-lo>1e-6;i++){const mid=(lo+hi)/2;if(sampleX(mid){if(k<=0)return 0;if(k>=1)return 1;return sampleY(solveS(k))}}const BEZIER_PRESETS=Object.freeze({"Material.Standard":[.4,0,.2,1],"Material.Accelerate":[.4,0,1,1],"Material.Decelerate":[0,0,.2,1],"CSS.Ease":[.25,.1,.25,1]});const _bezierCache=new Map;function _cachedBezier(x1,y1,x2,y2){const key=x1+","+y1+","+x2+","+y2;let fn=_bezierCache.get(key);if(!fn){fn=buildCubicBezier(x1,y1,x2,y2);_bezierCache.set(key,fn)}return fn}function cubicBezier(a,b,c,d){if(typeof a==="string"){let preset=BEZIER_PRESETS[a];if(!preset){console.warn("[customEasings.cubicBezier] unknown preset, falling back to Material.Standard:",a);preset=BEZIER_PRESETS["Material.Standard"]}return _cachedBezier(preset[0],preset[1],preset[2],preset[3])}const clamp=(v,lo,hi)=>Math.max(lo,Math.min(hi,v));const x1=clamp(a,0,1);const y1=clamp(b,-.5,1.5);const x2=clamp(c,0,1);const y2=clamp(d,-.5,1.5);return _cachedBezier(x1,y1,x2,y2)}const libSpring=({stiffness=180,damping=12,mass=1}={})=>{const DT=1/240;const T=1.5;let x=0,v=0;const samples=[];for(let t=0;t<=T;t+=DT){const force=-stiffness*(x-1)-damping*v;v+=force/mass*DT;x+=v*DT;samples.push({t:t,x:x})}let T_end=T;for(let i=samples.length-1;i>=0;i--){if(Math.abs(samples[i].x-1)>.01){T_end=samples[i].t;break}}return k=>{if(k<=0)return 0;if(k>=1)return 1;const t=k*T_end;const idx=Math.min(samples.length-1,Math.floor(t/DT));return samples[idx].x}};const libHeartBeat=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c)=>Math.exp(-((t-c)**2)/(2*.07*.07));return peak*(bell(k,.2)+bell(k,.5))};const libSteps=(n=6)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return Math.floor(k*n)/n};const attentionPing=(peak=.35,decay=2)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(Math.PI*k)*Math.exp(-decay*k)};const attentionWiggle=(count=4,amplitude=.25)=>k=>{if(k<=0||k>=1)return 0;const env=1-k;return amplitude*env*Math.sin(k*Math.PI*2*count)};const attentionStrum=(notes=4,peak=.4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*.05*.05))}return peak*sum}};const Attention=Object.freeze({Ping:attentionPing(),Wiggle:attentionWiggle(),Strum:attentionStrum()});const breathNormal=(cycles=2,peak=.15)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(k*Math.PI*2*cycles)*Math.sin(k*Math.PI)};const breathDeep=(peak=.3,riseRatio=.35,holdRatio=.15)=>{const holdEnd=riseRatio+holdRatio;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const envelope=Math.sin(k*Math.PI);const wave=.5+.5*Math.sin(k*Math.PI*2*cycles-Math.PI/2);return peak*envelope*wave};const breathSigh=(peak=.25,riseRatio=.2)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return peak*Math.exp(-((k-center)**2)/(2*width*width))};const heartExcited=(beats=4,peak=.3,width=.04)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*width*width))}return peak*sum}};const heartLubDub=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return peak*(bell(k,.25,.045)+.6*bell(k,.42,.03))};const Heart=Object.freeze({Calm:heartCalm(),Excited:heartExcited(),LubDub:heartLubDub()});const mathJumpArc=()=>k=>{if(k<=0||k>=1)return 0;return 4*k*(1-k)};const mathPendulum=(damping=3,freq=2.5)=>k=>{if(k<=0||k>=1)return 0;return Math.sin(k*Math.PI)*Math.exp(-damping*k)*Math.cos(freq*Math.PI*k)};const mathTremor=(amplitude=.04,freq=22)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return k+amplitude*Math.sin(k*Math.PI*2*freq)};const mathBoomerang=fn=>k=>{if(k<=0||k>=1)return 0;return k<.5?fn(k*2):fn(2-k*2)};const MathExt=Object.freeze({JumpArc:mathJumpArc(),Pendulum:mathPendulum(),Tremor:mathTremor()});const explosionImpulse=(sharpness=6)=>{const tail=sharpness*Math.exp(1-sharpness);return k=>{if(k<=0||k>=1)return 0;const h=sharpness*k;return h*Math.exp(1-h)-tail*k}};const explosionFlash=(rise=.05,decay=5)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return-Math.exp(-decay*k)*Math.cos(freq*Math.PI*k)};const explosionImplosion=(charge=.3,depth=.4,burstPeak=1.2)=>{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const w=Math.sin(k*Math.PI*2*cycles)+.5*Math.sin(k*Math.PI*2*cycles*1.5+1.2)+.25*Math.sin(k*Math.PI*2*cycles*3+2.4);return amplitude*env*w*.6};const natureFlicker=(rate=15,intensity=.2,seed=7)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=rate+1;i++)samples.push(rand());return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*rate;const idx=Math.floor(pos);const t=pos-idx;const a=samples[idx];const b=samples[idx+1];const interp=a+(b-a)*t;return intensity*env*(interp-.5)*2}};const natureGust=(gusts=3,peak=.25)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*.08*.08))}return peak*sum/gusts*1.8}};const Nature=Object.freeze({Wave:natureWave(),Flicker:natureFlicker(),Gust:natureGust()});const impactRain=(impactAt=.7,rippleAmp=.08)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const liftEnd=.35,strikeEnd=.6;return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return t*t}const t=(k-.4)/.6;const env=Math.exp(-2.5*t);const wave=Math.abs(Math.sin(t*Math.PI*bounces));return 1-env*wave*rebound};const impactSlap=(contactAt=.3,holdRatio=.1)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return.4*Math.pow(t,2.5)}if(k<.48){const t=(k-.4)/.08;return.4-.2*t}if(k<.52){const t=(k-.48)/.04;return.2+.8*t}const t=(k-.52)/.48;return 1-.04*Math.sin(t*Math.PI*8)*(1-t)};const rhythmPunchCombo=(peak=.4)=>{const pattern=[{c:.15,w:.04,a:.75},{c:.35,w:.04,a:.75},{c:.7,w:.055,a:1}];return k=>{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of pattern){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return peak*sum}};const rhythmStaccato=(beats=4,duty=.3)=>k=>{if(k<=0||k>=1)return 0;const beatLen=1/beats;const phase=k/beatLen-Math.floor(k/beatLen);if(phase>duty)return 0;const t=phase/duty;return Math.sin(t*Math.PI)};const rhythmKick=(peak=1.2)=>k=>{if(k<=0||k>=1)return 0;if(k<.05)return peak*k/.05;const t=(k-.05)/.95;return peak*Math.exp(-4*t)};const rhythmCrescendo=(beats=4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return sum}};const rhythmDunDunDun=()=>{const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return k=>{if(k<=0||k>=1)return 0;return.3*bell(k,.15,.025)+.6*bell(k,.35,.03)+1*bell(k,.68,.09)}};const rhythmBellToll=(decay=3,freq=8)=>{const strike=.05;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.2){const t=k/.2;return-pressDepth*Math.sin(t*Math.PI/2)}if(k<.5){const t=(k-.2)/.3;return-pressDepth+(pressDepth+reboundPeak)*(1-Math.pow(1-t,3))}const t=(k-.5)/.5;return reboundPeak*Math.exp(-4*t)*Math.cos(t*Math.PI*3)};const uiHoverBloom=(riseRatio=.2,fallRatio=.3)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=1-k;const raw=Math.sin(k*Math.PI*2*count);const clipped=Math.sign(raw)*Math.min(1,Math.abs(raw)*1.8);return amplitude*env*clipped};const uiSuccessPop=(overshoot=.2)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return(1+overshoot)*(1-Math.pow(1-t,2))}const t=(k-.4)/.6;return 1+overshoot*Math.exp(-5*t)*Math.cos(t*Math.PI*3)};const uiRippleOut=()=>k=>{if(k<=0||k>=1)return 0;return 6.75*k*Math.pow(1-k,2)};const UI=Object.freeze({ClickSnap:uiClickSnap(),HoverBloom:uiHoverBloom(),ErrorShake:uiErrorShake(),SuccessPop:uiSuccessPop(),RippleOut:uiRippleOut()});const magicManaCharge=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;const base=(Math.exp(3*k)-1)/(Math.exp(3)-1);const pulse=.04*Math.sin(k*Math.PI*8)*k;return base+pulse};const magicSpellCast=(chargeEnd=.4)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.45){const t=k/.45;return t*t*t}if(k<.55)return 1;const t=(k-.55)/.45;return Math.pow(1-t,3)};const magicShield=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.3){const t=k/.3;return 1.2*(1-Math.pow(1-t,2))}if(k<.6){const t=(k-.3)/.3;return 1.2-.2*t}const t=(k-.6)/.4;return 1+.03*Math.sin(t*Math.PI*3)};const magicAura=(peak=.15)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const fundamental=.6*Math.sin(k*Math.PI*2);const harmonic=.3*Math.sin(k*Math.PI*4+1);const overtone=.1*Math.sin(k*Math.PI*6+2);return peak*env*(fundamental+harmonic+overtone)};const Magic=Object.freeze({ManaCharge:magicManaCharge(),SpellCast:magicSpellCast(),Teleport:magicTeleport(),Shield:magicShield(),MagicAura:magicAura()});const animalCatPounce=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.2){const t=k/.2;return-.2*Math.sin(t*Math.PI)}if(k<.3){const t=(k-.2)/.1;return.5*t*t}if(k<.8){const t=(k-.3)/.5;return.5+.5*t+.2*Math.sin(t*Math.PI)}const t=(k-.8)/.2;return 1+.05*Math.sin(t*Math.PI)};const animalBirdFlap=(flaps=4)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const phase=k*Math.PI*2*flaps;const wave=Math.sin(phase)-.3*Math.sin(phase*2);return.2*env*wave};const animalSnakeSlither=(waves=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const wave=Math.sin(k*Math.PI*2*waves);return.2*env*wave};const animalButterflyFlit=(seed=13)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=26;i++)samples.push(rand()-.5);return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*25;const idx=Math.floor(pos);const t=pos-idx;const smooth=t*t*(3-2*t);const interp=samples[idx]+(samples[idx+1]-samples[idx])*smooth;return.3*env*interp}};const animalHorseGallop=(cycles=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const cyclePos=k*cycles-Math.floor(k*cycles);const bell=(c,w=.04)=>Math.exp(-((cyclePos-c)**2)/(2*w*w));return.25*env*(bell(0)+bell(.18)+bell(.36)+bell(.54))};const Animal=Object.freeze({CatPounce:animalCatPounce(),BirdFlap:animalBirdFlap(),SnakeSlither:animalSnakeSlither(),ButterflyFlit:animalButterflyFlit(),HorseGallop:animalHorseGallop()});const Progress=Object.freeze({Physics:Object.freeze({...Physics,Spring:libSpring()}),Motion:Motion,Step:Object.freeze({...Step,Steps6:libSteps()}),Math:Object.freeze({Tremor:MathExt.Tremor}),Impact:Object.freeze({Rain:Impact.Rain,Hammer:Impact.Hammer,BounceDrop:Impact.BounceDrop,ArrowHit:Impact.ArrowHit,Shatter:Impact.Shatter}),Rhythm:Object.freeze({BassDrop:Rhythm.BassDrop}),UI:Object.freeze({SuccessPop:UI.SuccessPop}),Magic:Object.freeze({ManaCharge:Magic.ManaCharge,Shield:Magic.Shield}),Animal:Object.freeze({CatPounce:Animal.CatPounce})});const Pulse=Object.freeze({Attention:Object.freeze({Ping:Attention.Ping}),Breath:Object.freeze({Deep:Breath.Deep,Sigh:Breath.Sigh}),Heart:Object.freeze({Calm:Heart.Calm}),Math:Object.freeze({JumpArc:MathExt.JumpArc,BoomerangSharp:mathBoomerang(E.Cubic.In),BoomerangSoft:mathBoomerang(E.Cubic.Out)}),Explosion:Object.freeze({Impulse:Explosion.Impulse,Flash:Explosion.Flash,Recoil:Explosion.Recoil,Implosion:Explosion.Implosion}),Impact:Object.freeze({Slap:Impact.Slap}),Rhythm:Object.freeze({Kick:Rhythm.Kick}),UI:Object.freeze({ClickSnap:UI.ClickSnap,HoverBloom:UI.HoverBloom,RippleOut:UI.RippleOut}),Magic:Object.freeze({SpellCast:Magic.SpellCast,Teleport:Magic.Teleport})});const Wave=Object.freeze({Attention:Object.freeze({Wiggle:Attention.Wiggle,Strum:Attention.Strum}),Breath:Object.freeze({Normal:Breath.Normal,Panting:Breath.Panting}),Heart:Object.freeze({Excited:Heart.Excited,LubDub:Heart.LubDub,Beat:libHeartBeat()}),Math:Object.freeze({Pendulum:MathExt.Pendulum}),Nature:Nature,Rhythm:Object.freeze({PunchCombo:Rhythm.PunchCombo,Staccato:Rhythm.Staccato,Crescendo:Rhythm.Crescendo,DunDunDun:Rhythm.DunDunDun,BellToll:Rhythm.BellToll}),UI:Object.freeze({ErrorShake:UI.ErrorShake}),Magic:Object.freeze({MagicAura:Magic.MagicAura}),Animal:Object.freeze({BirdFlap:Animal.BirdFlap,SnakeSlither:Animal.SnakeSlither,ButterflyFlit:Animal.ButterflyFlit,HorseGallop:Animal.HorseGallop})});const customEasings=Object.freeze({makeOutIn:makeOutIn,OutIn:OutIn,Progress:Progress,Pulse:Pulse,Wave:Wave,cubicBezier:cubicBezier});exports.customEasings=customEasings;exports.default=customEasings; \ No newline at end of file diff --git a/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/scriptScene.js b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/scriptScene.js new file mode 100644 index 0000000000000000000000000000000000000000..5d5f0a8bde54f7efa0912b77bb0a8298e3fb04e9 --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/scriptScene.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/three-amg-wrapper.js b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/three-amg-wrapper.js new file mode 100644 index 0000000000000000000000000000000000000000..c2037e314e032c4d36912923d4cc1258cba3ab19 --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/three-amg-wrapper.js @@ -0,0 +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;iobj.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; \ No newline at end of file diff --git a/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/tween.js b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/tween.js new file mode 100644 index 0000000000000000000000000000000000000000..690fb9e4284728629129deed5a5a3f4bcec291ed --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/tween.js @@ -0,0 +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=power1e4?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;_i0){this._tweensAddedDuringUpdate={};for(var i=0;i1){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[m1;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;itotalTime){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;ithis.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;ithis.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.xthis.max.x||box.max.ythis.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; \ No newline at end of file diff --git a/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Box3.js b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Box3.js new file mode 100644 index 0000000000000000000000000000000000000000..4100dc7442d3a622827c8a415e24557f68c491f1 --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Box3.js @@ -0,0 +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=3?array[offset+2]:0;if(xthis.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=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.xthis.max.x||box.max.ythis.max.y||box.max.zthis.max.z)}}exports.Box3=Box3; \ No newline at end of file diff --git a/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..be3b8b1334a62f5e88c45feee098063a199fca55 --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js @@ -0,0 +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=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; \ No newline at end of file diff --git a/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..af9a8a13a46500e78f082a35e18d0b5932061234 --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js @@ -0,0 +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;iObject.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;i1?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; \ No newline at end of file diff --git a/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Constants.js b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Constants.js new file mode 100644 index 0000000000000000000000000000000000000000..6b8adda19a4d67236719804f5170889b39fd4582 --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Constants.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js new file mode 100644 index 0000000000000000000000000000000000000000..29b0aad5599401be17f967ba1d48851acb70c2ac --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js @@ -0,0 +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;i0||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;i0?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;imaxX)maxX=p.x;if(p.ymaxY)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; \ No newline at end of file diff --git a/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..f3dee08bf1c089e040fcfef228902ab9a39c93cb --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Earcut.js b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Earcut.js new file mode 100644 index 0000000000000000000000000000000000000000..953abffdf38c2def26df73fed180eff8c7644ced --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Earcut.js @@ -0,0 +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;imaxX)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=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=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.x&&p.x>=mx&&hx!==p.x&&pointInTriangle(hym.x||p.x===m.x&§orContainsSector(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.xb.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;i0||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=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;i0){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;imaxX)maxX=contour[i].x;if(contour[i].ymaxY)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;layerIdx0?-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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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; \ No newline at end of file diff --git a/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Group.js b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Group.js new file mode 100644 index 0000000000000000000000000000000000000000..90c4dbef65aa04d7a3bb6b6d76ec3317ea65a228 --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Group.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");class Group extends Object3D{constructor(name="Group_w"){super(name)}dispose(){super.dispose()}}exports.Group=Group; \ No newline at end of file diff --git a/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Material.js b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Material.js new file mode 100644 index 0000000000000000000000000000000000000000..81b97053ad9d1e4b1ef05d5ac6ed992487b2ca8e --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Material.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..dcf34d4cffb9de0869382a24690f78f60dda6049 --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js new file mode 100644 index 0000000000000000000000000000000000000000..41e6cd0a0eee7dd7bc497be5deac584806b68dc3 --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Mesh.js b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Mesh.js new file mode 100644 index 0000000000000000000000000000000000000000..254d69b074e797dd34c16d7dad723bbcc3b4895d --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Mesh.js @@ -0,0 +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;imaterial,set:value=>{material=value;if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;im.dispose&&m.dispose());else if(this.material.dispose)this.material.dispose()}}}exports.MeshWrapper=MeshWrapper; \ No newline at end of file diff --git a/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..ac394f66efc4e113a7127ee0f50ec672e4c5e9eb --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Object3D.js b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Object3D.js new file mode 100644 index 0000000000000000000000000000000000000000..8532c6122f839460aab34fe88957802ff523318b --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Object3D.js @@ -0,0 +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{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&¤tScene._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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js new file mode 100644 index 0000000000000000000000000000000000000000..ba39801de50d38ec04424f3c2ebfa2ff5d28fded --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js @@ -0,0 +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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..bc595fb80ad9e7c2f4d8360c67dbef556f3d6cbe --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js @@ -0,0 +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;iy0){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; \ No newline at end of file diff --git a/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..02dc1be955bc766de744222a7e75c65bf147bb61 --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js @@ -0,0 +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&¶meters.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{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=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=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=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; \ No newline at end of file diff --git a/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Shape.js b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Shape.js new file mode 100644 index 0000000000000000000000000000000000000000..ecde48b5ceb30812c922aa5c7cfe2aa7b50cabe4 --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Shape.js @@ -0,0 +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;i0){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;i0||(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;imaxX)maxX=p.x;if(p.ymaxY)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;i0?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;ipoints.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;itwoPi)deltaAngle-=twoPi;if(deltaAngle>4;uuid[i]=chars[i===19?r&3|8:r]}}return uuid.join("")}exports.Shape=Shape; \ No newline at end of file diff --git a/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..3786abc7d64ed80b56101c4ac9d30ce9fcb8f941 --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js @@ -0,0 +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;i0){const bounds=calculateBounds(flatVertices);const vertexOffset=vertices.length/3;for(let j=0;j0){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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}function calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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; \ No newline at end of file diff --git a/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..1ea27a55fbce9fc3771c66840c068e5ff6347092 --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Texture.js b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Texture.js new file mode 100644 index 0000000000000000000000000000000000000000..35bff49d732c9884e07bfcb5682f18a860485e1f --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Texture.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Vector2.js b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Vector2.js new file mode 100644 index 0000000000000000000000000000000000000000..a30a2431264ee62cec937714dfa9e50932ddedeb --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/js/ThreeJS/wrapper/Vector2.js @@ -0,0 +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)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)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)= 1.0) return texel2; + + float p = smoothstep(0.0, 1.0, progress); + float morphPhase = smoothstep(0.04, 0.74, p); + float burstPhase = smoothstep(0.72, 0.98, p); + + vec2 uv = vUv; + vec2 centered = uv - 0.5; + centered.x *= ratio; + vec2 uvAspect = centered + 0.5; + + vec2 grid = vec2(panelDensity * ratio, panelDensity); + vec2 cell = uvAspect * grid; + vec2 id = floor(cell); + vec2 local = fract(cell) - 0.5; + + float h = hash21(id); + float baseAngle = h * 6.28318530718; + float morphAngle = baseAngle + sin(h * 11.0 + p * 9.0) * 1.6 * morphPhase; + vec2 lf = rot2(morphAngle) * local; + + float foldMetric = abs(lf.x) + abs(lf.y); + float ridge = 1.0 - smoothstep(0.08, 0.5, foldMetric); + float facetEdge = 1.0 - smoothstep(0.33, 0.52, foldMetric); + + vec2 dir = normalize(vec2(cos(baseAngle), sin(baseAngle))); + float mechanicalPulse = sin((h * 17.0 + p * 14.0) * 1.7) * 0.5 + 0.5; + vec2 offset = + dir * (0.028 * morphPhase * mechanicalPulse) + + dir * (0.22 * burstPhase * (0.25 + 0.75 * h)); + + vec2 refrDir = normalize(lf + vec2(0.001, -0.001)); + vec2 refr = refrDir * refractAmount * (0.35 + 0.65 * morphPhase) * (1.0 - 0.55 * burstPhase); + + vec2 uvA = clamp(uv + offset + refr, 0.0, 1.0); + vec2 uvB = clamp(uv + offset * 0.2 - refr * 1.25 + (h - 0.5) * 0.014 * burstPhase, 0.0, 1.0); + + vec4 srcA = texture2D(tDiffuse, uvA); + vec4 srcB = texture2D(tDiffuse1, uvB); + + vec3 normal = normalize(vec3(lf * 2.0, 0.75 + 0.25 * h)); + vec3 lightDir = normalize(vec3(-0.35, 0.55, 0.76)); + float spec = pow(max(dot(normal, lightDir), 0.0), 28.0) * (0.35 + 0.65 * facetEdge); + + vec3 prismTint = mix(vec3(0.72, 0.86, 1.0), vec3(1.0, 0.88, 0.78), h); + vec3 highlight = prismTint * spec * sparkle * (0.35 + 0.65 * morphPhase) * (0.7 + 0.3 * ridge); + + float revealInsideCrystal = smoothstep(0.70, 1.0, p); + vec4 crystalColor = mix(srcA, srcB, revealInsideCrystal * 0.7); + crystalColor.rgb = clamp(crystalColor.rgb + highlight, 0.0, 1.0); + + vec4 folded = mix(texel1, crystalColor, morphPhase); + vec4 unfolded = mix(folded, texel2, burstPhase); + + unfolded.rgb = clamp(unfolded.rgb, 0.0, 1.0); + return unfolded; +} + +void main() { + // Get the pixel color from both textures + vec4 texel1 = texture2D(tDiffuse, vUv); + vec4 texel2 = texture2D(tDiffuse1, vUv); + + // --- Transition Configuration --- + const float fadeInEnd = 0.1; + const float fadeOutStart = 0.9; + + // 1. Calculate the transition's own progress. + float transitionProgress = clamp((progress - fadeInEnd) / (fadeOutStart - fadeInEnd), 0.0, 1.0); + vec4 transitionColor = transition(texel1, texel2, transitionProgress); + + // 2. Calculate smooth blending factors for the start and end zones. + float blendInFactor = smoothstep(0.0, fadeInEnd, progress); + float blendOutFactor = smoothstep(fadeOutStart, 1.0, progress); + + // 3. Apply the blending. + vec4 finalColor = mix(texel1, transitionColor, blendInFactor); + finalColor = mix(finalColor, texel2, blendOutFactor); + + gl_FragColor = finalColor; +} +//===end_frag_code=== +`; \ No newline at end of file diff --git a/scripts/7681564284442250514/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js b/scripts/7681564284442250514/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js new file mode 100644 index 0000000000000000000000000000000000000000..2c87ab8ca97aecc86f650141dcf51ecc1ee7f46e --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js @@ -0,0 +1,8 @@ +exports.source=` +varying vec2 vUv; + +void main() { + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); +} +`; \ No newline at end of file diff --git a/scripts/7681564284442250514/AmazingFeature/xshader/Unlit.frag b/scripts/7681564284442250514/AmazingFeature/xshader/Unlit.frag new file mode 100644 index 0000000000000000000000000000000000000000..2b8ef6c235afd5362d14d87961e5b7fa2fe044b1 --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/xshader/Unlit.frag @@ -0,0 +1,25 @@ +precision highp float; +uniform sampler2D u_AlbedoTexture; +uniform vec4 u_AlbedoColor; +uniform vec2 u_Repeat; +uniform vec2 u_Offset; +uniform float u_Translucency; +uniform float u_Opacity; +varying vec2 g_vary_uv0; +void main () +{ + vec2 uv_1; + uv_1.x = g_vary_uv0.x; + uv_1.y = (g_vary_uv0.y); + lowp vec4 tmpvar_2; + tmpvar_2 = texture2D (u_AlbedoTexture, (uv_1 * u_Repeat + u_Offset)); + lowp vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2.xyz * u_AlbedoColor.xyz); + lowp float tmpvar_4; + tmpvar_4 = (tmpvar_2.w * u_Translucency); + mediump vec4 tmpvar_5; + tmpvar_5.xyz = tmpvar_3; + tmpvar_5.w = tmpvar_4; + gl_FragColor = vec4(tmpvar_5.xyz * u_Opacity, tmpvar_5.w * u_Opacity); +} + diff --git a/scripts/7681564284442250514/AmazingFeature/xshader/Unlit.vert b/scripts/7681564284442250514/AmazingFeature/xshader/Unlit.vert new file mode 100644 index 0000000000000000000000000000000000000000..64a27d816e6146a0fb85643a9991207e5fda2acb --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/xshader/Unlit.vert @@ -0,0 +1,35 @@ +precision highp float; +attribute vec3 attPosition; +attribute vec2 attTexcoord0; + +//#define AMAZING_USE_BONES + +#ifdef AMAZING_USE_BONES +attribute vec4 attBoneIds; +attribute vec4 attWeights; +const int MAX_BONES = 50; +uniform mat4 u_Palatte[MAX_BONES]; +#endif + +uniform mat4 u_Model; +uniform mat4 u_MVP; +varying vec2 g_vary_uv0; + + + +void main () +{ + vec3 modelPostiton = attPosition; + vec4 homogeneous_pos = vec4(attPosition, 1.0); + g_vary_uv0 = attTexcoord0; + +#ifdef AMAZING_USE_BONES + mat4 boneTransform = u_Palatte[int(attBoneIds.x)] * attWeights.x; + boneTransform += u_Palatte[int(attBoneIds.y)] * attWeights.y; + boneTransform += u_Palatte[int(attBoneIds.z)] * attWeights.z; + boneTransform += u_Palatte[int(attBoneIds.w)] * attWeights.w; + gl_Position = u_MVP * boneTransform * homogeneous_pos; +#else + gl_Position = u_MVP * homogeneous_pos; +#endif +} diff --git a/scripts/7681564284442250514/AmazingFeature/xshader/noface.frag b/scripts/7681564284442250514/AmazingFeature/xshader/noface.frag new file mode 100644 index 0000000000000000000000000000000000000000..88e9ec343761b2395bae9430e6e55466b0367d67 --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/xshader/noface.frag @@ -0,0 +1,7 @@ +precision lowp float; +varying highp vec2 uv0; +uniform sampler2D u_albedo; +void main() +{ + gl_FragColor = texture2D(u_albedo, uv0); +} diff --git a/scripts/7681564284442250514/AmazingFeature/xshader/noface.vert b/scripts/7681564284442250514/AmazingFeature/xshader/noface.vert new file mode 100644 index 0000000000000000000000000000000000000000..16450a4b5880cf8d83528ea1ae0f47d10b2ab1d8 --- /dev/null +++ b/scripts/7681564284442250514/AmazingFeature/xshader/noface.vert @@ -0,0 +1,12 @@ +precision highp float; + +attribute vec2 position; +attribute vec2 texcoord0; +varying vec2 uv0; +//uniform mat4 u_MVP; +void main() +{ + //gl_Position = u_MVP * position; + gl_Position = sign(vec4(position.xy, 0.0, 1.0)); + uv0 = texcoord0; +} diff --git a/scripts/7681564284442250514/config.json b/scripts/7681564284442250514/config.json new file mode 100644 index 0000000000000000000000000000000000000000..557ff9895b4c8c8a7d91baae310b40001cd6c20d --- /dev/null +++ b/scripts/7681564284442250514/config.json @@ -0,0 +1,16 @@ +{ + "ae_tool": "AmazingEditor", + "bALG_BACH_CONFIG": false, + "effect": { + "Link": [ + { + "path": "AmazingFeature/", + "type": "AmazingFeature", + "zorder": 8011 + } + ] + }, + "name": "AlgorithmGraph_7bdbHcdcscQkbEdcc9cIlcNdvTdtb", + "version": "13.4.0", + "item_source": "user_post_pc_lumi_ai" +} \ No newline at end of file diff --git a/scripts/7681564284442250514/extra.json b/scripts/7681564284442250514/extra.json new file mode 100644 index 0000000000000000000000000000000000000000..a532333af7c54e06a325afda1afc8f4f6f00def5 --- /dev/null +++ b/scripts/7681564284442250514/extra.json @@ -0,0 +1,43 @@ +{ + "transition": { + "defaultDura": 2.0, + "isOverlap": true + }, + "External_Producer": true, + "setting": { + "lumiai_material_properties": [ + { + "effect_key": "progress", + "effect_key_cn": "progress", + "type": "float", + "default": 0, + "min": 0, + "max": 1 + }, + { + "effect_key": "panelDensity", + "effect_key_cn": "panelDensity", + "type": "float", + "default": 36, + "min": 6, + "max": 80 + }, + { + "effect_key": "refractAmount", + "effect_key_cn": "refractAmount", + "type": "float", + "default": 0.028, + "min": 0, + "max": 0.08 + }, + { + "effect_key": "sparkle", + "effect_key_cn": "sparkle", + "type": "float", + "default": 0.65, + "min": 0, + "max": 1 + } + ] + } +} \ No newline at end of file diff --git a/scripts/7681574644264045845/AmazingFeature/content.json b/scripts/7681574644264045845/AmazingFeature/content.json new file mode 100644 index 0000000000000000000000000000000000000000..91fbb9be9167ba1f5315de330b0f1903d08afc0b --- /dev/null +++ b/scripts/7681574644264045845/AmazingFeature/content.json @@ -0,0 +1,7 @@ +{ + "ae_tool" : "AmazingEditor", + "content" : {}, + "needblend" : false, + "tag" : "AMG_96763024926065909023875386850577846442", + "version" : "1.0" +} \ No newline at end of file diff --git a/scripts/7681574644264045845/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua b/scripts/7681574644264045845/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua new file mode 100644 index 0000000000000000000000000000000000000000..a498e06b924f116108617c6860cb4ca1fd5e9b15 --- /dev/null +++ b/scripts/7681574644264045845/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua @@ -0,0 +1,327 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiAnimSeqLoadAndCrop = LumiAnimSeqLoadAndCrop or {} +LumiAnimSeqLoadAndCrop.__index = LumiAnimSeqLoadAndCrop +---@class LumiAnimSeqLoadAndCrop : ScriptComponent +---@field animSeqType string [UI(Option={"Video", "Image", "Texture"})] +---@field cropType string [UI(Option={"Stretch", "Fill", "Fit", "Texture Size"})] +---@field edgeType string [UI(Option={"Tile", "Mirror", "Clamp", "Empty"})] +---@field pivot Vector2f +---@field position Vector2f +---@field rotation double [UI(Range={0, 360}, Drag)] +---@field scale double [UI(Range={0, 5}, Drag)] +---@field opacity double [UI(Range={0, 1}, Drag)] +---@field playMode string [UI(Option={"once", "loop"})] +---@field speed double [UI(Range={0.001, 10}, Drag)] +---@field seqTime number [UI(Range={0, 100}, Drag)] +---@field enableVideoAlphaBlend boolean +---@field videoFilename String +---@field animSeq AnimSeq +---@field seqTex Texture +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local animSeqTypeName = { + "Video", "Image", "Texture", +} +setmetatable(animSeqTypeName, {__index = function(_, _) return animSeqTypeName[1] end}) +local animSeqTypeIndex = {} +for index, value in ipairs(animSeqTypeName) do animSeqTypeIndex[value] = index - 1 end +setmetatable(animSeqTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, 'Unsupported AnimSeqType: ' .. key) + return 0 + end +}) + +local cropTypeName = { + "Stretch", "Fill", "Fit", "Texture Size" +} +setmetatable(cropTypeName, {__index = function(_, _) return cropTypeName[1] end}) +local cropTypeIndex = {} +for index, value in ipairs(cropTypeName) do cropTypeIndex[value] = index - 1 end +setmetatable(cropTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported SeqCrop Type: " .. key) + return 0 + end +}) + +local edgeTypeName = { + "Tile", "Mirror", "Clamp", "Empty", +} +setmetatable(edgeTypeName, {__index = function(_, _) return edgeTypeName[1] end}) +local edgeTypeIndex = {} +for index, value in ipairs(edgeTypeName) do edgeTypeIndex[value] = index - 1 end +setmetatable(edgeTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported Edge Type: " .. key) + return 0 + end +}) + +local playModeName = { + "once", "loop" +} +setmetatable(playModeName, {__index = function(_, _) return playModeName[1] end}) +local playModeIndex = {} +for index, value in ipairs(playModeName) do playModeIndex[value] = index - 1 end +setmetatable(playModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported Play Mode: " .. key) + return 0 + end +}) + +function LumiAnimSeqLoadAndCrop.new(construct, ...) + local self = setmetatable({}, LumiAnimSeqLoadAndCrop) + + self.AEPlugin = false + self.seqTime = 0.0 + self.globalRotation = 0.0 + self.globalScale = 1.0 + self.globalOpacity = 1.0 + self.globalSpeed = 1.0 + + self.paramInitInfo = { + {'specify', false}, + {'animSeqType', 'Texture'}, + {'cropType', 'Stretch'}, + {'edgeType', 'Empty'}, + {'pivot', Amaz.Vector2f(0.5, 0.5)}, + {'position', Amaz.Vector2f(0.5, 0.5)}, + {'rotation', 0}, + {'scale', 1.0}, + {'opacity', 1.0}, + {'playMode', 'loop'}, + {'speed', 1.0}, + -- Video seq + {'videoFilename', ''}, + {'enableVideoAlphaBlend', false}, + -- Image seq + {'animSeq', nil}, + -- Texture + {'seqTex', nil}, + } + + self.multiAspect = { + ['5.8'] = 1.125 / 2.436, -- 0.4618 + ['9_16'] = 9 / 16, -- 0.5625 + ['3_4'] = 3 / 4, -- 0.75 + ['1_1'] = 1, + ['4_3'] = 4 / 3, -- 1.3333 + ['16_9'] = 16 / 9, -- 1.7778 + ['1.85_1'] = 1.85, + ['2_1'] = 2, + ['2.35_1'] = 2.35, + } + + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self.paramInitInfo[i][2] + end + + for key, _ in pairs(self.multiAspect) do + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1] .. '_' .. key] = self.paramInitInfo[i][2] + end + end + + self.needUpdateSize = true + self.InputTex = nil + self.OutputTex = nil + + return self +end + +function LumiAnimSeqLoadAndCrop:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.camera = self.entity:searchEntity("AnimSeqCamera"):getComponent("Camera") + self.material = self.entity:searchEntity('AnimSeqPass'):getComponent('MeshRenderer').material + self.videoAnim = self.entity:searchEntity("AnimSeqPass"):getComponent("VideoAnimSeq") + self.seqAnim = self.entity:searchEntity("AnimSeqPass"):getComponent("AnimSeqComponent") +end + +function LumiAnimSeqLoadAndCrop:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value, _force) + if _force or self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if self[key] ~= nil then + if key:sub(1, #'cropType') == 'cropType' then + local type = cropTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'edgeType') == 'edgeType' then + local type = edgeTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'animSeqType') == 'animSeqType' then + local type = animSeqTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'playMode') == 'playMode' then + local type = playModeName[value + 1] + _setEffectAttr(key, type) + else + _setEffectAttr(key, value) + end + elseif key:sub(1, #'seqTex') == 'seqTex' + or key:sub(1, #'animSeq') == 'animSeq' + then + _setEffectAttr(key, value, true) + else + _setEffectAttr(key, value) + end +end + +function LumiAnimSeqLoadAndCrop:afterAnimSeqSystemUpdate(comp) + if self.animSeqType == "Image" then + if self.needUpdateSize and self.material then + local seqTex = self.material:getTex("u_seqTexture") + self.material:setVec2("u_seqTexSize", Amaz.Vector2f(seqTex.width, seqTex.height)) + seqTex = nil + self.needUpdateSize = false + end + end +end + +function LumiAnimSeqLoadAndCrop:onUpdate(comp, deltaTime) + if self.OutputTex then + self.camera.renderTexture = self.OutputTex + end + + local w = self.camera.renderTexture.width + local h = self.camera.renderTexture.height + + local ratio = w / h + local paramFlag = '' + local _diff = math.huge + for key, value in pairs(self.multiAspect) do + if self['specify_' .. key] then + local diff = math.abs(ratio - value) + if diff < _diff then + _diff = diff + paramFlag = key + end + end + end + + -- update parameters based on resolution + if paramFlag == '' then + if self.AEPlugin then + Amaz.LOGE(self.TAG, 'No aspect specified' .. ', ratio: ' .. ratio .. ', reset params!') + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self.paramInitInfo[i][2] + end + else + Amaz.LOGE(self.TAG, 'No aspect specified' .. ', ratio: ' .. ratio) + end + else + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self[self.paramInitInfo[i][1] .. '_' .. paramFlag] + end + end + + if self.AEPlugin then + self.animSeqType = 'Texture' + end + + self.material:setTex("u_inputTexture", self.InputTex) + self.material:setInt('u_cropType', cropTypeIndex[self.cropType]) + self.material:setInt('u_edgeType', edgeTypeIndex[self.edgeType]) + self.material:setFloat('u_opacity', self.opacity * self.globalOpacity) + self.material:setVec2('u_scale', Amaz.Vector2f(self.scale, self.scale) * self.globalScale) + self.material:setVec2('u_pivot', self.pivot - Amaz.Vector2f(0.5, 0.5)) + self.material:setVec2('u_position', self.position - Amaz.Vector2f(0.5, 0.5)) + self.material:setFloat('u_rotation', math.rad(self.rotation + self.globalRotation)) + + local playMode = Amaz.PlayMode.loop + if self.playMode == 'once' then + playMode = Amaz.PlayMode.once + end + + local speed = self.speed * self.globalSpeed + + if self.animSeqType == "Video" then + self.videoAnim.enabled = true + self.seqAnim.enabled = false + + if not isEditor then + self.videoAnim.enableFixedSeekMode = true + end + if self.videoAnim.videoFilename ~= self.videoFilename then + self.videoAnim.videoFilename = self.videoFilename + end + if self.videoAnim.enableAlphaBlend ~= self.enableVideoAlphaBlend then + self.videoAnim.enableAlphaBlend = self.enableVideoAlphaBlend + end + if self.videoAnim.playmode ~= playMode then + self.videoAnim.playmode = playMode + end + if self.videoAnim.speed ~= speed then + self.videoAnim.speed = speed + end + local frames = self.videoAnim:getFrameCount() + local duration = self.videoAnim:getDuration() + local videoFps = frames / duration * 1000 + self.videoAnim:seekToTime(self.seqTime + 0.5 / videoFps) + local videoSize = self.videoAnim:getVideoSize() + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", 0) + -- self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + self.material:setInt('u_yFlip', 1) + elseif self.animSeqType == "Image" then + self.videoAnim.enabled = false + self.seqAnim.enabled = true + + if self.seqAnim.animSeq ~= self.animSeq then + self.seqAnim.animSeq = self.animSeq + self.needUpdateSize = true + end + if self.seqAnim.playmode ~= playMode then + self.seqAnim.playmode = playMode + end + if self.seqAnim.speed ~= speed then + self.seqAnim.speed = speed + end + self.seqAnim:seekToTime(self.seqTime + 0.5 / self.animSeq.fps) + self.material:setInt("u_convertAlpha", 0) + self.material:setInt('u_yFlip', 1) + elseif self.animSeqType == "Texture" then + self.videoAnim.enabled = false + self.seqAnim.enabled = false + + if self.seqTex then + self.material:setTex("u_seqTexture", self.seqTex) + local videoSize = Amaz.Vector2f(self.seqTex.width, self.seqTex.height) + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + else + self.material:setTex("u_seqTexture", self.InputTex) + local inputWidth = Amaz.BuiltinObject.getInputTextureWidth() + local inputHeight = Amaz.BuiltinObject.getInputTextureHeight() + local videoSize = Amaz.Vector2f(inputWidth, inputHeight) + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + end + self.material:setInt('u_yFlip', 0) + end +end + +exports.LumiAnimSeqLoadAndCrop = LumiAnimSeqLoadAndCrop +return exports diff --git a/scripts/7681574644264045845/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag b/scripts/7681574644264045845/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag new file mode 100644 index 0000000000000000000000000000000000000000..776d48b9649c5f359d8b806bfa1895121567e7d5 --- /dev/null +++ b/scripts/7681574644264045845/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag @@ -0,0 +1,162 @@ +precision highp float; +precision highp int; + +uniform mediump int u_yFlip; +uniform mediump int u_convertAlpha; +uniform mediump sampler2D u_seqTexture; +uniform vec4 u_ScreenParams; +uniform vec2 u_scale; +uniform float u_rotation; +uniform vec2 u_position; +uniform vec2 u_pivot; +uniform vec2 u_seqTexSize; +uniform mediump int u_cropType; +uniform mediump int u_edgeType; +uniform float u_opacity; + +varying vec2 uv0; + +vec2 _f4(inout vec2 _p0, float _p1, vec2 _p2, vec2 _p3, vec2 _p4) +{ + _p0 -= _p2; + _p0 -= vec2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _169 = sin(_p1); + float _172 = cos(_p1); + _p0 = mat2(vec2(_172, _169), vec2(-_169, _172)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 /= _p4; + _p0 += vec2(0.5); + _p0 += _p3; + return _p0; +} + +vec2 _f2(vec2 _p0) +{ + vec2 _122 = mod(_p0, vec2(1.0)); + return _122 + (vec2(1.0) - step(vec2(0.0), _122)); +} + +vec2 _f1(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +vec4 _f0(inout vec2 _p0) +{ + if (u_yFlip == 1) + { + _p0 = vec2(_p0.x, 1.0 - _p0.y); + } + if (u_convertAlpha == 0) + { + return texture2D(u_seqTexture, _p0); + } + vec4 _t2; + _t2.w = texture2D(u_seqTexture, vec2(_p0.x * 0.5, _p0.y)).x; + mediump vec3 _97 = texture2D(u_seqTexture, vec2((_p0.x * 0.5) + 0.5, _p0.y)).xyz; + _t2.x = _97.x; + _t2.y = _97.y; + _t2.z = _97.z; + return _t2; +} + +float _f3(vec2 _p0) +{ + vec2 _t4 = step(vec2(0.0), _p0) * step(_p0, vec2(1.0)); + return _t4.x * _t4.y; +} + +void main() +{ + bool _214 = abs(u_scale.x) < 9.9999997473787516355514526367188e-05; + bool _222; + if (!_214) + { + _222 = abs(u_scale.y) < 9.9999997473787516355514526367188e-05; + } + else + { + _222 = _214; + } + if (_222) + { + gl_FragData[0] = vec4(0.0); + return; + } + vec2 param = uv0; + float param_1 = u_rotation; + vec2 param_2 = u_position; + vec2 param_3 = u_pivot; + vec2 param_4 = u_scale; + vec2 _245 = _f4(param, param_1, param_2, param_3, param_4); + vec2 _t8 = _245; + float _252 = u_seqTexSize.x / u_seqTexSize.y; + float _258 = u_ScreenParams.x / u_ScreenParams.y; + vec2 _t11 = _245; + if (u_cropType == 1) + { + if (_252 > _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (u_cropType == 2) + { + if (_252 < _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (u_cropType == 3) + { + _t11 -= vec2(0.5); + _t11.x *= (u_ScreenParams.x / u_seqTexSize.x); + _t11.y *= (u_ScreenParams.y / u_seqTexSize.y); + _t11 += vec2(0.5); + } + } + } + if (u_edgeType == 0) + { + vec2 param_5 = _t11; + _t11 = _f2(param_5); + } + else + { + if (u_edgeType == 1) + { + vec2 param_6 = _t11; + _t11 = _f1(param_6); + } + } + vec2 param_7 = _t11; + vec4 _389 = _f0(param_7); + vec4 _t16 = _389; + if (u_edgeType == 3) + { + vec2 param_8 = _t11; + _t16 *= _f3(param_8); + } + vec4 _401 = _t16; + vec4 _402 = _401 * u_opacity; + _t16 = _402; + gl_FragData[0] = _402; +} + diff --git a/scripts/7681574644264045845/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert b/scripts/7681574644264045845/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681574644264045845/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681574644264045845/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag b/scripts/7681574644264045845/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag new file mode 100644 index 0000000000000000000000000000000000000000..d21575c9d17e191328bff9c1ab15dd22db3dc969 --- /dev/null +++ b/scripts/7681574644264045845/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag @@ -0,0 +1,190 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + int u_yFlip; + int u_convertAlpha; + float4 u_ScreenParams; + float2 u_scale; + float u_rotation; + float2 u_position; + float2 u_pivot; + float2 u_seqTexSize; + int u_cropType; + int u_edgeType; + float u_opacity; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f4(thread float2& _p0, thread const float& _p1, thread const float2& _p2, thread const float2& _p3, thread const float2& _p4, constant float4& u_ScreenParams) +{ + _p0 -= _p2; + _p0 -= float2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _169 = sin(_p1); + float _172 = cos(_p1); + _p0 = float2x2(float2(_172, _169), float2(-_169, _172)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 /= _p4; + _p0 += float2(0.5); + _p0 += _p3; + return _p0; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float2& _p0) +{ + float2 _122 = mod(_p0, float2(1.0)); + return _122 + (float2(1.0) - step(float2(0.0), _122)); +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float4 _f0(thread float2& _p0, constant int& u_yFlip, constant int& u_convertAlpha, texture2d u_seqTexture, sampler u_seqTextureSmplr) +{ + if (u_yFlip == 1) + { + _p0 = float2(_p0.x, 1.0 - _p0.y); + } + if (u_convertAlpha == 0) + { + return u_seqTexture.sample(u_seqTextureSmplr, _p0); + } + float4 _t2; + _t2.w = u_seqTexture.sample(u_seqTextureSmplr, float2(_p0.x * 0.5, _p0.y)).x; + float3 _97 = u_seqTexture.sample(u_seqTextureSmplr, float2((_p0.x * 0.5) + 0.5, _p0.y)).xyz; + _t2.x = _97.x; + _t2.y = _97.y; + _t2.z = _97.z; + return _t2; +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0) +{ + float2 _t4 = step(float2(0.0), _p0) * step(_p0, float2(1.0)); + return _t4.x * _t4.y; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_seqTexture [[texture(0)]], sampler u_seqTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + bool _214 = abs(buffer.u_scale.x) < 9.9999997473787516355514526367188e-05; + bool _222; + if (!_214) + { + _222 = abs(buffer.u_scale.y) < 9.9999997473787516355514526367188e-05; + } + else + { + _222 = _214; + } + if (_222) + { + out.o_fragColor = float4(0.0); + return out; + } + float2 param = in.uv0; + float param_1 = buffer.u_rotation; + float2 param_2 = buffer.u_position; + float2 param_3 = buffer.u_pivot; + float2 param_4 = buffer.u_scale; + float2 _245 = _f4(param, param_1, param_2, param_3, param_4, buffer.u_ScreenParams); + float2 _t8 = _245; + float _252 = buffer.u_seqTexSize.x / buffer.u_seqTexSize.y; + float _258 = buffer.u_ScreenParams.x / buffer.u_ScreenParams.y; + float2 _t11 = _245; + if (buffer.u_cropType == 1) + { + if (_252 > _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (buffer.u_cropType == 2) + { + if (_252 < _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (buffer.u_cropType == 3) + { + _t11 -= float2(0.5); + _t11.x *= (buffer.u_ScreenParams.x / buffer.u_seqTexSize.x); + _t11.y *= (buffer.u_ScreenParams.y / buffer.u_seqTexSize.y); + _t11 += float2(0.5); + } + } + } + if (buffer.u_edgeType == 0) + { + float2 param_5 = _t11; + _t11 = _f2(param_5); + } + else + { + if (buffer.u_edgeType == 1) + { + float2 param_6 = _t11; + _t11 = _f1(param_6); + } + } + float2 param_7 = _t11; + float4 _389 = _f0(param_7, buffer.u_yFlip, buffer.u_convertAlpha, u_seqTexture, u_seqTextureSmplr); + float4 _t16 = _389; + if (buffer.u_edgeType == 3) + { + float2 param_8 = _t11; + _t16 *= _f3(param_8); + } + float4 _401 = _t16; + float4 _402 = _401 * buffer.u_opacity; + _t16 = _402; + out.o_fragColor = _402; + return out; +} + diff --git a/scripts/7681574644264045845/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert b/scripts/7681574644264045845/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681574644264045845/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681574644264045845/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua b/scripts/7681574644264045845/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua new file mode 100644 index 0000000000000000000000000000000000000000..438a547f7d5c96047e2f183309e2a7d7200347e7 --- /dev/null +++ b/scripts/7681574644264045845/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua @@ -0,0 +1,416 @@ +local exports = exports or {} +local LumiLayer = LumiLayer or {} +LumiLayer.__index = LumiLayer +---@class LumiLayer : ScriptComponent +---@field hasTransform boolean +---@field active_cam_fovx number +---@field compositeSize Vector2f +---@field layerSize Vector2f +---@field anchorPoint Vector3f +---@field orientation Vector3f +---@field position Vector3f +---@field scale Vector3f +---@field xRotation number [UI(Range={-360, 360}, Drag)] +---@field yRotation number [UI(Range={-360, 360}, Drag)] +---@field rotation number [UI(Range={-360, 360}, Drag)] +---@field opacity number [UI(Range={0, 100}, Drag)] +---@field mirrorEdge boolean +---@field hasMatte boolean +---@field matteMode string [UI(Option={"Alpha Matte", "Luma Matte", "Alpha Inverted Matte", "Luma Inverted Matte"})] +---@field maskTex Texture +---@field hasBlend boolean +---@field blendMode string [UI(Option={"Normal", "Add", "Multiply", "Difference", "Overlay", "Darken", "Lighten", "Soft Light", "Hard Light", "Hue", "Saturation", "Color", "Screen", "Color Burn", "Linear Burn", "Color Dodge", "Linear Dodge", "Vivid Light", "Linear Light", "Pin Light", "Hard Mix", "Exclusion", "Subtract", "Divide", "Luminosity", "Lighter Color", "Darker Color", "Dissolve"})] +---@field layerType string [UI(Option={"Adjustment", "Precomp", "Solid", "Image", "Video", "Sequence"})] +---@field baseTex Texture +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local MatteMode = { + "Alpha Matte", "Luma Matte", "Alpha Inverted Matte", "Luma Inverted Matte", +} +setmetatable(MatteMode, {__index = function(_, _) return MatteMode[1] end}) + +local MatteModeIndex = {} +for index, value in ipairs(MatteMode) do MatteModeIndex[value] = index - 1 end +setmetatable(MatteModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported matte mode: " .. key) + return 0 + end +}) + +local BlendMode = { + "Normal", "Add", "Multiply", "Difference", "Overlay", "Darken", "Lighten", "Soft Light", "Hard Light", "Hue", "Saturation", "Color", "Screen", "Color Burn", "Linear Burn", "Color Dodge", "Linear Dodge", "Vivid Light", "Linear Light", "Pin Light", "Hard Mix", "Exclusion", "Subtract", "Divide", "Luminosity", "Lighter Color", "Darker Color", "Dissolve", +} +setmetatable(BlendMode, {__index = function(_, _) return BlendMode[1] end}) + +local BlendModeIndex = {} +for index, value in ipairs(BlendMode) do BlendModeIndex[value] = index - 1 end +setmetatable(BlendModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported blend mode: " .. key) + return 0 + end +}) + +local LayerType = { + "Adjustment", "Precomp", "Solid", "Image", "Video", "Sequence", +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +function LumiLayer.new(construct, ...) + local self = setmetatable({}, LumiLayer) + + self.TAG = AE_EFFECT_TAG + + self.InputTex = nil + self.OutputTex = nil + self.aeTime = -1 + + -- TRS + self.hasTransform = false + self.active_cam_fovx = 39.6 + self.compositeSize = Amaz.Vector2f(1080, 1080) + self.layerSize = Amaz.Vector2f(1080, 1080) + + self.anchorPoint = Amaz.Vector3f(0, 0, 0) + self.position = Amaz.Vector3f(0, 0, 0) + self.scale = Amaz.Vector3f(100, 100, 100) + self.orientation = Amaz.Vector3f(0, 0, 0) + self.rotation = 0 + self.xRotation = 0 + self.yRotation = 0 + self.opacity = 100 + + self.p0_anchorPoint = Amaz.Vector3f(0, 0, 0) + self.p0_position = Amaz.Vector3f(0, 0, 0) + self.p0_scale = Amaz.Vector3f(100, 100, 100) + self.p0_orientation = Amaz.Vector3f(0, 0, 0) + self.p0_rotation = 0 + self.p0_xRotation = 0 + self.p0_yRotation = 0 + + self.p1_anchorPoint = Amaz.Vector3f(0, 0, 0) + self.p1_position = Amaz.Vector3f(0, 0, 0) + self.p1_scale = Amaz.Vector3f(100, 100, 100) + self.p1_orientation = Amaz.Vector3f(0, 0, 0) + self.p1_rotation = 0 + self.p1_xRotation = 0 + self.p1_yRotation = 0 + + self.expandRight = 0.0 + self.expandLeft = 0.0 + self.expandUp = 0.0 + self.expandDown = 0.0 + self.mirrorEdge = false + + -- Matte + self.hasMatte = false + self.matteMode = "Alpha" + self.matteDuration = {} + self.maskTex = nil + + -- Blend + self.hasBlend = true + self.blendMode = "Normal" + self.isVisible = true + self.layerType = 'Adjustment' + self.baseTex = nil + self.srcDuration = {} + self.baseDuration = {} + + -- for test + if false then + self.aeTime = 1 + self.srcDuration = {{0, 6}} + self.baseDuration = {{0, 6}} + end + + return self +end + +function LumiLayer:setVisible(visible) + self.isVisible = visible +end + +function LumiLayer:setEntityVisible(entity, visible) + local transforms = entity:getComponentsRecursive("Transform") + for i = 0, transforms:size() - 1 do + local transform = transforms:get(i) + if transform then + transform.entity.visible = visible + end + end + entity.visible = visible +end + +function LumiLayer:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.layerEntity = self.entity:searchEntity('LayerCamera'); + self.camera = self.layerEntity:getComponent('Camera') + self.expand_tile_trans = self.entity:searchEntity("expand_tile"):getComponent("Transform") + self.father_trans = self.entity:searchEntity("father_trans"):getComponent("Transform") + self.child_trans = self.entity:searchEntity("child_trans"):getComponent("Transform") + self.p0_father_trans = self.entity:searchEntity("p0_father_trans"):getComponent("Transform") + self.p0_child_trans = self.entity:searchEntity("p0_child_trans"):getComponent("Transform") + self.p1_father_trans = self.entity:searchEntity("p1_father_trans"):getComponent("Transform") + self.p1_child_trans = self.entity:searchEntity("p1_child_trans"):getComponent("Transform") + self.renderer = self.entity:searchEntity('expand_tile'):getComponent('MeshRenderer') + self.renderer.useFrustumCulling = false + self.material = self.renderer.material +end + +local PositionDict = { + xPosition = {'position', 'x'}, + yPosition = {'position', 'y'}, + zPosition = {'position', 'z'}, + p0_xPosition = {'p0_position', 'x'}, + p0_yPosition = {'p0_position', 'y'}, + p0_zPosition = {'p0_position', 'z'}, + p1_xPosition = {'p1_position', 'x'}, + p1_yPosition = {'p1_position', 'y'}, + p1_zPosition = {'p1_position', 'z'}, +} + +function LumiLayer:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value) + if self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if key == 'position' + or key == 'anchorPoint' + or key == 'scale' + or key == 'orientation' + or key == 'p0_position' + or key == 'p0_anchorPoint' + or key == 'p0_scale' + or key == 'p0_orientation' + or key == 'p1_position' + or key == 'p1_anchorPoint' + or key == 'p1_scale' + or key == 'p1_orientation' + then + if value.z ~= nil then + _setEffectAttr(key, value) + else + -- Vector2f to Vector3f + _setEffectAttr(key, Amaz.Vector3f(value.x, value.y, 0)) + end + elseif PositionDict[key] ~= nil then + local newKey = PositionDict[key][1] + local dimension = PositionDict[key][2] + self[newKey][dimension] = value + _setEffectAttr(newKey, self[newKey]) + elseif key == 'blendMode' then + _setEffectAttr(key, BlendMode[value + 1]) + elseif key == 'matteMode' then + _setEffectAttr(key, MatteMode[value + 1]) + elseif key == 'layerType' then + if type(value) == 'string' then + _setEffectAttr(key, value) + else + _setEffectAttr(key, LayerType[value + 1]) + end + else + _setEffectAttr(key, value) + end +end + +function LumiLayer:_rotateByAEAxis(_trans, _direction, _euler_angle) + -- ae xyz, editor yxz + local right = Amaz.Vector3f(1.0, 0.0, 0.0) + local up = Amaz.Vector3f(0.0, 1.0, 0.0) + local forward = Amaz.Vector3f(0.0, 0.0, 1.0) + + local cur_orientation = Amaz.Quaternionf.axisAngleToQuaternion(right, math.rad(_direction.x)) + * Amaz.Quaternionf.axisAngleToQuaternion(up, -math.rad(_direction.y)) + * Amaz.Quaternionf.axisAngleToQuaternion(forward, -math.rad(_direction.z)) + + up = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, up) + right = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, right) + forward = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, forward) + + cur_orientation = Amaz.Quaternionf.axisAngleToQuaternion(right, math.rad(_euler_angle.x)) + * Amaz.Quaternionf.axisAngleToQuaternion(up, -math.rad(_euler_angle.y)) + * Amaz.Quaternionf.axisAngleToQuaternion(forward, -math.rad(_euler_angle.z)) + * cur_orientation + + _trans.localOrientation = cur_orientation +end + +function LumiLayer:updateTRS(ratio) + self.expand_tile_trans.localScale = Amaz.Vector3f(1.0+self.expandRight+self.expandLeft, 1.0+self.expandUp+self.expandDown, 1.0) + self.expand_tile_trans.localPosition = Amaz.Vector3f( + self.expandRight-self.expandLeft, + self.expandUp-self.expandDown, + 0.0 + ) + + local ratio_c = self.compositeSize.x / self.compositeSize.y + local pos_z0 = ratio / math.tan(math.rad(self.active_cam_fovx * 0.5)) + local compositeSizeZ = self.compositeSize.y * ratio_c / ratio + -- Amaz.LOGE(self.TAG, "compositeSizeZ: "..compositeSizeZ) + self.camera.fovy = 2 * math.deg(math.atan(1 / pos_z0)) + + local rotate = Amaz.Vector3f(self.xRotation, self.yRotation, self.rotation) + self:_rotateByAEAxis(self.father_trans, self.orientation, rotate) + self.father_trans.localPosition = Amaz.Vector3f( + (self.position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.position.y / self.compositeSize.y - 0.5) * 2, + -self.position.z * 2 / compositeSizeZ + ) + self.child_trans.localPosition = Amaz.Vector3f( + -(self.anchorPoint.x / self.layerSize.x - 0.5) * 2 * ratio, + -(1.0 - self.anchorPoint.y / self.layerSize.y - 0.5) * 2, + self.anchorPoint.z * 2 / compositeSizeZ + ) + self.child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + -- parent 0 + rotate = Amaz.Vector3f(self.p0_xRotation, self.p0_yRotation, self.p0_rotation) + self:_rotateByAEAxis(self.p0_father_trans, self.p0_orientation, rotate) + self.p0_father_trans.localPosition = Amaz.Vector3f( + (self.p0_position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.p0_position.y / self.compositeSize.y - 0.5) * 2, + -self.p0_position.z * 2 / compositeSizeZ + ) + self.p0_child_trans.localPosition = Amaz.Vector3f( + -(self.p0_anchorPoint.x / self.compositeSize.x - 0.5) * 2 * ratio, + -(1.0 - self.p0_anchorPoint.y / self.compositeSize.y - 0.5) * 2, + self.p0_anchorPoint.z * 2 / compositeSizeZ + ) + self.p0_child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + -- parent 1 + rotate = Amaz.Vector3f(self.p1_xRotation, self.p1_yRotation, self.p1_rotation) + self:_rotateByAEAxis(self.p1_father_trans, self.p1_orientation, rotate) + self.p1_father_trans.localPosition = Amaz.Vector3f( + (self.p1_position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.p1_position.y / self.compositeSize.y - 0.5) * 2, + -pos_z0 - self.p1_position.z * 2 / compositeSizeZ + ) + self.p1_child_trans.localPosition = Amaz.Vector3f( + -(self.p1_anchorPoint.x / self.compositeSize.x - 0.5) * 2 * ratio, + -(1.0 - self.p1_anchorPoint.y / self.compositeSize.y - 0.5) * 2, + self.p1_anchorPoint.z * 2 / compositeSizeZ + ) + self.p1_child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + self.father_trans.localScale = Amaz.Vector3f( + self.scale.x / 100.0 * (self.layerSize.x / self.compositeSize.x), + self.scale.y / 100.0 * (self.layerSize.y / self.compositeSize.y), + self.scale.z / 100.0 + ) + self.child_trans.localScale = Amaz.Vector3f(ratio, 1, 1) + self.p0_father_trans.localScale = self.p0_scale / 100.0 + self.p1_father_trans.localScale = self.p1_scale / 100.0 + + local mMat = self.expand_tile_trans:getWorldMatrix() + local vMat = self.camera:getWorldToCameraMatrix() + local pMat = self.camera.projectionMatrix + + return {vMat * mMat, pMat:invert_Full()} +end + +function LumiLayer:onUpdate(comp, deltaTime) + self.opacity = clamp(self.opacity, 0, 100) + local trsOpacity = 1.0 + local blendOpacity = 1.0 + if self.layerType == 'Adjustment' then + blendOpacity = self.opacity / 100.0 + else + trsOpacity = self.opacity / 100.0 + end + + local hasSrcTexture = false + if self.isVisible then + for _, duration in ipairs(self.srcDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + hasSrcTexture = true + break + end + end + end + + local needTrs = self.hasTransform and hasSrcTexture + local visible = needTrs or self.hasMatte or self.hasBlend + if self.layerEntity.visible ~= visible then + self:setEntityVisible(self.layerEntity, visible) + end + if visible == false then + return + end + + self.camera.renderTexture = self.OutputTex + self.material:setTex('u_sourceTexture', self.InputTex) + self.material:setTex('u_baseTexure', self.baseTex) + self.material:setTex('u_maskTexture', self.maskTex) + self.material:setInt('u_layerType', self.layerType == 'Adjustment' and 1 or 0) + + if needTrs then + local ratio = self.OutputTex.width / self.OutputTex.height + local mvp = self:updateTRS(ratio) + self.material:setInt('u_hasTrs', 1) + self.material:setMat4('u_mvMat', mvp[1]) + self.material:setMat4('u_pMat', mvp[2]) + self.material:setFloat('u_alpha', trsOpacity) + self.material:setFloat('u_mirrorEdge', self.mirrorEdge and 1 or 0) + else + self.material:setInt('u_hasTrs', 0) + end + + if hasSrcTexture then + self.material:setInt("u_hasSourceTexture", 1) + else + self.material:setInt("u_hasSourceTexture", 0) + end + + local enableMatte = false + if self.hasMatte and self.maskTex then + for _, duration in ipairs(self.matteDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + enableMatte = true + break + end + end + end + + if self.hasBlend then + local hasBaseTexture = false + for _, duration in ipairs(self.baseDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + hasBaseTexture = true + break + end + end + self.material:setInt("u_hasBlend", 1) + self.material:setInt("u_hasBaseTexture", hasBaseTexture and 1 or 0) + self.material:setInt("u_blendMode", BlendModeIndex[self.blendMode]) + self.material:setFloat("u_layerOpacity", blendOpacity) + else + self.material:setInt("u_hasBlend", 0) + end + + if self.hasMatte then + self.material:setInt('u_hasMatte', 1) + self.material:setInt("u_enableMatte", enableMatte and 1 or 0) + self.material:setInt("u_matteMode", MatteModeIndex[self.matteMode]) + else + self.material:setInt('u_hasMatte', 0) + end +end + +exports.LumiLayer = LumiLayer +return exports diff --git a/scripts/7681574644264045845/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag b/scripts/7681574644264045845/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag new file mode 100644 index 0000000000000000000000000000000000000000..01561dcc590f6fbe28e9efccd32698c72f5eeb0f --- /dev/null +++ b/scripts/7681574644264045845/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag @@ -0,0 +1,240 @@ +precision highp float; +precision highp int; + +uniform mediump int u_enableMatte; +uniform mediump sampler2D u_maskTexture; +uniform mediump int u_matteMode; +uniform mediump int u_layerType; +uniform mediump int u_hasMatte; +uniform float u_layerOpacity; +uniform mediump int u_hasBlend; +uniform mediump int u_hasBaseTexture; +uniform mediump sampler2D u_baseTexure; +uniform mediump int u_hasSourceTexture; +uniform mediump int u_hasTrs; +uniform mat4 u_mvMat; +uniform mat4 u_pMat; +uniform float u_mirrorEdge; +uniform mediump sampler2D u_sourceTexture; +uniform float u_alpha; + +varying vec2 uv0; + +vec4 _f1(vec3 _p0, vec3 _p1, vec3 _p2, vec3 _p3, vec3 _p4) +{ + vec3 _61 = _p3 - _p2; + vec3 _65 = _p4 - _p2; + vec3 _69 = cross(_p1, _65); + float _74 = dot(_61, _69); + if (_74 <= 1.0000000116860974230803549289703e-07) + { + return vec4(-1.0); + } + vec3 _87 = _p0 - _p2; + float _93 = dot(_87, _69) / _74; + if ((_93 < 0.0) || (_93 > 1.0)) + { + return vec4(-1.0); + } + vec3 _107 = cross(_87, _61); + float _113 = dot(_p1, _107) / _74; + bool _115 = _113 < 0.0; + bool _123; + if (!_115) + { + _123 = (_93 + _113) > 1.0; + } + else + { + _123 = _115; + } + if (_123) + { + return vec4(-1.0); + } + return vec4(_93, _113, dot(_65, _107) / _74, 1.0); +} + +vec2 _f2(mat4 _p0, mat4 _p1, vec2 _p2) +{ + vec3 _162 = (_p0 * vec4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + vec3 _168 = (_p0 * vec4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _173 = (_p0 * vec4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _178 = (_p0 * vec4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + vec4 _189 = _p1 * vec4((_p2 * 2.0) - vec2(1.0), 0.0, 1.0); + vec4 _t17 = _189; + vec3 _206 = normalize((_189.xyz / vec3(_t17.w)) - vec3(0.0)); + vec3 param = vec3(0.0); + vec3 param_1 = _206; + vec3 _214 = (_p0 * vec4(-10.0, -10.0, 0.0, 1.0)).xyz; + vec3 param_2 = _214; + vec3 param_3 = _162; + vec3 param_4 = _173; + vec4 _t21 = _f1(param, param_1, param_2, param_3, param_4); + vec3 param_5 = vec3(0.0); + vec3 param_6 = _206; + vec3 param_7 = _178; + vec3 param_8 = _168; + vec3 _231 = (_p0 * vec4(10.0, 10.0, 0.0, 1.0)).xyz; + vec3 param_9 = _231; + vec4 _t22 = _f1(param_5, param_6, param_7, param_8, param_9); + vec3 param_10 = vec3(0.0); + vec3 param_11 = _206; + vec3 param_12 = _214; + vec3 param_13 = _173; + vec3 param_14 = _162; + vec4 _t23 = _f1(param_10, param_11, param_12, param_13, param_14); + vec3 param_15 = vec3(0.0); + vec3 param_16 = _206; + vec3 param_17 = _178; + vec3 param_18 = _231; + vec3 param_19 = _168; + vec4 _t24 = _f1(param_15, param_16, param_17, param_18, param_19); + vec2 _397 = (((((((vec2(-4.5) * ((1.0 - _t21.x) - _t21.y)) + (vec2(5.5, -4.5) * _t21.x)) + (vec2(-4.5, 5.5) * _t21.y)) * step(0.0, _t21.w)) + ((((vec2(-4.5, 5.5) * ((1.0 - _t22.x) - _t22.y)) + (vec2(5.5, -4.5) * _t22.x)) + (vec2(5.5) * _t22.y)) * (step(_t21.w, 0.0) * step(0.0, _t22.w)))) + ((((vec2(-4.5) * ((1.0 - _t23.x) - _t23.y)) + (vec2(-4.5, 5.5) * _t23.x)) + (vec2(5.5, -4.5) * _t23.y)) * ((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(0.0, _t23.w)))) + ((((vec2(-4.5, 5.5) * ((1.0 - _t24.x) - _t24.y)) + (vec2(5.5) * _t24.x)) + (vec2(5.5, -4.5) * _t24.y)) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(0.0, _t24.w)))) + (vec2(-10000.0) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(_t24.w, 0.0))); + return _397; +} + +vec2 _f4(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +float _f3(vec2 _p0) +{ + vec2 _t30 = step(vec2(0.0), _p0) * step(_p0, vec2(1.0)); + return _t30.x * _t30.y; +} + +float _f0(vec3 _p0) +{ + return dot(_p0, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +vec4 _f5(vec4 _p0) +{ + vec4 _t31 = vec4(0.0); + if (u_enableMatte == 1) + { + _t31 = texture2D(u_maskTexture, uv0); + } + float _t32 = _t31.w; + if (u_matteMode == 1) + { + vec3 param = _t31.xyz; + _t32 = _f0(param); + } + else + { + if (u_matteMode == 2) + { + _t32 = 1.0 - _t31.w; + } + else + { + if (u_matteMode == 3) + { + vec3 param_1 = _t31.xyz; + _t32 = 1.0 - _f0(param_1); + } + } + } + return _p0 * _t32; +} + +vec4 _f6(inout vec4 _p0, inout vec4 _p1) +{ + float _483 = _p0.w; + vec4 _486 = _p0; + vec3 _489 = _486.xyz / vec3(max(_483, 9.9999997473787516355514526367188e-06)); + _p0.x = _489.x; + _p0.y = _489.y; + _p0.z = _489.z; + float _498 = _p1.w; + vec4 _500 = _p1; + vec3 _503 = _500.xyz / vec3(max(_498, 9.9999997473787516355514526367188e-06)); + _p1.x = _503.x; + _p1.y = _503.y; + _p1.z = _503.z; + vec4 _t33 = _p1; + _t33.x = _p0.xyz.x; + _t33.y = _p0.xyz.y; + _t33.z = _p0.xyz.z; + vec4 _t34 = vec4(0.0); + if (u_layerType == 1) + { + float _t35 = 1.0; + if (u_hasMatte == 1) + { + vec4 param = vec4(1.0); + _t35 = _f5(param).w; + } + vec4 _551 = mix(_p1, vec4(_t33.xyz, _p0.w), vec4(u_layerOpacity * _t35)); + _t34 = _551; + float _553 = _t34.w; + vec3 _556 = _551.xyz * _553; + _t34.x = _556.x; + _t34.y = _556.y; + _t34.z = _556.z; + } + else + { + vec3 _591 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t33.xyz * (_p0.w * _p1.w)); + _t34.x = _591.x; + _t34.y = _591.y; + _t34.z = _591.z; + _t34.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t34; +} + +void main() +{ + vec4 _t36 = vec4(0.0); + bool _614 = u_hasBlend == 1; + if (_614) + { + if (u_hasBaseTexture == 1) + { + _t36 = texture2D(u_baseTexure, uv0); + } + if (u_hasSourceTexture == 0) + { + gl_FragData[0] = _t36; + return; + } + } + vec4 _t37 = vec4(0.0); + if (u_hasTrs == 1) + { + mat4 param = u_mvMat; + mat4 param_1 = u_pMat; + vec2 param_2 = uv0; + vec2 _652 = _f2(param, param_1, param_2); + float _656 = step(u_mirrorEdge, 0.5); + vec2 param_3 = _652; + vec2 _666 = (_652 * _656) + (_f4(param_3) * (1.0 - _656)); + vec2 param_4 = _666; + _t37 = (texture2D(u_sourceTexture, _666) * u_alpha) * _f3(param_4); + } + else + { + if (u_hasSourceTexture == 1) + { + _t37 = texture2D(u_sourceTexture, uv0); + } + } + if ((u_layerType != 1) && (u_hasMatte == 1)) + { + vec4 param_5 = _t37; + _t37 = _f5(param_5); + } + if (_614) + { + vec4 param_6 = _t37; + vec4 param_7 = _t36; + vec4 _704 = _f6(param_6, param_7); + _t37 = _704; + } + gl_FragData[0] = _t37; +} + diff --git a/scripts/7681574644264045845/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681574644264045845/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..705dd9f8b691def7eaafc9c1b6e2528c0b0c0165 --- /dev/null +++ b/scripts/7681574644264045845/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681574644264045845/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag b/scripts/7681574644264045845/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag new file mode 100644 index 0000000000000000000000000000000000000000..7b5f204904818053699abc060be6bfa62f2ab74e --- /dev/null +++ b/scripts/7681574644264045845/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag @@ -0,0 +1,268 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + int u_enableMatte; + int u_matteMode; + int u_layerType; + int u_hasMatte; + float u_layerOpacity; + int u_hasBlend; + int u_hasBaseTexture; + int u_hasSourceTexture; + int u_hasTrs; + float4x4 u_mvMat; + float4x4 u_pMat; + float u_mirrorEdge; + float u_alpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f1(thread const float3& _p0, thread const float3& _p1, thread const float3& _p2, thread const float3& _p3, thread const float3& _p4) +{ + float3 _61 = _p3 - _p2; + float3 _65 = _p4 - _p2; + float3 _69 = cross(_p1, _65); + float _74 = dot(_61, _69); + if (_74 <= 1.0000000116860974230803549289703e-07) + { + return float4(-1.0); + } + float3 _87 = _p0 - _p2; + float _93 = dot(_87, _69) / _74; + if ((_93 < 0.0) || (_93 > 1.0)) + { + return float4(-1.0); + } + float3 _107 = cross(_87, _61); + float _113 = dot(_p1, _107) / _74; + bool _115 = _113 < 0.0; + bool _123; + if (!_115) + { + _123 = (_93 + _113) > 1.0; + } + else + { + _123 = _115; + } + if (_123) + { + return float4(-1.0); + } + return float4(_93, _113, dot(_65, _107) / _74, 1.0); +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float4x4& _p0, thread const float4x4& _p1, thread const float2& _p2) +{ + float3 _162 = (_p0 * float4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + float3 _168 = (_p0 * float4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _173 = (_p0 * float4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _178 = (_p0 * float4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + float4 _189 = _p1 * float4((_p2 * 2.0) - float2(1.0), 0.0, 1.0); + float4 _t17 = _189; + float3 _206 = fast::normalize((_189.xyz / float3(_t17.w)) - float3(0.0)); + float3 param = float3(0.0); + float3 param_1 = _206; + float3 _214 = (_p0 * float4(-10.0, -10.0, 0.0, 1.0)).xyz; + float3 param_2 = _214; + float3 param_3 = _162; + float3 param_4 = _173; + float4 _t21 = _f1(param, param_1, param_2, param_3, param_4); + float3 param_5 = float3(0.0); + float3 param_6 = _206; + float3 param_7 = _178; + float3 param_8 = _168; + float3 _231 = (_p0 * float4(10.0, 10.0, 0.0, 1.0)).xyz; + float3 param_9 = _231; + float4 _t22 = _f1(param_5, param_6, param_7, param_8, param_9); + float3 param_10 = float3(0.0); + float3 param_11 = _206; + float3 param_12 = _214; + float3 param_13 = _173; + float3 param_14 = _162; + float4 _t23 = _f1(param_10, param_11, param_12, param_13, param_14); + float3 param_15 = float3(0.0); + float3 param_16 = _206; + float3 param_17 = _178; + float3 param_18 = _231; + float3 param_19 = _168; + float4 _t24 = _f1(param_15, param_16, param_17, param_18, param_19); + float2 _397 = (((((((float2(-4.5) * ((1.0 - _t21.x) - _t21.y)) + (float2(5.5, -4.5) * _t21.x)) + (float2(-4.5, 5.5) * _t21.y)) * step(0.0, _t21.w)) + ((((float2(-4.5, 5.5) * ((1.0 - _t22.x) - _t22.y)) + (float2(5.5, -4.5) * _t22.x)) + (float2(5.5) * _t22.y)) * (step(_t21.w, 0.0) * step(0.0, _t22.w)))) + ((((float2(-4.5) * ((1.0 - _t23.x) - _t23.y)) + (float2(-4.5, 5.5) * _t23.x)) + (float2(5.5, -4.5) * _t23.y)) * ((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(0.0, _t23.w)))) + ((((float2(-4.5, 5.5) * ((1.0 - _t24.x) - _t24.y)) + (float2(5.5) * _t24.x)) + (float2(5.5, -4.5) * _t24.y)) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(0.0, _t24.w)))) + (float2(-10000.0) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(_t24.w, 0.0))); + return _397; +} + +static inline __attribute__((always_inline)) +float2 _f4(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0) +{ + float2 _t30 = step(float2(0.0), _p0) * step(_p0, float2(1.0)); + return _t30.x * _t30.y; +} + +static inline __attribute__((always_inline)) +float _f0(thread const float3& _p0) +{ + return dot(_p0, float3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread const float4& _p0, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode) +{ + float4 _t31 = float4(0.0); + if (u_enableMatte == 1) + { + _t31 = u_maskTexture.sample(u_maskTextureSmplr, uv0); + } + float _t32 = _t31.w; + if (u_matteMode == 1) + { + float3 param = _t31.xyz; + _t32 = _f0(param); + } + else + { + if (u_matteMode == 2) + { + _t32 = 1.0 - _t31.w; + } + else + { + if (u_matteMode == 3) + { + float3 param_1 = _t31.xyz; + _t32 = 1.0 - _f0(param_1); + } + } + } + return _p0 * _t32; +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, thread float4& _p1, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode, constant int& u_layerType, constant int& u_hasMatte, constant float& u_layerOpacity) +{ + float _483 = _p0.w; + float4 _486 = _p0; + float3 _489 = _486.xyz / float3(fast::max(_483, 9.9999997473787516355514526367188e-06)); + _p0.x = _489.x; + _p0.y = _489.y; + _p0.z = _489.z; + float _498 = _p1.w; + float4 _500 = _p1; + float3 _503 = _500.xyz / float3(fast::max(_498, 9.9999997473787516355514526367188e-06)); + _p1.x = _503.x; + _p1.y = _503.y; + _p1.z = _503.z; + float4 _t33 = _p1; + _t33.x = _p0.xyz.x; + _t33.y = _p0.xyz.y; + _t33.z = _p0.xyz.z; + float4 _t34 = float4(0.0); + if (u_layerType == 1) + { + float _t35 = 1.0; + if (u_hasMatte == 1) + { + float4 param = float4(1.0); + _t35 = _f5(param, u_enableMatte, u_maskTexture, u_maskTextureSmplr, uv0, u_matteMode).w; + } + float4 _551 = mix(_p1, float4(_t33.xyz, _p0.w), float4(u_layerOpacity * _t35)); + _t34 = _551; + float _553 = _t34.w; + float3 _556 = _551.xyz * _553; + _t34.x = _556.x; + _t34.y = _556.y; + _t34.z = _556.z; + } + else + { + float3 _591 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t33.xyz * (_p0.w * _p1.w)); + _t34.x = _591.x; + _t34.y = _591.y; + _t34.z = _591.z; + _t34.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t34; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_maskTexture [[texture(0)]], texture2d u_baseTexure [[texture(1)]], texture2d u_sourceTexture [[texture(2)]], sampler u_maskTextureSmplr [[sampler(0)]], sampler u_baseTexureSmplr [[sampler(1)]], sampler u_sourceTextureSmplr [[sampler(2)]]) +{ + main0_out out = {}; + float4 _t36 = float4(0.0); + bool _614 = buffer.u_hasBlend == 1; + if (_614) + { + if (buffer.u_hasBaseTexture == 1) + { + _t36 = u_baseTexure.sample(u_baseTexureSmplr, in.uv0); + } + if (buffer.u_hasSourceTexture == 0) + { + out.o_fragColor = _t36; + return out; + } + } + float4 _t37 = float4(0.0); + if (buffer.u_hasTrs == 1) + { + float4x4 param = buffer.u_mvMat; + float4x4 param_1 = buffer.u_pMat; + float2 param_2 = in.uv0; + float2 _652 = _f2(param, param_1, param_2); + float _656 = step(buffer.u_mirrorEdge, 0.5); + float2 param_3 = _652; + float2 _666 = (_652 * _656) + (_f4(param_3) * (1.0 - _656)); + float2 param_4 = _666; + _t37 = (u_sourceTexture.sample(u_sourceTextureSmplr, _666) * buffer.u_alpha) * _f3(param_4); + } + else + { + if (buffer.u_hasSourceTexture == 1) + { + _t37 = u_sourceTexture.sample(u_sourceTextureSmplr, in.uv0); + } + } + if ((buffer.u_layerType != 1) && (buffer.u_hasMatte == 1)) + { + float4 param_5 = _t37; + _t37 = _f5(param_5, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode); + } + if (_614) + { + float4 param_6 = _t37; + float4 param_7 = _t36; + float4 _704 = _f6(param_6, param_7, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode, buffer.u_layerType, buffer.u_hasMatte, buffer.u_layerOpacity); + _t37 = _704; + } + out.o_fragColor = _t37; + return out; +} + diff --git a/scripts/7681574644264045845/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681574644264045845/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..d7349349d1805ff40c01eddcceaf24b19c0e17d2 --- /dev/null +++ b/scripts/7681574644264045845/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681574644264045845/AmazingFeature/effects/LumiMotionBlur2D/MotionBlur2D.lua b/scripts/7681574644264045845/AmazingFeature/effects/LumiMotionBlur2D/MotionBlur2D.lua new file mode 100644 index 0000000000000000000000000000000000000000..d83978c2f9b31ed6ad4750add08f35d33541be09 --- /dev/null +++ b/scripts/7681574644264045845/AmazingFeature/effects/LumiMotionBlur2D/MotionBlur2D.lua @@ -0,0 +1,199 @@ +local exports = exports or {} +local MotionBlur2D = MotionBlur2D or {} +MotionBlur2D.__index = MotionBlur2D +---@class MotionBlur2D: ScriptComponent +---@field currRotate double [UI(Range={0, 360}, Slider)] +---@field currAnchor Vector2f [UI(Drag=0.01)] +---@field currPosition Vector2f [UI(Drag=0.01)] +---@field unifiedScale boolean +---@field currScale Vector2f [UI(Drag=0.01)] +---@field vIntensity double [UI(Range={0, 2}, Slider)] +---@field vCenter double [UI(Range={-1, 1}, Slider)] +---@field minSamples double [UI(Range={0, 256}, Slider)] +---@field maxSamples double [UI(Range={0, 256}, Slider)] +---@field dither double [UI(Range={0, 1}, Slider)] +---@field mirrorEdge boolean +---@field InputTex Texture +---@field OutputTex Texture + +function MotionBlur2D.new(construct, ...) + local self = setmetatable({}, MotionBlur2D) + if construct and MotionBlur2D.constructor then + MotionBlur2D.constructor(self, ...) + end + self.startTime = 0.0 + self.endTime = 1.0 + self.curTime = 0.0 + self.firstSeek = true + + self.prevRotate = 0 + self.prevPosition = Amaz.Vector2f(0., 0.) + self.prevScale = Amaz.Vector2f(1, 1) + self.prevAnchor = Amaz.Vector2f(0., 0.) + self.currRotate = 0 + self.currPosition = Amaz.Vector2f(0., 0.) + self.currScale = Amaz.Vector2f(1, 1) + self.currAnchor = Amaz.Vector2f(0., 0.) + self.positionVec2Vector = Amaz.Vec2Vector() + + self.vIntensity = 1.0 + self.vCenter = 0.0 + self.minSamples = 2.0 + self.maxSamples = 24.0 + self.dither = 1.0 + self.mirrorEdge = false + self.unifiedScale = false + + self.InputTex = nil + self.OutputTex = nil + return self +end + +function MotionBlur2D:constructor() +end + +function MotionBlur2D:onUpdate(comp, detalTime) + self:seekToTime(comp, detalTime) + + self.material:setTex("u_inputImageTexture", self.InputTex) + self.cam.renderTexture = self.OutputTex +end + +function MotionBlur2D:start(comp) + self.first = true + self.material = comp.entity:searchEntity("motion_blur_2d"):getComponent("MeshRenderer").material + self.cam = comp.entity:searchEntity("cam"):getComponent("Camera") +end + +function MotionBlur2D:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value) + if self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if key == "maxSamples" or key == "minSamples" then + _setEffectAttr(key, math.floor(value * 100)) + elseif key == "rotate" then + _setEffectAttr("currRotate", value) + elseif key == "ae_pre_rotate" then + _setEffectAttr("prevRotate", value) + elseif key == "scale_x" or key == "scale_y" then + local currScale = self["currScale"] + if currScale then + if math.abs(value)<0.001 then value = 0.001 end + if key == "scale_x" then + currScale.x = value + else + currScale.y = value + end + _setEffectAttr("currScale", currScale) + end + elseif key == "position" then + local currPosition = self["currPosition"] + if currPosition then + currPosition.x = value.x - 0.5 + currPosition.y = value.y - 0.5 + _setEffectAttr("currPosition", currPosition) + end + elseif key == "ae_pre_position" then + local prevPosition = self["prevPosition"] + if prevPosition then + prevPosition.x = value.x - 0.5 + prevPosition.y = value.y - 0.5 + _setEffectAttr("prevPosition", prevPosition) + end + elseif key == "anchor" then + local currAnchor = self["currAnchor"] + if currAnchor then + currAnchor.x = value.x - 0.5 + currAnchor.y = value.y - 0.5 + _setEffectAttr("currAnchor", currAnchor) + end + elseif key == "ae_pre_anchor" then + local prevAnchor = self["prevAnchor"] + if prevAnchor then + prevAnchor.x = value.x - 0.5 + prevAnchor.y = value.y - 0.5 + _setEffectAttr("prevAnchor", prevAnchor) + end + elseif key == "ae_pre_scale_x" or key == "ae_pre_scale_y" then + local prevScale = self["prevScale"] + if prevScale then + if math.abs(value)<0.001 then value = 0.001 end + if key == "ae_pre_scale_x" then + prevScale.x = value + else + prevScale.y = value + end + _setEffectAttr("prevScale", prevScale) + end + else + _setEffectAttr(key, value) + end + +end + +function MotionBlur2D:seekToTime(comp, time) + if self.first == nil then + self:start(comp) + end + + self.curTime = (self.curTime + time)%(self.endTime - self.startTime) + + local pointSize = 5; + local pivotVec2Vector = Amaz.Vec2Vector() + local positionVec2Vector = Amaz.Vec2Vector() + local scaleVec2Vector = Amaz.Vec2Vector() + local rotationFloatVector = Amaz.FloatVector() + for i=0,pointSize,1 do + local w = (self.vIntensity * (i/pointSize) + self.vCenter + 1.0); + -- Offset keyframe with curve + -- local frameTime = 1./ 90.0 + -- local AEprogress = progress + frameTime*(w-1.0) + -- positionVec2Vector:pushBack(self:getOffset(AEprogress)) + local pivot = self.prevAnchor * (1.0-w) + self.currAnchor * w; + local position = self.prevPosition * (1.0-w) + self.currPosition * w; + local scale = self.prevScale * (1.0-w) + self.currScale * w; + if self.unifiedScale then + scale.y = scale.x + end + local rotation = self.prevRotate * (1.0-w) + self.currRotate * w; + pivotVec2Vector:pushBack(pivot) + positionVec2Vector:pushBack(position) + scaleVec2Vector:pushBack(scale) + rotationFloatVector:pushBack(rotation) + end + self.material:setVec2Vector("u_pivotVec2Vector", pivotVec2Vector) + if self.positionVec2Vector:empty() then + self.material:setVec2Vector("u_positionVec2Vector", positionVec2Vector) + else + self.material:setVec2Vector("u_positionVec2Vector", self.positionVec2Vector) + end + self.material:setVec2Vector("u_scaleVec2Vector", scaleVec2Vector) + self.material:setFloatVector("u_rotationFloatVector", rotationFloatVector) + + self.material:setFloat("u_minSamples", self.minSamples); + self.material:setFloat("u_maxSamples", self.maxSamples); + self.material:setFloat("u_dither", self.dither); + self.material:setFloat("u_mirrorEdge", self.mirrorEdge and 1 or 0) + if math.abs(self.vIntensity) < 0.001 then + self.material:setInt("u_skipSample", 1) + else + self.material:setInt("u_skipSample", 0) + end +end + +function MotionBlur2D:onLateUpdate(comp, detalTime) + +end + +local function clamp(val, min, max) + return math.max(math.min(val, max), min) +end + +exports.MotionBlur2D = MotionBlur2D +return exports diff --git a/scripts/7681574644264045845/AmazingFeature/effects/LumiMotionBlur2D/shaderLib/shaderGLES/93ab10f0e935e0bc691355370bc4cc5d.frag b/scripts/7681574644264045845/AmazingFeature/effects/LumiMotionBlur2D/shaderLib/shaderGLES/93ab10f0e935e0bc691355370bc4cc5d.frag new file mode 100644 index 0000000000000000000000000000000000000000..f312dbc929647fba08987c5bceaa20ae2ebd5a11 --- /dev/null +++ b/scripts/7681574644264045845/AmazingFeature/effects/LumiMotionBlur2D/shaderLib/shaderGLES/93ab10f0e935e0bc691355370bc4cc5d.frag @@ -0,0 +1,142 @@ +precision highp float; +precision highp int; + +uniform vec4 u_ScreenParams; +uniform mediump int u_skipSample; +uniform float u_rotationFloatVector[6]; +uniform vec2 u_positionVec2Vector[6]; +uniform vec2 u_pivotVec2Vector[6]; +uniform vec2 u_scaleVec2Vector[6]; +uniform float u_mirrorEdge; +uniform mediump sampler2D u_inputImageTexture; +uniform float u_minSamples; +uniform float u_maxSamples; +uniform float u_dither; + +varying vec2 uv0; + +vec2 _f0(inout vec2 _p0, float _p1, vec2 _p2, vec2 _p3, vec2 _p4) +{ + _p0 -= _p2; + _p0 -= vec2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _66 = sin(_p1); + float _69 = cos(_p1); + _p0 = mat2(vec2(_69, _66), vec2(-_66, _69)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 *= (vec2(1.0) / _p4); + _p0 += vec2(0.5); + _p0 += _p3; + return _p0; +} + +vec2 _f1(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +float _f2(vec2 _p0) +{ + return ((step(0.0, _p0.x) * step(0.0, _p0.y)) * step(_p0.x, 1.0)) * step(_p0.y, 1.0); +} + +float _f4(float _p0, float _p1) +{ + vec2 _218 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t3 = _218 + vec2(dot(_218, _218.yx + vec2(22.5410003662109375))); + return fract((_t3.x + _t3.y) * _t3.y); +} + +vec2 _f3(float _p0, vec2 _p1, vec2 _p2, vec2 _p3, vec2 _p4, vec2 _p5, vec2 _p6) +{ + return ((((mix(_p1, _p2, vec2(_p0 * 5.0)) * step(_p0, 0.20000000298023223876953125)) + ((mix(_p2, _p3, vec2((_p0 * 5.0) - 1.0)) * (1.0 - step(_p0, 0.20000000298023223876953125))) * step(_p0, 0.4000000059604644775390625))) + ((mix(_p3, _p4, vec2((_p0 * 5.0) - 2.0)) * (1.0 - step(_p0, 0.4000000059604644775390625))) * step(_p0, 0.60000002384185791015625))) + ((mix(_p4, _p5, vec2((_p0 * 5.0) - 3.0)) * (1.0 - step(_p0, 0.60000002384185791015625))) * step(_p0, 0.800000011920928955078125))) + (mix(_p5, _p6, vec2((_p0 * 5.0) - 4.0)) * (1.0 - step(_p0, 0.800000011920928955078125))); +} + +void main() +{ + if (u_skipSample == 1) + { + vec2 param = uv0; + float param_1 = (u_rotationFloatVector[0] * 3.141592502593994140625) / 180.0; + vec2 param_2 = u_positionVec2Vector[0]; + vec2 param_3 = u_pivotVec2Vector[0]; + vec2 param_4 = u_scaleVec2Vector[0]; + vec2 _281 = _f0(param, param_1, param_2, param_3, param_4); + float _284 = step(u_mirrorEdge, 0.5); + vec2 param_5 = _281; + vec2 _294 = (_281 * _284) + (_f1(param_5) * (1.0 - _284)); + vec2 param_6 = _294; + gl_FragData[0] = texture2D(u_inputImageTexture, _294) * _f2(param_6); + return; + } + vec2 param_7 = uv0; + float param_8 = (u_rotationFloatVector[0] * 3.141592502593994140625) / 180.0; + vec2 param_9 = u_positionVec2Vector[0]; + vec2 param_10 = u_pivotVec2Vector[0]; + vec2 param_11 = u_scaleVec2Vector[0]; + vec2 _326 = _f0(param_7, param_8, param_9, param_10, param_11); + vec2 param_12 = uv0; + float param_13 = (u_rotationFloatVector[1] * 3.141592502593994140625) / 180.0; + vec2 param_14 = u_positionVec2Vector[1]; + vec2 param_15 = u_pivotVec2Vector[1]; + vec2 param_16 = u_scaleVec2Vector[1]; + vec2 _344 = _f0(param_12, param_13, param_14, param_15, param_16); + vec2 param_17 = uv0; + float param_18 = (u_rotationFloatVector[2] * 3.141592502593994140625) / 180.0; + vec2 param_19 = u_positionVec2Vector[2]; + vec2 param_20 = u_pivotVec2Vector[2]; + vec2 param_21 = u_scaleVec2Vector[2]; + vec2 _363 = _f0(param_17, param_18, param_19, param_20, param_21); + vec2 param_22 = uv0; + float param_23 = (u_rotationFloatVector[3] * 3.141592502593994140625) / 180.0; + vec2 param_24 = u_positionVec2Vector[3]; + vec2 param_25 = u_pivotVec2Vector[3]; + vec2 param_26 = u_scaleVec2Vector[3]; + vec2 _382 = _f0(param_22, param_23, param_24, param_25, param_26); + vec2 param_27 = uv0; + float param_28 = (u_rotationFloatVector[4] * 3.141592502593994140625) / 180.0; + vec2 param_29 = u_positionVec2Vector[4]; + vec2 param_30 = u_pivotVec2Vector[4]; + vec2 param_31 = u_scaleVec2Vector[4]; + vec2 _401 = _f0(param_27, param_28, param_29, param_30, param_31); + vec2 param_32 = uv0; + float param_33 = (u_rotationFloatVector[5] * 3.141592502593994140625) / 180.0; + vec2 param_34 = u_positionVec2Vector[5]; + vec2 param_35 = u_pivotVec2Vector[5]; + vec2 param_36 = u_scaleVec2Vector[5]; + vec2 _420 = _f0(param_32, param_33, param_34, param_35, param_36); + float _424 = max(u_minSamples, 2.0); + float _442 = floor(_424 + ((max(u_maxSamples, _424) - _424) * smoothstep(0.0, 0.20000000298023223876953125, length(_420 - _326)))); + vec4 _t14 = vec4(0.0); + for (float _t15 = 0.0; _t15 <= 256.0; _t15 += 1.0) + { + if (_t15 >= _442) + { + break; + } + float _t16 = _t15 / (_442 - 1.0); + float param_37 = _t15 + uv0.x; + float param_38 = _t15 * uv0.y; + float _484 = _t16; + float _485 = _484 + ((u_dither * (_f4(param_37, param_38) - 0.5)) / _442); + _t16 = _485; + float param_39 = _485; + vec2 param_40 = _326; + vec2 param_41 = _344; + vec2 param_42 = _363; + vec2 param_43 = _382; + vec2 param_44 = _401; + vec2 param_45 = _420; + vec2 _501 = _f3(param_39, param_40, param_41, param_42, param_43, param_44, param_45); + float _503 = step(u_mirrorEdge, 0.5); + vec2 param_46 = _501; + vec2 _513 = (_501 * _503) + (_f1(param_46) * (1.0 - _503)); + vec2 param_47 = _513; + _t14 += (texture2D(u_inputImageTexture, _513) * _f2(param_47)); + } + vec4 _526 = _t14; + vec4 _528 = _526 / vec4(_442); + _t14 = _528; + gl_FragData[0] = _528; +} + diff --git a/scripts/7681574644264045845/AmazingFeature/effects/LumiMotionBlur2D/shaderLib/shaderGLES/93ab10f0e935e0bc691355370bc4cc5d.vert b/scripts/7681574644264045845/AmazingFeature/effects/LumiMotionBlur2D/shaderLib/shaderGLES/93ab10f0e935e0bc691355370bc4cc5d.vert new file mode 100644 index 0000000000000000000000000000000000000000..6f2b17f0434964051cb3004b8be4c637742a6fe9 --- /dev/null +++ b/scripts/7681574644264045845/AmazingFeature/effects/LumiMotionBlur2D/shaderLib/shaderGLES/93ab10f0e935e0bc691355370bc4cc5d.vert @@ -0,0 +1,11 @@ + +attribute vec3 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = vec4(a_position, 1.0); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681574644264045845/AmazingFeature/effects/LumiMotionBlur2D/shaderLib/shaderMetal/93ab10f0e935e0bc691355370bc4cc5d.frag b/scripts/7681574644264045845/AmazingFeature/effects/LumiMotionBlur2D/shaderLib/shaderMetal/93ab10f0e935e0bc691355370bc4cc5d.frag new file mode 100644 index 0000000000000000000000000000000000000000..e2be9b1215be7570e295b1465464f7fe3ffd363a --- /dev/null +++ b/scripts/7681574644264045845/AmazingFeature/effects/LumiMotionBlur2D/shaderLib/shaderMetal/93ab10f0e935e0bc691355370bc4cc5d.frag @@ -0,0 +1,209 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + float4 u_ScreenParams; + int u_skipSample; + spvUnsafeArray u_rotationFloatVector; + spvUnsafeArray u_positionVec2Vector; + spvUnsafeArray u_pivotVec2Vector; + spvUnsafeArray u_scaleVec2Vector; + float u_mirrorEdge; + float u_minSamples; + float u_maxSamples; + float u_dither; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f0(thread float2& _p0, thread const float& _p1, thread const float2& _p2, thread const float2& _p3, thread const float2& _p4, constant float4& u_ScreenParams) +{ + _p0 -= _p2; + _p0 -= float2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _66 = sin(_p1); + float _69 = cos(_p1); + _p0 = float2x2(float2(_69, _66), float2(-_66, _69)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 *= (float2(1.0) / _p4); + _p0 += float2(0.5); + _p0 += _p3; + return _p0; +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float _f2(thread const float2& _p0) +{ + return ((step(0.0, _p0.x) * step(0.0, _p0.y)) * step(_p0.x, 1.0)) * step(_p0.y, 1.0); +} + +static inline __attribute__((always_inline)) +float _f4(thread const float& _p0, thread const float& _p1) +{ + float2 _218 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t3 = _218 + float2(dot(_218, _218.yx + float2(22.5410003662109375))); + return fract((_t3.x + _t3.y) * _t3.y); +} + +static inline __attribute__((always_inline)) +float2 _f3(thread const float& _p0, thread const float2& _p1, thread const float2& _p2, thread const float2& _p3, thread const float2& _p4, thread const float2& _p5, thread const float2& _p6) +{ + return ((((mix(_p1, _p2, float2(_p0 * 5.0)) * step(_p0, 0.20000000298023223876953125)) + ((mix(_p2, _p3, float2((_p0 * 5.0) - 1.0)) * (1.0 - step(_p0, 0.20000000298023223876953125))) * step(_p0, 0.4000000059604644775390625))) + ((mix(_p3, _p4, float2((_p0 * 5.0) - 2.0)) * (1.0 - step(_p0, 0.4000000059604644775390625))) * step(_p0, 0.60000002384185791015625))) + ((mix(_p4, _p5, float2((_p0 * 5.0) - 3.0)) * (1.0 - step(_p0, 0.60000002384185791015625))) * step(_p0, 0.800000011920928955078125))) + (mix(_p5, _p6, float2((_p0 * 5.0) - 4.0)) * (1.0 - step(_p0, 0.800000011920928955078125))); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputImageTexture [[texture(0)]], sampler u_inputImageTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + if (buffer.u_skipSample == 1) + { + float2 param = in.uv0; + float param_1 = (buffer.u_rotationFloatVector[0] * 3.141592502593994140625) / 180.0; + float2 param_2 = buffer.u_positionVec2Vector[0]; + float2 param_3 = buffer.u_pivotVec2Vector[0]; + float2 param_4 = buffer.u_scaleVec2Vector[0]; + float2 _281 = _f0(param, param_1, param_2, param_3, param_4, buffer.u_ScreenParams); + float _284 = step(buffer.u_mirrorEdge, 0.5); + float2 param_5 = _281; + float2 _294 = (_281 * _284) + (_f1(param_5) * (1.0 - _284)); + float2 param_6 = _294; + out.o_fragColor = u_inputImageTexture.sample(u_inputImageTextureSmplr, _294) * _f2(param_6); + return out; + } + float2 param_7 = in.uv0; + float param_8 = (buffer.u_rotationFloatVector[0] * 3.141592502593994140625) / 180.0; + float2 param_9 = buffer.u_positionVec2Vector[0]; + float2 param_10 = buffer.u_pivotVec2Vector[0]; + float2 param_11 = buffer.u_scaleVec2Vector[0]; + float2 _326 = _f0(param_7, param_8, param_9, param_10, param_11, buffer.u_ScreenParams); + float2 param_12 = in.uv0; + float param_13 = (buffer.u_rotationFloatVector[1] * 3.141592502593994140625) / 180.0; + float2 param_14 = buffer.u_positionVec2Vector[1]; + float2 param_15 = buffer.u_pivotVec2Vector[1]; + float2 param_16 = buffer.u_scaleVec2Vector[1]; + float2 _344 = _f0(param_12, param_13, param_14, param_15, param_16, buffer.u_ScreenParams); + float2 param_17 = in.uv0; + float param_18 = (buffer.u_rotationFloatVector[2] * 3.141592502593994140625) / 180.0; + float2 param_19 = buffer.u_positionVec2Vector[2]; + float2 param_20 = buffer.u_pivotVec2Vector[2]; + float2 param_21 = buffer.u_scaleVec2Vector[2]; + float2 _363 = _f0(param_17, param_18, param_19, param_20, param_21, buffer.u_ScreenParams); + float2 param_22 = in.uv0; + float param_23 = (buffer.u_rotationFloatVector[3] * 3.141592502593994140625) / 180.0; + float2 param_24 = buffer.u_positionVec2Vector[3]; + float2 param_25 = buffer.u_pivotVec2Vector[3]; + float2 param_26 = buffer.u_scaleVec2Vector[3]; + float2 _382 = _f0(param_22, param_23, param_24, param_25, param_26, buffer.u_ScreenParams); + float2 param_27 = in.uv0; + float param_28 = (buffer.u_rotationFloatVector[4] * 3.141592502593994140625) / 180.0; + float2 param_29 = buffer.u_positionVec2Vector[4]; + float2 param_30 = buffer.u_pivotVec2Vector[4]; + float2 param_31 = buffer.u_scaleVec2Vector[4]; + float2 _401 = _f0(param_27, param_28, param_29, param_30, param_31, buffer.u_ScreenParams); + float2 param_32 = in.uv0; + float param_33 = (buffer.u_rotationFloatVector[5] * 3.141592502593994140625) / 180.0; + float2 param_34 = buffer.u_positionVec2Vector[5]; + float2 param_35 = buffer.u_pivotVec2Vector[5]; + float2 param_36 = buffer.u_scaleVec2Vector[5]; + float2 _420 = _f0(param_32, param_33, param_34, param_35, param_36, buffer.u_ScreenParams); + float _424 = fast::max(buffer.u_minSamples, 2.0); + float _442 = floor(_424 + ((fast::max(buffer.u_maxSamples, _424) - _424) * smoothstep(0.0, 0.20000000298023223876953125, length(_420 - _326)))); + float4 _t14 = float4(0.0); + for (float _t15 = 0.0; _t15 <= 256.0; _t15 += 1.0) + { + if (_t15 >= _442) + { + break; + } + float _t16 = _t15 / (_442 - 1.0); + float param_37 = _t15 + in.uv0.x; + float param_38 = _t15 * in.uv0.y; + float _484 = _t16; + float _485 = _484 + ((buffer.u_dither * (_f4(param_37, param_38) - 0.5)) / _442); + _t16 = _485; + float param_39 = _485; + float2 param_40 = _326; + float2 param_41 = _344; + float2 param_42 = _363; + float2 param_43 = _382; + float2 param_44 = _401; + float2 param_45 = _420; + float2 _501 = _f3(param_39, param_40, param_41, param_42, param_43, param_44, param_45); + float _503 = step(buffer.u_mirrorEdge, 0.5); + float2 param_46 = _501; + float2 _513 = (_501 * _503) + (_f1(param_46) * (1.0 - _503)); + float2 param_47 = _513; + _t14 += (u_inputImageTexture.sample(u_inputImageTextureSmplr, _513) * _f2(param_47)); + } + float4 _526 = _t14; + float4 _528 = _526 / float4(_442); + _t14 = _528; + out.o_fragColor = _528; + return out; +} + diff --git a/scripts/7681574644264045845/AmazingFeature/effects/LumiMotionBlur2D/shaderLib/shaderMetal/93ab10f0e935e0bc691355370bc4cc5d.vert b/scripts/7681574644264045845/AmazingFeature/effects/LumiMotionBlur2D/shaderLib/shaderMetal/93ab10f0e935e0bc691355370bc4cc5d.vert new file mode 100644 index 0000000000000000000000000000000000000000..025cf392753da0f3945510ac9a3bf1cc3e8b2a6d --- /dev/null +++ b/scripts/7681574644264045845/AmazingFeature/effects/LumiMotionBlur2D/shaderLib/shaderMetal/93ab10f0e935e0bc691355370bc4cc5d.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float3 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = float4(in.a_position, 1.0); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681574644264045845/AmazingFeature/lua/LumiFamily/AETools.lua b/scripts/7681574644264045845/AmazingFeature/lua/LumiFamily/AETools.lua new file mode 100644 index 0000000000000000000000000000000000000000..07ad317cd97ebb4ef6a4b329cdda5e775c5c2b2c --- /dev/null +++ b/scripts/7681574644264045845/AmazingFeature/lua/LumiFamily/AETools.lua @@ -0,0 +1,273 @@ +local AETools = AETools or {} +AETools.__index = AETools + +-- AE PropertyValueType +local ThreeD_SPATIAL = 6413 +local ThreeD = 6414 +local TwoD_SPATIAL = 6415 +local TwoD = 6416 +local OneD = 6417 + +local function deepcopy(orig) + local copy + if type(orig) == "table" then + copy = {} + for orig_key, orig_value in next, orig, nil do + copy[deepcopy(orig_key)] = deepcopy(orig_value) + end + -- setmetatable(copy, deepcopy(getmetatable(orig))) + else + copy = orig + end + return copy +end + +function AETools.new(attrs) + if attrs == nil then return nil end + + local self = setmetatable({}, AETools) + self.attrs = attrs + + local max_frame = 0 + local min_frame = 100000 + for _,v in pairs(attrs) do + for i = 1, #v do + local content = v[i] + local cur_frame_min = content[2][1] + local cur_frame_max = content[2][2] + max_frame = math.max(cur_frame_max, max_frame) + min_frame = math.min(cur_frame_min, min_frame) + + if content[4] ~= nil + and content[5] ~= nil + and (content[4][1] == ThreeD_SPATIAL or content[4][1] == TwoD_SPATIAL) + and content[5][1] == 0 + then + local p0 = content[3][1] + local totalLen = 0 + local lenInfo = {} + lenInfo[0] = 0 + for test=1,200,1 do + local coord = self._cubicBezier3D(content[3][1], content[3][3], content[3][4], content[3][2], test/200) + local length = 0 + if #p0 >= 3 then + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])+(coord[3]-p0[3])*(coord[3]-p0[3])) + else + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])) + end + p0 = coord + totalLen = totalLen + length + lenInfo[test] = totalLen + -- print(test/200 .. " coord: "..coord[1].." - "..coord[2]) + end + for test=1,200,1 do + lenInfo[test] = lenInfo[test]/(lenInfo[200]+0.000001) + -- print(test/200 .. " "..lenInfo[test]) + end + content['lenInfo'] = lenInfo + end + end + end + + self.all_frame = max_frame - min_frame + self.min_frame = min_frame + + return self +end + +function AETools:CurFrame(_p) + local frame = math.floor(_p*self.all_frame) + return frame + self.min_frame +end + +function AETools:AllFrame(_p) + return self.all_frame +end + +function AETools._remap01(a,b,x) + if x < a then return 0 end + if x > b then return 1 end + return (x-a)/(b-a) +end + +function AETools._cubicBezier(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + return { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + } +end + +function AETools._cubicBezier3D(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + local value = { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + 0, + } + if #p1 >= 3 then + value[3] = p1[3] * _t3 + 3 * p2[3] * _t2 * t + 3 * p3[3] * _t * t2 + p4[3] * t3 + end + return value +end + +function AETools:_cubicBezierSpatial(lenInfo, p1, p2, p3, p4, t) + local p = 0 + if t <= 0 then + p = 0 + elseif t >= 1 then + p = 1 + else + local ts = 199 + local te = 200 + for i=1,200,1 do + if lenInfo[i] >= t then + te = i + ts = i-1 + break + end + end + p = ts/200. + 0.005*(t-lenInfo[ts])/(lenInfo[te]-lenInfo[ts]+0.000001) + end + return self._cubicBezier3D(p1, p2, p3, p4, p) +end + +function AETools:_cubicBezier01(_bezier_val, p, y_len) + local x = self:_getBezier01X(_bezier_val, p, y_len) + return self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + x + )[2] +end + +function AETools:AllFrame() + return self.all_frame +end + +function AETools:_getBezier01X(_bezier_val, x, y_len) + local ts = 0 + local te = 1 + -- divide and conque + local times = 1 + repeat + local tm = (ts+te)*0.5 + local value = self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + tm) + if(value[1]>x) then + te = tm + else + ts = tm + end + times = times +1 + until(te-ts < 0.001 and times < 50) + + return (te+ts)*0.5 +end + +function AETools._mix(a, b, x, type) + if type == 1 then + return a * (1-x) + b * x + end + return a + x +end + +function AETools:GetVal(_name, _progress) + local content = self.attrs[_name] + if content == nil then + return nil + end + + -- local cur_frame = _progress * self.all_frame + self.min_frame + local cur_frame = _progress + + for i = 1, #content do + local info = content[i] + local start_frame = info[2][1] + local end_frame = info[2][2] + if cur_frame >= start_frame and cur_frame < end_frame then + local cur_progress = self._remap01(start_frame, end_frame, cur_frame) + local bezier = info[1] + local value_range = info[3] + local y_len = 1 + if (value_range[2][1] == value_range[1][1] and info[5] and info[5][1]==0 and #(value_range[1])==1) then + y_len = 0 + end + + if info[5] and info[5][1] == 2 then + return deepcopy(info[3][1]) + end + + if #bezier > 4 then + -- currently scale attrs contains more than 4 bezier values + local res = {} + for k = 1, 3 do + local cur_bezier = {bezier[k], bezier[k+3], bezier[k+3*2], bezier[k+3*3]} + local p = self:_cubicBezier01(cur_bezier, cur_progress, y_len) + res[k] = self._mix(value_range[1][k], value_range[2][k], p, y_len) + end + return res + + else + local p = self:_cubicBezier01(bezier, cur_progress, y_len) + if info[4] ~= nil + and info[5] ~= nil + and (info[4][1] == ThreeD_SPATIAL or info[4][1] == TwoD_SPATIAL) + and info[5][1] == 0 + then + local coord = self:_cubicBezierSpatial( + info['lenInfo'], + value_range[1], + value_range[3], + value_range[4], + value_range[2], + p + ) + if info[4][1] == TwoD_SPATIAL then + return {coord[1], coord[2]} + end + return coord + end + + if type(value_range[1]) == "table" then + local res = {} + for j = 1, #value_range[1] do + res[j] = self._mix(value_range[1][j], value_range[2][j], p, y_len) + end + return res + end + return self._mix(value_range[1], value_range[2], p, y_len) + end + end + end + + local first_info = content[1] + local start_frame = first_info[2][1] + if cur_frame=end_frame then + return deepcopy(last_info[3][2]) + end + + return nil +end + +return AETools diff --git a/scripts/7681574644264045845/AmazingFeature/lua/LumiFamily/LumiEffect.lua b/scripts/7681574644264045845/AmazingFeature/lua/LumiFamily/LumiEffect.lua new file mode 100644 index 0000000000000000000000000000000000000000..bee4c14190a8231d06c80826ceaa131067ca8ad2 --- /dev/null +++ b/scripts/7681574644264045845/AmazingFeature/lua/LumiFamily/LumiEffect.lua @@ -0,0 +1,32 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiEffect = LumiEffect or {} +LumiEffect.__index = LumiEffect +---@class LumiEffect : ScriptComponent + +function LumiEffect.new(construct, ...) + local self = setmetatable({}, LumiEffect) + + self.__lumi_type = "lumi_effect" + self.__lumi_rt_pingpong_type = "custom" + + return self +end + +function LumiEffect:constructor() +end + +function LumiEffect:onStart(comp) +end + +function LumiEffect:onDestroy(comp) +end + +function LumiEffect:updateMaterials(comp, deltaTime) +end + +function LumiEffect:onUpdate(comp, deltaTime) +end + +exports.LumiEffect = LumiEffect +return exports diff --git a/scripts/7681574644264045845/AmazingFeature/lua/LumiFamily/LumiExportData.lua b/scripts/7681574644264045845/AmazingFeature/lua/LumiFamily/LumiExportData.lua new file mode 100644 index 0000000000000000000000000000000000000000..e98778745129e68c1e8b9c4b0e3fad5f2a646936 --- /dev/null +++ b/scripts/7681574644264045845/AmazingFeature/lua/LumiFamily/LumiExportData.lua @@ -0,0 +1,467 @@ +local data = {} + +local ae_compDurations = {0, 2} +data.ae_compDurations = ae_compDurations + +local ae_effectType = 'transition' +data.ae_effectType = ae_effectType + +local ae_transitionInputIndex = { + {'LumiMotionBlur2D_8147-effect0', 'InputTex', 1}, + {'LumiLayer_8148-trs', 'InputTex', 0}, +} +data.ae_transitionInputIndex = ae_transitionInputIndex + +local ae_durations = { + ['LumiMotionBlur2D_8147-effect0'] = { + ['nodeDuration'] = {{0, 2.03333333333333}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2.03333333333333}, }, + }, + }, + ['LumiLayer_8148-trs'] = { + ['nodeDuration'] = {{0, 2.03333333333333}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2.03333333333333}, }, + }, + }, + ['LumiAnimSeqLoadAndCrop_8156-effect0'] = { + ['nodeDuration'] = {{0, 2.03333333333333}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2.03333333333333}, }, + ['seqTex_1_1'] = {{0, 2.03333333333333}, }, + }, + }, + ['LumiLayer_8147-matte-blend'] = { + ['nodeDuration'] = {{0, 2.03333333333333}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2.03333333333333}, }, + ['baseTex'] = {{0, 2.03333333333333}, }, + ['maskTex'] = {{0, 2.03333333333333}, }, + }, + }, + ['LumiAnimSeqLoadAndCrop_8154-effect0'] = { + ['nodeDuration'] = {{0, 2.03333333333333}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2.03333333333333}, }, + ['seqTex_1_1'] = {{0, 2.03333333333333}, }, + }, + }, + ['LumiLayer_8154-blend'] = { + ['nodeDuration'] = {{0, 2.03333333333333}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2.03333333333333}, }, + ['baseTex'] = {{0, 2.03333333333333}, }, + }, + }, +} +data.ae_durations = ae_durations + +local ae_attribute = { + ['LumiMotionBlur2D_8147-effect0'] = { + ['rotate'] = 0, + ['ae_pre_rotate'] = 0, + ['anchor'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_anchor'] = Amaz.Vector2f(0.5, 0.5), + ['position'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position'] = Amaz.Vector2f(0.5, 0.5), + ['unifiedScale'] = true, + ['scale_x'] = 0.5, + ['ae_pre_scale_x'] = 0.5, + ['scale_y'] = 1, + ['ae_pre_scale_y'] = 1, + ['vIntensity'] = 0.5, + ['vCenter'] = -0.25, + ['minSamples'] = 0.12, + ['maxSamples'] = 0.24, + ['mirrorEdge'] = true, + ['dither'] = 1, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiLayer_8148-trs'] = { + ['hasBlend'] = false, + ['hasMatte'] = false, + ['hasTransform'] = true, + ['layerType'] = 'Precomp', + ['anchorPoint'] = Amaz.Vector3f(540, 540, 0), + ['position'] = Amaz.Vector3f(540, 540, 0), + ['scale'] = Amaz.Vector3f(100, 100, 100), + ['orientation'] = Amaz.Vector3f(0, 0, 0), + ['xRotation'] = 0, + ['yRotation'] = 0, + ['rotation'] = 0, + ['opacity'] = 100, + ['active_cam_fovx'] = 39.6, + ['compositeSize'] = Amaz.Vector2f(1080, 1080), + ['layerSize'] = Amaz.Vector2f(1080, 1080), + ['mirrorEdge'] = false, + }, + ['LumiAnimSeqLoadAndCrop_8156-effect0'] = { + ['specify_1_1'] = true, + ['animSeqType_1_1'] = 0, + ['cropType_1_1'] = 1, + ['edgeType_1_1'] = 3, + ['enableVideoAlphaBlend_1_1'] = true, + ['pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1_1'] = 0, + ['scale_1_1'] = 1, + ['opacity_1_1'] = 1, + ['speed_1_1'] = 1, + ['playMode_1_1'] = 0, + ['specify_9_16'] = false, + ['animSeqType_9_16'] = 2, + ['cropType_9_16'] = 1, + ['edgeType_9_16'] = 0, + ['enableVideoAlphaBlend_9_16'] = false, + ['pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_9_16'] = 0, + ['scale_9_16'] = 1, + ['opacity_9_16'] = 1, + ['speed_9_16'] = 1, + ['playMode_9_16'] = 0, + ['specify_16_9'] = false, + ['animSeqType_16_9'] = 2, + ['cropType_16_9'] = 1, + ['edgeType_16_9'] = 0, + ['enableVideoAlphaBlend_16_9'] = false, + ['pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_16_9'] = 0, + ['scale_16_9'] = 1, + ['opacity_16_9'] = 1, + ['speed_16_9'] = 1, + ['playMode_16_9'] = 0, + ['specify_5.8'] = false, + ['animSeqType_5.8'] = 2, + ['cropType_5.8'] = 1, + ['edgeType_5.8'] = 0, + ['enableVideoAlphaBlend_5.8'] = false, + ['pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_5.8'] = 0, + ['scale_5.8'] = 1, + ['opacity_5.8'] = 1, + ['speed_5.8'] = 1, + ['playMode_5.8'] = 0, + ['specify_2_1'] = false, + ['animSeqType_2_1'] = 2, + ['cropType_2_1'] = 1, + ['edgeType_2_1'] = 0, + ['enableVideoAlphaBlend_2_1'] = false, + ['pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2_1'] = 0, + ['scale_2_1'] = 1, + ['opacity_2_1'] = 1, + ['speed_2_1'] = 1, + ['playMode_2_1'] = 0, + ['specify_3_4'] = false, + ['animSeqType_3_4'] = 2, + ['cropType_3_4'] = 1, + ['edgeType_3_4'] = 0, + ['enableVideoAlphaBlend_3_4'] = false, + ['pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_3_4'] = 0, + ['scale_3_4'] = 1, + ['opacity_3_4'] = 1, + ['speed_3_4'] = 1, + ['playMode_3_4'] = 0, + ['specify_4_3'] = false, + ['animSeqType_4_3'] = 2, + ['cropType_4_3'] = 1, + ['edgeType_4_3'] = 0, + ['enableVideoAlphaBlend_4_3'] = false, + ['pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_4_3'] = 0, + ['scale_4_3'] = 1, + ['opacity_4_3'] = 1, + ['speed_4_3'] = 1, + ['playMode_4_3'] = 0, + ['specify_1.85_1'] = false, + ['animSeqType_1.85_1'] = 2, + ['cropType_1.85_1'] = 1, + ['edgeType_1.85_1'] = 0, + ['enableVideoAlphaBlend_1.85_1'] = false, + ['pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1.85_1'] = 0, + ['scale_1.85_1'] = 1, + ['opacity_1.85_1'] = 1, + ['speed_1.85_1'] = 1, + ['playMode_1.85_1'] = 0, + ['specify_2.35_1'] = false, + ['animSeqType_2.35_1'] = 2, + ['cropType_2.35_1'] = 1, + ['edgeType_2.35_1'] = 0, + ['enableVideoAlphaBlend_2.35_1'] = false, + ['pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2.35_1'] = 0, + ['scale_2.35_1'] = 1, + ['opacity_2.35_1'] = 1, + ['speed_2.35_1'] = 1, + ['playMode_2.35_1'] = 0, + ['globalRotation'] = 0, + ['globalScale'] = 1, + ['globalOpacity'] = 1, + ['globalSpeed'] = 1, + ['lite_mode'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiLayer_8147-matte-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = true, + ['hasTransform'] = false, + ['layerType'] = 'Precomp', + ['matteMode'] = 0, + ['blendMode'] = 0, + }, + ['LumiAnimSeqLoadAndCrop_8154-effect0'] = { + ['specify_1_1'] = true, + ['animSeqType_1_1'] = 0, + ['cropType_1_1'] = 1, + ['edgeType_1_1'] = 3, + ['enableVideoAlphaBlend_1_1'] = true, + ['pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1_1'] = 0, + ['scale_1_1'] = 1, + ['opacity_1_1'] = 1, + ['speed_1_1'] = 1, + ['playMode_1_1'] = 0, + ['specify_9_16'] = false, + ['animSeqType_9_16'] = 2, + ['cropType_9_16'] = 1, + ['edgeType_9_16'] = 0, + ['enableVideoAlphaBlend_9_16'] = false, + ['pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_9_16'] = 0, + ['scale_9_16'] = 1, + ['opacity_9_16'] = 1, + ['speed_9_16'] = 1, + ['playMode_9_16'] = 0, + ['specify_16_9'] = false, + ['animSeqType_16_9'] = 2, + ['cropType_16_9'] = 1, + ['edgeType_16_9'] = 0, + ['enableVideoAlphaBlend_16_9'] = false, + ['pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_16_9'] = 0, + ['scale_16_9'] = 1, + ['opacity_16_9'] = 1, + ['speed_16_9'] = 1, + ['playMode_16_9'] = 0, + ['specify_5.8'] = false, + ['animSeqType_5.8'] = 2, + ['cropType_5.8'] = 1, + ['edgeType_5.8'] = 0, + ['enableVideoAlphaBlend_5.8'] = false, + ['pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_5.8'] = 0, + ['scale_5.8'] = 1, + ['opacity_5.8'] = 1, + ['speed_5.8'] = 1, + ['playMode_5.8'] = 0, + ['specify_2_1'] = false, + ['animSeqType_2_1'] = 2, + ['cropType_2_1'] = 1, + ['edgeType_2_1'] = 0, + ['enableVideoAlphaBlend_2_1'] = false, + ['pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2_1'] = 0, + ['scale_2_1'] = 1, + ['opacity_2_1'] = 1, + ['speed_2_1'] = 1, + ['playMode_2_1'] = 0, + ['specify_3_4'] = false, + ['animSeqType_3_4'] = 2, + ['cropType_3_4'] = 1, + ['edgeType_3_4'] = 0, + ['enableVideoAlphaBlend_3_4'] = false, + ['pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_3_4'] = 0, + ['scale_3_4'] = 1, + ['opacity_3_4'] = 1, + ['speed_3_4'] = 1, + ['playMode_3_4'] = 0, + ['specify_4_3'] = false, + ['animSeqType_4_3'] = 2, + ['cropType_4_3'] = 1, + ['edgeType_4_3'] = 0, + ['enableVideoAlphaBlend_4_3'] = false, + ['pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_4_3'] = 0, + ['scale_4_3'] = 1, + ['opacity_4_3'] = 1, + ['speed_4_3'] = 1, + ['playMode_4_3'] = 0, + ['specify_1.85_1'] = false, + ['animSeqType_1.85_1'] = 2, + ['cropType_1.85_1'] = 1, + ['edgeType_1.85_1'] = 0, + ['enableVideoAlphaBlend_1.85_1'] = false, + ['pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1.85_1'] = 0, + ['scale_1.85_1'] = 1, + ['opacity_1.85_1'] = 1, + ['speed_1.85_1'] = 1, + ['playMode_1.85_1'] = 0, + ['specify_2.35_1'] = false, + ['animSeqType_2.35_1'] = 2, + ['cropType_2.35_1'] = 1, + ['edgeType_2.35_1'] = 0, + ['enableVideoAlphaBlend_2.35_1'] = false, + ['pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2.35_1'] = 0, + ['scale_2.35_1'] = 1, + ['opacity_2.35_1'] = 1, + ['speed_2.35_1'] = 1, + ['playMode_2.35_1'] = 0, + ['globalRotation'] = 0, + ['globalScale'] = 1, + ['globalOpacity'] = 1, + ['globalSpeed'] = 1, + ['lite_mode'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiLayer_8154-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = false, + ['layerType'] = 'Solid', + ['blendMode'] = 0, + }, +} +data.ae_attribute = ae_attribute + +local ae_keyframes = { + ['LumiMotionBlur2D_8147-effect0#ae_pre_scale_x#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0.03333333333333, 2.03333333333333, }, + {{0.5, }, {1, }, }, + {6417, }, + {1, }, + }, +}, + ['LumiMotionBlur2D_8147-effect0#scale_x#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 2, }, + {{0.5, }, {1, }, }, + {6417, }, + {1, }, + }, +}, + ['LumiLayer_8148-trs#scale#vector'] = +{ + { + {0.166666667,0.166666667,0.166666667, 0.166666667,0.166666667,0.166666667, 0.833333333,0.833333333,0.833333333, 0.833333333,0.833333333,0.833333333, }, + {0, 2, }, + {{100, 100, 100, }, {130, 130, 100, }, }, + {6414, }, + {1, }, + }, +}, + ['LumiAnimSeqLoadAndCrop_8156-effect0#seqTime#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 2.03333333333333, }, + {{0, }, {2.03333333333333, }, }, + {6417, }, + {1, }, + }, +}, + ['LumiAnimSeqLoadAndCrop_8154-effect0#seqTime#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 2.03333333333333, }, + {{0, }, {2.03333333333333, }, }, + {6417, }, + {1, }, + }, +}, +} +data.ae_keyframes = ae_keyframes + +local ae_reverseKeyframes = false +data.ae_reverseKeyframes = ae_reverseKeyframes + +local ae_sliderInfos = { +} +data.ae_sliderInfos = ae_sliderInfos + +local ae_fadeinInfos = { + time = 0, + infos = { + } +} +data.ae_fadeinInfos = ae_fadeinInfos + +local ae_fadeoutInfos = { + time = 0, + infos = { + } +} +data.ae_fadeoutInfos = ae_fadeoutInfos + +local ae_animationInfos = { + animationMode = 0, + loopStart = 0, + speedInfo = {1, 0, 1, }, +} +data.ae_animationInfos = ae_animationInfos + +return data diff --git a/scripts/7681574644264045845/AmazingFeature/lua/LumiFamily/LumiManager.lua b/scripts/7681574644264045845/AmazingFeature/lua/LumiFamily/LumiManager.lua new file mode 100644 index 0000000000000000000000000000000000000000..7a07ee24e9b82500e89114ce8cb3a85474915e38 --- /dev/null +++ b/scripts/7681574644264045845/AmazingFeature/lua/LumiFamily/LumiManager.lua @@ -0,0 +1,554 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiManager = LumiManager or {} +LumiManager.__index = LumiManager +---@class LumiManager : ScriptComponent +---@field debugTime number [UI(Range={0, 6}, Drag)] +---@field autoPlay boolean +---@field lumiEffectRoot Transform +---@field start_render_layer int +---@field start_render_order int + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local EffectType = { + Effect = 'effect', + Transition = 'transition', + VideoAnimation = 'videoAnimation', + EffectXT = 'xtEffect', + FilterXT = 'xtFilter', +} + +local AnimationMode = { + Once = 0, + Loop = 1, + StretchOnce = 2, + StretchLoop = 3, +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +local function remap(value, srcMin, srcMax, dstMin, dstMax) + return dstMin + (value - srcMin) * (dstMax - dstMin) / (srcMax - srcMin) +end + +local function handleAllEntityBySingleParent(_trans, func, ...) + if _trans.children:size() > 0 then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i - 1) + handleAllEntityBySingleParent(child, func, ...) + end + end + func(_trans, ...) +end + +local function intervalIntersection(intervals1, intervals2) + local result = {} + local i = 1 + local j = 1 + + while i <= #intervals1 and j <= #intervals2 do + local start1 = intervals1[i][1] + local end1 = intervals1[i][2] + local start2 = intervals2[j][1] + local end2 = intervals2[j][2] + + local start = math.max(start1, start2) + local end_ = math.min(end1, end2) + + if start <= end_ then + table.insert(result, {start, end_}) + end + if end1 < end2 then + i = i + 1 + else + j = j + 1 + end + end + return result +end + +function LumiManager.new(construct, ...) + local self = setmetatable({}, LumiManager) + + self.lumiEffectRoot = nil + self.start_render_layer = 1 + self.start_render_order = 1 + + self.InputTex = nil + self.OutputTex = nil + self.PingPongTex = nil + + self.startTime = 0.0 + self.endTime = 6.0 + self.curTime = 0.0 + + self.speed = 1.0 + self.animationMode = AnimationMode.Once + self.autoPlay = true + self.debugTime = 0.0 + + -- for XT + self.cameraStartTime = 0 + self.lastCycle = -1 + + return self +end + +function LumiManager:getKeyframeAeTime(aeTime) + if self.isReverseKeyframes ~= true then + return aeTime + end + return self.compDurations[1] + self.compDurations[2] - aeTime +end + +function LumiManager:onStart(comp) + self.entity = comp.entity + + self.lumi_obj_extension = includeRelativePath("LumiObjectExtension") + self.lumi_obj = nil + + self.keyframes = nil + self.durations = nil + self.params = nil + self.compDurations = {0, 6} + self.animationInfos = 0 + self.sliderInfos = {} + self.fadeinInfos = {} + self.fadeoutInfos = {} + self.effectType = "effect" + self.transitionInputIndex = {} + + self.LumiParamsSetter = includeRelativePath("LumiParamsSetter") + local ae_export_data = includeRelativePath("LumiExportData") + if ae_export_data then + if ae_export_data.ae_keyframes then + local ae_tools = includeRelativePath("AETools") + if ae_tools then + self.keyframes = ae_tools.new(ae_export_data.ae_keyframes) + end + end + if ae_export_data.ae_reverseKeyframes ~= nil then + self.isReverseKeyframes = ae_export_data.ae_reverseKeyframes + end + if ae_export_data.ae_durations ~= nil then + self.durations = ae_export_data.ae_durations + end + if ae_export_data.ae_attribute ~= nil then + self.params = ae_export_data.ae_attribute + end + if ae_export_data.ae_compDurations ~= nil then + self.compDurations = ae_export_data.ae_compDurations + self.compDurations[2] = self.compDurations[2] + end + if ae_export_data.ae_animationInfos ~= nil then + self.animationInfos = ae_export_data.ae_animationInfos + self.animationMode = self.animationInfos.animationMode + self.loopStart = self.animationInfos.loopStart + self.speed = self.animationInfos.speedInfo[1] + end + if ae_export_data.ae_sliderInfos ~= nil then + self.sliderInfos = ae_export_data.ae_sliderInfos + end + if ae_export_data.ae_fadeinInfos ~= nil then + self.fadeinInfos = ae_export_data.ae_fadeinInfos + end + if ae_export_data.ae_fadeoutInfos ~= nil then + self.fadeoutInfos = ae_export_data.ae_fadeoutInfos + end + if ae_export_data.ae_effectType ~= nil then + self.effectType = ae_export_data.ae_effectType + end + if ae_export_data.ae_cameraMode ~= nil then + self.cameraMode = ae_export_data.ae_cameraMode + end + if ae_export_data.ae_transitionInputIndex ~= nil then + self.transitionInputIndex = ae_export_data.ae_transitionInputIndex + end + end + if self.LumiParamsSetter then + self.lumi_params_setter = self.LumiParamsSetter.new( + self, + self.params, + self.keyframes, + self.effectType, + self.sliderInfos, + self.fadeinInfos, + self.fadeoutInfos + ) + end + + if self.effectType == EffectType.VideoAnimation then + local baseEntity = self.entity:searchEntity('base') + local videoCamera = baseEntity:searchEntity('videoCamera'):getComponent('Camera') + local videoRenderer = baseEntity:searchEntity('video'):getComponent('MeshRenderer') + local modelCamera = baseEntity:searchEntity('modelCamera'):getComponent('Camera') + local modelRenderer = baseEntity:searchEntity('model'):searchEntity('quad'):getComponent('MeshRenderer') + local fxaaCamera = baseEntity:searchEntity('fxaaCamera'):getComponent('Camera') + local fxaaRenderer = baseEntity:searchEntity('fxaa'):getComponent('MeshRenderer') + local bgCamera = baseEntity:searchEntity('bgCamera'):getComponent('Camera') + local bgRenderer = baseEntity:searchEntity('bg'):getComponent('MeshRenderer') + local blendCamera = baseEntity:searchEntity('blendCamera'):getComponent('Camera') + local blendRenderer = baseEntity:searchEntity('blend'):getComponent('MeshRenderer') + self.videoAnimationCameraAndRenderer = { + { camera = videoCamera, renderer = videoRenderer }, + { camera = modelCamera, renderer = modelRenderer }, + { camera = fxaaCamera, renderer = fxaaRenderer }, + { camera = bgCamera, renderer = bgRenderer }, + { camera = blendCamera, renderer = blendRenderer }, + } + end +end + +function LumiManager:onDestroy(comp) + if self.lumiEffectRoot and self.lumi_obj_extension then + self.lumi_obj_extension.deregister(self.lumiEffectRoot.entity) + end + self.lumi_obj = nil + self.LumiParamsSetter = nil +end + +function LumiManager:getCameraCount() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return 0 + end + + self.lumi_obj = nil + self:ReRender() + + local cam_count = 0 + if self.lumi_obj then + cam_count = self.lumi_obj:getCameraCount() + Amaz.LOGI(AE_EFFECT_TAG, self.lumi_obj.entity.name .. " camera_count: " .. tostring(cam_count)) + end + return cam_count +end + +function LumiManager:ReRender() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + -- re register + self.lumi_obj = nil + self:registerLumiObj(self.lumiEffectRoot, 1) + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'No lumi_obj register') + return + end + + -- change layer & order + self:updateCameraLayerAndOrder() + + -- change rt pingpong + self:updateRtPingpong() +end + +function LumiManager:registerLumiObj(_trans, _idx) + if _trans == nil then return end + local script_comp = _trans.entity:getComponent("ScriptComponent") + if script_comp then + local lua_obj = Amaz.ScriptUtils.getLuaObj(script_comp:getScript()) + if lua_obj then + self.lumi_obj_extension.deregister(_trans.entity) + self.lumi_obj = self.lumi_obj_extension.register(_trans.entity) + end + end +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str .. "0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiManager:updateCameraLayerAndOrder() + if self.lumi_obj then + local cur_start_layer, cur_start_order = self.lumi_obj:updateCameraLayerAndOrder(self.start_render_layer, self.start_render_order) + + if self.effectType == EffectType.VideoAnimation then + cur_start_layer = cur_start_layer + 10 + cur_start_order = cur_start_order + 10 + + for i = 1, #self.videoAnimationCameraAndRenderer do + local cameraAndRenderer = self.videoAnimationCameraAndRenderer[i] + local camera = cameraAndRenderer.camera + local renderer = cameraAndRenderer.renderer + camera.renderOrder = cur_start_order + _setLayer(camera, cur_start_layer) + renderer.entity.layer = cur_start_layer + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end +end + +function LumiManager:updateRtPingpong() + if self.lumi_obj then + self.lumi_obj:updateRt(self.InputTex, self.OutputTex, self.PingPongTex) + end +end + +function LumiManager:updateOutputRtSize() + if self.lumi_obj then + self.lumi_obj:updateOutputRtSize(self.width, self.height) + end +end + +function LumiManager:initVideoAnimationLua(comp) + local modelEntity = comp.entity:searchEntity("model") + if modelEntity then + local scriptComp = modelEntity:getComponent("ScriptComponent") + if scriptComp then + self.videoAnimationLua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + end + end +end + +function LumiManager:onUpdate(comp, deltaTime) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.durations and not self.isSetDuration then + for entityName, durationMap in pairs(self.durations) do + local isLumiLayer = string.sub(entityName, 1, string.len('LumiLayer')) == 'LumiLayer' + if isLumiLayer then + local texDuration = durationMap['texDuration'] + local srcDuration = texDuration['InputTex'] + local baseDuration = texDuration['baseTex'] + local maskDuration = texDuration['maskTex'] + if srcDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'srcDuration', srcDuration) + end + if baseDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'baseDuration', baseDuration) + end + if maskDuration then + local matteDuration = intervalIntersection(maskDuration, srcDuration) + self.lumi_obj:setSubEffectAttr(entityName, 'matteDuration', matteDuration) + end + end + end + self.isSetDuration = true + end + + local w = Amaz.BuiltinObject.getInputTextureWidth() + local h = Amaz.BuiltinObject.getInputTextureHeight() + if self.InputTex then + w = self.InputTex.width + h = self.InputTex.height + end + if self.OutputTex and (self.OutputTex.width ~= w or self.OutputTex.height ~= h) then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid rt size, input: ' .. w .. 'x' .. h .. ', output: ' .. self.OutputTex.width .. 'x' .. self.OutputTex.height) + end + if self.width == nil or self.width ~= w or self.height == nil or self.height ~= h then + self.width = w + self.height = h + self:updateOutputRtSize() + end + + self.curTime = self.curTime + deltaTime + if isEditor then + self.curTime = self.curTime % self.endTime + end + local curTime = (self.curTime - self.startTime) * self.speed + self.startTime + local startTime = self.startTime + local endTime = (self.endTime - self.startTime) * self.speed + self.startTime + + if self.cameraMode then + if self.animationMode ~= AnimationMode.Loop then + Amaz.LOGE(AE_EFFECT_TAG, 'Camera mode is not support animationMode: ' .. tostring(self.animationMode)) + return + end + curTime = self.curTime - self.cameraStartTime + endTime = math.huge + elseif self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT then -- deprecated after 1810 in XT + startTime = 0 + if self.isVideo == 1 then + endTime = self.videoTime + else + curTime = 0 + endTime = 3 + end + end + + local aeTime = curTime; + local aeDuration = math.max(0.001, self.compDurations[2] - self.compDurations[1]) + if endTime < curTime then + aeTime = math.max(self.compDurations[1], self.compDurations[2] - (self.endTime - self.curTime)) + else + local lvDuration = math.max(0.001, endTime - startTime) + if self.animationMode == AnimationMode.Once then + aeTime = self.compDurations[1] + curTime - startTime + aeTime = math.min(aeTime, self.compDurations[2]) + elseif self.animationMode == AnimationMode.Loop then + if self.cameraMode then + local cycle = math.floor((curTime - startTime) / aeDuration) + if self.lastCycle ~= cycle then + self.lastCycle = cycle + comp.entity.scene:sendMessage(4999, 1, 0, '') + end + end + if math.floor((curTime - startTime) / aeDuration) < 1 then + aeTime = self.compDurations[1] + (curTime - startTime) % aeDuration + else + local curLoopStart = (self.loopStart - self.compDurations[1]) * self.speed + self.compDurations[1] + aeTime = self.loopStart + (curTime - startTime - curLoopStart) % (aeDuration - self.loopStart) + end + elseif self.animationMode == AnimationMode.StretchOnce then + aeTime = remap(curTime, startTime, self.endTime, self.compDurations[1], self.compDurations[2]) + aeTime = clamp(aeTime, self.compDurations[1], self.compDurations[2]) + elseif self.animationMode == AnimationMode.StretchLoop then + local newCurTime = startTime + (curTime - startTime) * self.speed % lvDuration + aeTime = remap(newCurTime, startTime, endTime, self.compDurations[1], self.compDurations[2]) + + if math.floor((curTime - startTime) * self.speed / lvDuration) >= 1 then + aeTime = self.compDurations[1] + (aeTime - self.compDurations[1]) % (self.compDurations[2] - self.loopStart) + self.loopStart + end + end + end + + if self.effectType == EffectType.Transition then + local input1 = Amaz.BuiltinObject.getUserTexture("#TransitionInput0") + local input2 = Amaz.BuiltinObject.getUserTexture("#TransitionInput1") + if input1 and input2 then + for index, transitionInputInfo in ipairs(self.transitionInputIndex) do + local entityName = transitionInputInfo[1] + local texName = transitionInputInfo[2] + local inputIndex = transitionInputInfo[3] + if inputIndex == 0 then + self.lumi_obj:setSubEffectAttr(entityName, texName, input1) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 0) + else + self.lumi_obj:setSubEffectAttr(entityName, texName, input2) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 1) + end + end + aeTime = Amaz.Input.frameTimestamp * (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + end + elseif self.effectType == EffectType.VideoAnimation then + if self.videoAnimationLua == nil then + self:initVideoAnimationLua(comp) + end + if self.videoAnimationLua ~= nil then + aeTime = remap(self.videoAnimationLua.curTime, 0, self.videoAnimationLua.duration, self.compDurations[1], self.compDurations[2]) + end + end + + if isEditor then + if self.autoPlay then + self.debugTime = curTime % (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + aeTime = self.debugTime + else + aeTime = self.debugTime + end + elseif self.effectType == EffectType.VideoAnimation or self.effectType == EffectType.Transition then + self.curTime = aeTime + end + + if self.lumi_obj then + self.lumi_obj:setEffectAttrRecursively("startTime", self.startTime) + self.lumi_obj:setEffectAttrRecursively("endTime", self.endTime) + self.lumi_obj:setEffectAttrRecursively("curTime", self.curTime) + self.lumi_obj:setEffectAttrRecursively("aeTime", aeTime) + self.lumi_obj:setEffectAttrRecursively("aeDuration", aeDuration) + end + + if self.lumi_params_setter and self.lumi_params_setter.initParams then + self.lumi_params_setter:initParams(self.lumi_obj) + end + if self.lumi_params_setter and self.lumi_params_setter.updateKeyFrameData then + self.lumi_params_setter:updateKeyFrameData(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateSlider then + self.lumi_params_setter:updateSlider(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateFade then + if self.effectType == EffectType.Effect then + self.lumi_params_setter:updateFade(self.lumi_obj, self.startTime, self.endTime, self.curTime, self.compDurations, aeTime) + end + end + + if self.lumi_obj and self.durations ~= nil then + aeTime = math.min(math.max(aeTime, self.compDurations[1]), self.compDurations[2]) + for entityName, durationMap in pairs(self.durations) do + local nodeDuration = durationMap['nodeDuration'] + local visible = false + for j = 1, #nodeDuration do + if nodeDuration[j][1] <= aeTime and aeTime < nodeDuration[j][2] then + visible = true + break + end + end + self.lumi_obj:setVisible(entityName, visible) + end + end + if self.lumi_obj and self.lumi_obj.updateMaterials then + self.lumi_obj:updateMaterials(deltaTime) + end +end + +-- function LumiManager:onLateUpdate(comp, deltaTime) +-- collectgarbage("collect") +-- end + +function LumiManager:onEvent(comp, event) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Failed to find lumi_obj') + return + end + + if self.effectType == EffectType.Effect then + if event.args:get(0) == 'effects_adjust_speed' then + local value = event.args:get(1) + if self.animationInfos then + if value < 0 or value > 1 then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid effects_adjust_speed value: ' .. value) + end + self.speed = remap(clamp(value, 0, 1), 0, 1, self.animationInfos.speedInfo[2], self.animationInfos.speedInfo[3]) + else + self.speed = value + end + end + elseif event.args:get(0) == 'start_time' and self.cameraMode then + self.cameraStartTime = event.args:get(2) + elseif event.args:get(0) == 'is_video' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.isVideo = event.args:get(2) + elseif event.args:get(0) == 'video_time' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.videoTime = event.args:get(2) + end + + if self.lumi_params_setter and self.lumi_params_setter.onEvent then + self.lumi_params_setter:onEvent(self.lumi_obj, event) + end +end + +exports.LumiManager = LumiManager +return exports diff --git a/scripts/7681574644264045845/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua b/scripts/7681574644264045845/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua new file mode 100644 index 0000000000000000000000000000000000000000..c1e528b6007352c9831b71df7a92892be83703dc --- /dev/null +++ b/scripts/7681574644264045845/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua @@ -0,0 +1,436 @@ + +local LumiObjectExtension = {} +LumiObjectExtension.__index = LumiObjectExtension + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag-LumiObjectExtension' + +local function handleAllEntityBySingleParent(_trans, func, func2, ...) + if _trans.children:size() > 0 and func2(_trans, ...) then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i-1) + handleAllEntityBySingleParent(child, func, func2, ...) + end + end + func(_trans, ...) +end + +local function CreateRenderTexture(width, height) + local rt = Amaz.RenderTexture() + rt.width = width + rt.height = height + rt.depth = 1 + rt.filterMag = Amaz.FilterMode.LINEAR + rt.filterMin = Amaz.FilterMode.LINEAR + rt.filterMipmap = Amaz.FilterMipmapMode.NONE + rt.attachment = Amaz.RenderTextureAttachment.NONE + return rt +end + +function LumiObjectExtension.register(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + + local self = setmetatable({}, LumiObjectExtension) + self.entity = _ent + self.scriptComp = scriptComp + self.trans = _ent:getComponent("Transform") + self.effect_lua = effect_lua + if effect_lua.__lumi_type~= nil then + self.__lumi_type = effect_lua.__lumi_type + else + self.__lumi_type = "lumi_obj" + end + if effect_lua.__lumi_rt_pingpong_type~= nil then + self.__lumi_rt_pingpong_type = effect_lua.__lumi_rt_pingpong_type + else + self.__lumi_rt_pingpong_type = "custom" + end + + if self.entity:getComponents("Camera"):size() > 0 then + Amaz.LOGE(AE_EFFECT_TAG, "Error: root entity has camera attached") + return nil + end + self.subLumiObjExt = {} + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local objExt = LumiObjectExtension.register(child.entity) + if objExt and child.entity.name ~= '' then + self.subLumiObjExt[child.entity.name] = objExt + end + end + end + effect_lua.__lumi_obj_ext = self + return self +end + +function LumiObjectExtension.deregister(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + local lumi_obj = effect_lua.__lumi_obj_ext + if lumi_obj == nil then return nil end + + if lumi_obj.__lumi_type == "lumi_effect" then + for i = 1, lumi_obj.trans.children:size() do + local child = lumi_obj.trans.children:get(i-1) + LumiObjectExtension.deregister(child.entity) + end + end + lumi_obj.entity = nil + lumi_obj.trans = nil + lumi_obj.effect_lua = nil + lumi_obj.scriptComp = nil + lumi_obj.subLumiObjExt = nil + lumi_obj.__lumi_type = nil + lumi_obj.__lumi_rt_pingpong_type = nil + effect_lua.__lumi_obj_ext = nil +end + +function LumiObjectExtension.getLumiObjExt(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + return effect_lua.__lumi_obj_ext +end + +function LumiObjectExtension:searchSubLumiObjExt(name) + if self.trans.entity.name == name then + return self + end + if name and self.subLumiObjExt[name] then + return self.subLumiObjExt[name] + end + for _, subObj in pairs(self.subLumiObjExt) do + local obj = subObj:searchSubLumiObjExt(name) + if obj then + return obj + end + end + return nil +end + +function LumiObjectExtension:setInputTex(_tex) + if self.effect_lua then + self.effect_lua.InputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('InputTex', _tex) + end + end +end + +function LumiObjectExtension:setOutputTex(_tex) + if self.effect_lua then + self.effect_lua.OutputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('OutputTex', _tex) + end + end +end + +function LumiObjectExtension:getInputTex() + if self.effect_lua then + return self.effect_lua.InputTex + end + return nil +end + +function LumiObjectExtension:getOutputTex() + if self.effect_lua then + return self.effect_lua.OutputTex + end + return nil +end + +function LumiObjectExtension:setInputTexSizes(inputSize, originalSize) + assert(type(inputSize)=="table", "inputSize should be table") + if self.effect_lua and self.effect_lua.setInputTexSize then + self.effect_lua:setInputTexSize(inputSize) + end + if self.effect_lua and self.effect_lua.setInputOriginalTexSize then + self.effect_lua:setInputOriginalTexSize(originalSize) + end + self._inputTexSize, self._originalTexSize = inputSize, originalSize +end + +function LumiObjectExtension:getOutputTexSizes() + local inputSize = (self.effect_lua and self.effect_lua.getOutputTexSize) and self.effect_lua:getOutputTexSize() or self._inputTexSize + local originalSize = (self.effect_lua and self.effect_lua.getOutputOriginalTexSize) and self.effect_lua:getOutputOriginalTexSize() or self._originalTexSize + return inputSize, originalSize +end + +function LumiObjectExtension:needChangeOutputTexSize() + if self.effect_lua and self.effect_lua.__lumi_will_change_out_size then + return self.effect_lua.__lumi_will_change_out_size + end + if self._inputTexSize~=nil and self.effect_lua and self.effect_lua.getOutputTexSize then + local outSize = self.effect_lua:getOutputTexSize() + return (outSize[1] ~= self._inputTexSize[1] or outSize[2] ~= self._inputTexSize[2]) + end + return false +end + +function LumiObjectExtension:updateRt(_input_tex, _output_tex, _pingpong_tex) + self:setInputTex(_input_tex) + self:setOutputTex(_output_tex) + if self.effect_lua and self.effect_lua.updateRenderTexture ~= nil then + self.effect_lua:updateRenderTexture() + end + if self.__lumi_type == "lumi_effect" and self.__lumi_rt_pingpong_type == "auto" then + local lumi_obj_list = {} + local function collect_lumi_obj(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and (lumi_obj_ext.__lumi_type == "lumi_obj" or lumi_obj_ext.__lumi_rt_pingpong_type == "custom") then + table.insert(lumi_obj_list, lumi_obj_ext) + end + end + local function collect_lumi_obj_flag(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and lumi_obj_ext.__lumi_type == "lumi_effect" and lumi_obj_ext.__lumi_rt_pingpong_type == "auto" then + return true + end + return false + end + handleAllEntityBySingleParent(self.trans, collect_lumi_obj, collect_lumi_obj_flag) + + if _pingpong_tex then + self._pingpong_tex = _pingpong_tex + elseif #lumi_obj_list > 1 then + self._pingpong_tex = CreateRenderTexture(_output_tex.width, _output_tex.height) + end + local pingpong = { _output_tex, self._pingpong_tex } + if #lumi_obj_list%2 == 0 then + pingpong = { self._pingpong_tex, _output_tex } + end + for i = 1, #lumi_obj_list do + local lumi_obj = lumi_obj_list[i] + if lumi_obj then + local idx1 = (i-1)%2+1 + local idx2 = (i)%2+1 + if i == 1 then + lumi_obj:setInputTex(_input_tex) + lumi_obj:setOutputTex(pingpong[idx1]) + else + lumi_obj:setInputTex(pingpong[idx2]) + lumi_obj:setOutputTex(pingpong[idx1]) + end + if lumi_obj.effect_lua and lumi_obj.effect_lua.updateRenderTexture ~= nil then + lumi_obj.effect_lua:updateRenderTexture() + end + end + end + end +end + +function LumiObjectExtension:updateOutputRtSize(width, height) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i - 1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateOutputRtSize(width, height) + end + end + end + local tex = self:getOutputTex() + if tex then + tex.width = width + tex.height = height + end +end + +function LumiObjectExtension:getCameraCount() + local cam_count = 0 + + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + cam_count = cam_count + lumi_obj_ext:getCameraCount() + else + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + elseif self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + + return cam_count +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str.."0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiObjectExtension:updateCameraLayerAndOrder(_start_layer, _start_order) + function updateRendererEntityLayer(trans, layer) + local renderers = trans.entity:getComponentsRecursive("Renderer") + for i = 0, renderers:size() - 1 do + local renderer = renderers:get(i) + if renderer then + renderer.entity.layer = layer + end + end + end + + local lastCamera = nil + + local cur_start_layer = _start_layer + local cur_start_order = _start_order + + if self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local curTrans = self.trans.children:get(i-1) + local cam = curTrans.entity:getComponent("Camera") + if cam then + if lastCamera then + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + lastCamera = cam + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, curTrans.children:size() do + local rendererTrans = curTrans.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + elseif lastCamera then + updateRendererEntityLayer(curTrans, cur_start_layer) + end + end + + elseif self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateCameraLayerAndOrder(cur_start_layer, cur_start_order) + local cam_count = lumi_obj_ext:getCameraCount() + cur_start_layer = cur_start_layer + cam_count + cur_start_order = cur_start_order + cam_count + else + local cam = child.entity:getComponent("Camera") + if cam then + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, child.children:size() do + local rendererTrans = child.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end + end + + return cur_start_layer, cur_start_order +end + +function LumiObjectExtension:setEffectAttr(key, value) + if self.effect_lua and self.effect_lua.setEffectAttr ~= nil then + self.effect_lua:setEffectAttr(key, value, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + self.effect_lua[key] = value + if self.scriptComp and self.scriptComp.properties ~= nil then + self.scriptComp.properties:set(key, value) + end + end + end +end + +function LumiObjectExtension:getEffectAttr(key) + if self.effect_lua and self.effect_lua.getEffectAttr ~= nil then + return self.effect_lua:getEffectAttr(key, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + return self.effect_lua[key] + end + end + return nil +end + +function LumiObjectExtension:setSubEffectAttr(subName, key, value) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + subObj:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:getSubEffectAttr(subName, key) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + return subObj:getEffectAttr(key) + end + return nil +end + +function LumiObjectExtension:setEffectAttrRecursively(key, value) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:setEffectAttrRecursively(key, value) + end + end + self:setEffectAttr(key, value) + elseif self.__lumi_type == "lumi_obj" then + self:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:updateMaterials(time) + if self.effect_lua and self.scriptComp and self.entity and self.entity.visible then + if self.effect_lua.updateMaterial ~= nil then + self.effect_lua:updateMaterial(self.scriptComp, time) + elseif self.effect_lua.onUpdate ~= nil then + self.effect_lua:onUpdate(self.scriptComp, time) + end + + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateMaterials(time) + end + end + end +end + +function LumiObjectExtension:setVisible(subName, visible) + local subObj = self:searchSubLumiObjExt(subName) + if subObj and subObj.effect_lua then + if subObj.effect_lua.setVisible then + subObj.effect_lua:setVisible(visible) + else + subObj.entity.visible = visible + end + end +end + +return LumiObjectExtension diff --git a/scripts/7681574644264045845/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua b/scripts/7681574644264045845/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua new file mode 100644 index 0000000000000000000000000000000000000000..91587ae17803e82e95608198114893dfe226a5c9 --- /dev/null +++ b/scripts/7681574644264045845/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua @@ -0,0 +1,388 @@ +local LumiParamsSetter = {} +LumiParamsSetter.__index = LumiParamsSetter + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +function LumiParamsSetter.new(lumiManager, params, keyframes, effectType, sliderInfos, fadeinInfos, fadeoutInfos) + local self = setmetatable({}, LumiParamsSetter) + self.lumiManager = lumiManager + self.params = params + self.keyframes = keyframes + self.sliderInfos = sliderInfos + self.sliderParams = {} + self.XTEvent = (effectType == 'xtFilter' or effectType == 'xtEffect') + self.fadeinInfos = fadeinInfos + self.fadeoutInfos = fadeoutInfos + self.afterSliderParams = {} + + return self +end + +local function clamp(val, min, max) + return math.max(math.min(val, max), min) +end + +local function mix(a, b, t) + return a * (1 - t) + b * t +end + +local function cvtTable2Amaz(attrType, v) + local value = nil + if attrType == "number" then + if #v == 1 then + value = v[1] + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "vector" then + if #v == 2 then + value = Amaz.Vector2f(v[1], v[2]) + elseif #v == 3 then + value = Amaz.Vector3f(v[1], v[2], v[3]) + elseif #v == 4 then + value = Amaz.Vector4f(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "color" then + if #v == 3 then + value = Amaz.Color(v[1], v[2], v[3], 1.0) + elseif #v == 4 then + value = Amaz.Color(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. "unsupported type: " .. attrType) + end + return value +end + +local function getValueType(value) + local valueType = type(value) + if valueType == 'userdata' then + local str = tostring(value) + if string.sub(str, 1, 6) == 'Vector' then + valueType = 'vector' + elseif string.sub(str, 1, 5) == 'Color' then + valueType = 'color' + end + end + + return valueType +end + +local function add(value, number) + local type = getValueType(value) + if type == 'number' then + return value + number + elseif type == 'vector' then + local ret = value:copy() + ret.x = ret.x + number + ret.y = ret.y + number + if ret.z then ret.z = ret.z + number end + if ret.w then ret.w = ret.w + number end + return ret + elseif type == 'color' then + return Amaz.Color( + value.r + number, + value.g + number, + value.b + number, + value.a + number + ) + end + return nil +end + +local function mul(value, number) + local type = getValueType(value) + if type == 'color' then + return Amaz.Color( + value.r * number, + value.g * number, + value.b * number, + value.a * number + ) + end + return value * number +end + +function LumiParamsSetter:getCurrentDefaultParam(entityName, key, aeTime) + local keyframeName = nil + local keyframeType = 'number' + if self.keyframes ~= nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'number' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'vector' + keyframeType = 'vector' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'color' + keyframeType = 'color' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = nil + end + end + end + + if keyframeName == nil then + if entityName:sub(1, #'LumiLayer') == 'LumiLayer' and key:sub(-#'position') == 'position' then + local entity = self.params[entityName] + if entity ~= nil then + local position = entity[key] + if position ~= nil then + local hasSeparated = false + local newPosition = position:copy() + + local newKey = string.gsub(key, 'position', 'xPosition') + local newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.x = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'yPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.y = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'zPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.z = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + if hasSeparated then + return newPosition + end + end + end + end + end + end + + local value = nil + if keyframeName ~= nil then + value = cvtTable2Amaz(keyframeType, self.keyframes:GetVal(keyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + else + local entity = self.params[entityName] + if entity ~= nil then + value = entity[key] + end + end + return value +end + +function LumiParamsSetter:updateSlider(lumi_obj, aeTime) + -- local sliderIntensity = self.sliderParams['effects_adjust_blur'] + -- local gaussianIntensity = self:getCurrentDefaultParam("Gaussian_Blur_Root_353-effect2", 'intensity', aeTime) + -- if sliderIntensity and gaussianIntensity then + -- lumi_obj:setSubEffectAttr("Gaussian_Blur_Root_353-effect2", 'intensity', gaussianIntensity*sliderIntensity) + -- end + + local function fsub(value, slider, valueA, valueB) + -- (param - sliderValue) * valueA + valueB + return (value - slider) * valueA + valueB + end + + local function fmul(value, slider, valueA, valueB) + -- (param - valueA) * sliderValue + valueB + return (value - valueA) * slider + valueB + end + + local function fadd(value, slider, valueA, valueB) + -- (param - valueA) * valueB + sliderValue + return (value - valueA) * valueB + slider + end + + self.afterSliderParams = {} + for sliderKey, paramsInfos in pairs(self.sliderInfos) do + if self.sliderParams[sliderKey] ~= nil then + for index, value in ipairs(paramsInfos) do + local sliderIntensity = self.sliderParams[sliderKey] + local entityName = value[1] + local paramKey = value[2] + local paramType = value[3] + local paramDimensionFlag = value[4] + local calcType = value[5] + local maxValue = value[6] + local minValue = value[7] + local defaultValue = value[8] + local valueA = value[9] + local valueB = value[10] + sliderIntensity = sliderIntensity * (maxValue - minValue) + minValue + local oriValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + oriValue = self.afterSliderParams[entityName .. '#' .. paramKey] + end + local newValue = oriValue + local calcFunc = nil + if calcType == 0 then + calcFunc = fsub + elseif calcType == 1 then + calcFunc = fmul + elseif calcType == 2 then + calcFunc = fadd + else + Amaz.LOGE(AE_EFFECT_TAG, 'Unknown calcType: ' .. calcType) + return + end + if paramType == 'number' then + if paramDimensionFlag[1] then newValue = calcFunc(oriValue, sliderIntensity, valueA[1], valueB[1]) end + elseif paramType == 'color' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.r = calcFunc(oriValue.r, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.g = calcFunc(oriValue.g, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.b = calcFunc(oriValue.b, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.a = calcFunc(oriValue.a, sliderIntensity, valueA[4], valueB[4]) end + elseif paramType == 'vector' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.x = calcFunc(oriValue.x, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.y = calcFunc(oriValue.y, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.z = calcFunc(oriValue.z, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.w = calcFunc(oriValue.w, sliderIntensity, valueA[4], valueB[4]) end + end + lumi_obj:setSubEffectAttr(entityName, paramKey, newValue) + self.afterSliderParams[entityName .. '#' .. paramKey] = newValue + end + end + end +end + +function LumiParamsSetter:updateFadeParams(lumi_obj, fadeInfos, factor, aeTime) + for i = 1, #fadeInfos.infos do + local entityName = fadeInfos.infos[i][1] + local paramKey = fadeInfos.infos[i][2] + local valueType = fadeInfos.infos[i][3] + local value = fadeInfos.infos[i][4] + + local curValue = nil + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + curValue = self.afterSliderParams[entityName .. '#' .. paramKey] + else + curValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + end + + if curValue ~= nil then + local needRenew = true + if valueType == 'number' then + curValue = mix(value[1], curValue, factor) + elseif valueType == 'color' then + curValue.r = mix(value[1], curValue.r, factor) + curValue.g = mix(value[2], curValue.g, factor) + curValue.b = mix(value[3], curValue.b, factor) + curValue.a = mix(value[4], curValue.a, factor) + elseif valueType == 'vector' then + if #value <= 1 or #value >= 5 then + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid value size: ' .. #value) + else + if #value >= 2 then + curValue.x = mix(value[1], curValue.x, factor) + curValue.y = mix(value[2], curValue.y, factor) + end + if #value >= 3 then + curValue.z = mix(value[3], curValue.z, factor) + end + if #value >= 4 then + curValue.w = mix(value[4], curValue.w, factor) + end + end + else + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid valye type: ' .. valueType) + end + if needRenew then + lumi_obj:setSubEffectAttr(entityName, paramKey, curValue) + end + end + end +end + +function LumiParamsSetter:updateFade(lumi_obj, startTime, endTime, curTime, compDurations, aeTime) + local scale = (endTime - startTime) / (compDurations[2] - compDurations[1]) + scale = clamp(scale, 0, 1) + local runningTime = curTime - startTime + local remainingTime = endTime - curTime + + local isInFadein = false + if self.fadeinInfos + and self.fadeinInfos.time and self.fadeinInfos.time > 0 + and self.fadeinInfos.infos and #self.fadeinInfos.infos > 0 + then + local fadeinTime = self.fadeinInfos.time * scale + if runningTime <= fadeinTime then + isInFadein = true + local factor = runningTime / fadeinTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeinInfos, factor, aeTime) + end + end + + if self.fadeoutInfos + and self.fadeoutInfos.time and self.fadeoutInfos.time > 0 + and self.fadeoutInfos.infos and #self.fadeoutInfos.infos > 0 + then + local fadeoutTime = self.fadeoutInfos.time * scale + if remainingTime <= fadeoutTime or not isInFadein then + local factor = remainingTime / fadeoutTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeoutInfos, factor, aeTime) + end + end +end + +function LumiParamsSetter:onEvent(lumi_obj, event) + if lumi_obj == nil or event == nil then return end + local key = event.args:get(0) + if self.sliderInfos[key] ~= nil then + if self.XTEvent then + self.sliderParams[key] = event.args:get(2); + else + self.sliderParams[key] = event.args:get(1); + end + end +end + +function LumiParamsSetter:initParams(lumi_obj) + if lumi_obj == nil then return end + if self.params == nil then return end + if self.init then return end + + for entityName, params in pairs(self.params) do + for key, value in pairs(params) do + lumi_obj:setSubEffectAttr(entityName, key, value) + end + end + + self.init = true +end + +function LumiParamsSetter:updateKeyFrameData(lumi_obj, aeTime) + if lumi_obj == nil then return end + if self.keyframes == nil then return end + + local p = aeTime + for key, _ in pairs(self.keyframes.attrs) do + local keys = {} + for substr in string.gmatch(key, "[^#]+") do + table.insert(keys, substr) + end + if #keys == 3 then + local entityName = keys[1] + local attrName = keys[2] + local attrType = keys[3] + local v = self.keyframes:GetVal(key, self.lumiManager:getKeyframeAeTime(p)) + local value = cvtTable2Amaz(attrType, v) + if value then + lumi_obj:setSubEffectAttr(entityName, attrName, value) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key) + end + end +end + +return LumiParamsSetter diff --git a/scripts/7681574644264045845/config.json b/scripts/7681574644264045845/config.json new file mode 100644 index 0000000000000000000000000000000000000000..2324d9cbbd95946a5c679cf8a29cec27da745943 --- /dev/null +++ b/scripts/7681574644264045845/config.json @@ -0,0 +1,16 @@ +{ + "ae_tool": "AEExporter:1.5.6", + "bALG_BACH_CONFIG": false, + "effect": { + "Link": [ + { + "path": "AmazingFeature/", + "type": "AmazingFeature", + "zorder": 8029 + } + ] + }, + "name": "AE2Effect_20260904153828565", + "version": "14.8.0", + "item_source": "user_post_pc_le" +} \ No newline at end of file diff --git a/scripts/7681574644264045845/extra.json b/scripts/7681574644264045845/extra.json new file mode 100644 index 0000000000000000000000000000000000000000..f4e6b748e1b7b1b6f1c714fedd8c7b87ebaef725 --- /dev/null +++ b/scripts/7681574644264045845/extra.json @@ -0,0 +1,6 @@ +{ + "transition": { + "defaultDura": 2.000001, + "isOverlap": true + } +} \ No newline at end of file diff --git a/scripts/7681574665201962261/AmazingFeature/content.json b/scripts/7681574665201962261/AmazingFeature/content.json new file mode 100644 index 0000000000000000000000000000000000000000..df43720515b1b6981b24c4268c902195fa613d43 --- /dev/null +++ b/scripts/7681574665201962261/AmazingFeature/content.json @@ -0,0 +1,7 @@ +{ + "ae_tool" : "AmazingEditor", + "content" : {}, + "needblend" : false, + "tag" : "AMG_1515088281693380358513659446614427937212", + "version" : "1.0" +} \ No newline at end of file diff --git a/scripts/7681574665201962261/AmazingFeature/js/JSSys.js b/scripts/7681574665201962261/AmazingFeature/js/JSSys.js new file mode 100644 index 0000000000000000000000000000000000000000..bbcbf36f0f75c1beebe88c33dd0464bb4477158e --- /dev/null +++ b/scripts/7681574665201962261/AmazingFeature/js/JSSys.js @@ -0,0 +1,89 @@ +const effect_api = "undefined" != typeof effect ? effect : "undefined" != typeof tt ? tt : "undefined" != typeof lynx ? lynx : {}; +const Amaz = effect_api.getAmaz(); + +const { ScriptScene } = require('./ThreeJS/scriptScene'); +const THREE = require('./ThreeJS/three-amg-wrapper').THREE; + +class JSSys { + constructor() { + this.name = "JSSys"; + this.comps = {} + this.compsdirty = true + } + + onComponentAdded(comp) { + // console.log("running:JSSys:onComponentAdded"); + } + onComponentRemoved(comp) { + // console.log("running:JSSys:onComponentRemoved"); + } + + onStart() { + console.log("running:JSSys:onStart"); + + this.renderTexture = this.scene.assetMgr.SyncLoad('rt/outputTex.rt'); + + // 添加光源到场景 + console.log('JSSys: 创建ScriptScene实例'); + this.scriptScene = new ScriptScene(this.scene); + + this.input = Amaz.AmazingManager.getSingleton("Input"); + const builtinObject = Amaz.AmazingManager.getSingleton("BuiltinObject"); + + if (builtinObject.getUserTexture("#TransitionInput0") && builtinObject.getUserTexture("#TransitionInput1")) { + this.scriptScene.texture1 = new THREE.Texture(); + this.scriptScene.texture1.setImage(builtinObject.getUserTexture("#TransitionInput0")); + this.scriptScene.texture2 = new THREE.Texture(); + this.scriptScene.texture2.setImage(builtinObject.getUserTexture("#TransitionInput1")); + console.log("JSSys: 获取到纹理"); + } + else + { + this.scriptScene.texture1 = new THREE.Texture(); + this.scriptScene.texture1.setImage(this.scene.assetMgr.SyncLoad('image/Sample1.jpg')); + this.scriptScene.texture2 = new THREE.Texture(); + this.scriptScene.texture2.setImage(this.scene.assetMgr.SyncLoad('image/Sample2.jpg')); + console.log("JSSys: 未获取到纹理,使用默认纹理"); + } + + this.scriptScene.setupScene(); + // 初始化后处理效果 + if (this.scriptScene.initPostProcessing != null) { + this.scriptScene.initPostProcessing(); + } + } + + onUpdate(deltaTime) { + this.time = this.input.getFrameTimestamp(); + // this.time = this.time % 2; + // this.time = this.time / 2.0; + this.scriptScene.seekToTime(this.time * this.scriptScene.Duration); + // this.scriptScene.updateScene(); + } + onLateUpdate(deltaTime) { + // console.log("running:JSSys:onLateUpdate"); + this.scriptScene.scene.seekToTime(this.time * this.scriptScene.Duration); + } + + onEvent(event) { + console.log("running:JSSys:onEvent"); + if (event.type == Amaz.EventType.VIEWER) { + // console.log("JSSys: 窗口大小改变"); + console.log("renderTexture.width",this.renderTexture.width); + console.log("renderTexture.height",this.renderTexture.height); + + window.innerWidth = this.renderTexture.width; + window.innerHeight = this.renderTexture.height; + // console.log("JSSys: 窗口大小改变"); + this.scriptScene.handleResize(); + } + } + + onDestroy() { + // console.log("running:JSSys:onDestroy"); + this.scriptScene.destroy(); + } +} + +exports.JSSys = JSSys; + diff --git a/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/EffectComposer.js b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/EffectComposer.js new file mode 100644 index 0000000000000000000000000000000000000000..e7d8fd7a3f3978d9da1a9bf29af1854806f60014 --- /dev/null +++ b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/EffectComposer.js @@ -0,0 +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{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-6*k)*Math.cos(12*k)};const springStiff=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(18*k)};const dampedOscillation=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(10*k)};const Physics=Object.freeze({SpringSoft:springSoft,SpringStiff:springStiff,DampedOscillation:dampedOscillation});const anticipate=k=>{if(k<=0)return 0;if(k>=1)return 1;const pullback=.1;if(k<.3){const p=k/.3;return-pullback*p*(2-p)}const p=(k-.3)/.7;return-pullback+(1+pullback)*p*p*(3-2*p)};const overshootFactory=peak=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return peak*p*(2-p)}const p=(k-.6)/.4;return peak+(1-peak)*(1-Math.pow(1-p,3))};const overshoot110=overshootFactory(1.1);const overshoot125=overshootFactory(1.25);const snapBack=k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return 1.05*(1-Math.pow(1-p,3))}const p=(k-.6)/.4;return 1.05-.05*p*p*(3-2*p)};const swing=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.cos(1.5*Math.PI*k)*Math.exp(-2.5*k)};const Motion=Object.freeze({Anticipate:anticipate,Overshoot110:overshoot110,Overshoot125:overshoot125,SnapBack:snapBack,Swing:swing});const makeStep=(n,jumpTerm="end")=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(jumpTerm==="start")return Math.ceil(k*n)/n;return Math.floor(k*n)/n};const Step=Object.freeze({Steps4End:makeStep(4,"end"),Steps8End:makeStep(8,"end"),Steps12End:makeStep(12,"end")});function buildCubicBezier(x1,y1,x2,y2){const cx=3*x1,bx=3*(x2-x1)-cx,ax=1-cx-bx;const cy=3*y1,by=3*(y2-y1)-cy,ay=1-cy-by;const sampleX=s=>((ax*s+bx)*s+cx)*s;const sampleY=s=>((ay*s+by)*s+cy)*s;const sampleDX=s=>(3*ax*s+2*bx)*s+cx;const solveS=x=>{let s=x;for(let i=0;i<8;i++){const cur=sampleX(s)-x;if(Math.abs(cur)<1e-6)return s;const d=sampleDX(s);if(Math.abs(d)<1e-6)break;s-=cur/d;if(s<0)s=0;if(s>1)s=1}let lo=0,hi=1;for(let i=0;i<32&&hi-lo>1e-6;i++){const mid=(lo+hi)/2;if(sampleX(mid){if(k<=0)return 0;if(k>=1)return 1;return sampleY(solveS(k))}}const BEZIER_PRESETS=Object.freeze({"Material.Standard":[.4,0,.2,1],"Material.Accelerate":[.4,0,1,1],"Material.Decelerate":[0,0,.2,1],"CSS.Ease":[.25,.1,.25,1]});const _bezierCache=new Map;function _cachedBezier(x1,y1,x2,y2){const key=x1+","+y1+","+x2+","+y2;let fn=_bezierCache.get(key);if(!fn){fn=buildCubicBezier(x1,y1,x2,y2);_bezierCache.set(key,fn)}return fn}function cubicBezier(a,b,c,d){if(typeof a==="string"){let preset=BEZIER_PRESETS[a];if(!preset){console.warn("[customEasings.cubicBezier] unknown preset, falling back to Material.Standard:",a);preset=BEZIER_PRESETS["Material.Standard"]}return _cachedBezier(preset[0],preset[1],preset[2],preset[3])}const clamp=(v,lo,hi)=>Math.max(lo,Math.min(hi,v));const x1=clamp(a,0,1);const y1=clamp(b,-.5,1.5);const x2=clamp(c,0,1);const y2=clamp(d,-.5,1.5);return _cachedBezier(x1,y1,x2,y2)}const libSpring=({stiffness=180,damping=12,mass=1}={})=>{const DT=1/240;const T=1.5;let x=0,v=0;const samples=[];for(let t=0;t<=T;t+=DT){const force=-stiffness*(x-1)-damping*v;v+=force/mass*DT;x+=v*DT;samples.push({t:t,x:x})}let T_end=T;for(let i=samples.length-1;i>=0;i--){if(Math.abs(samples[i].x-1)>.01){T_end=samples[i].t;break}}return k=>{if(k<=0)return 0;if(k>=1)return 1;const t=k*T_end;const idx=Math.min(samples.length-1,Math.floor(t/DT));return samples[idx].x}};const libHeartBeat=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c)=>Math.exp(-((t-c)**2)/(2*.07*.07));return peak*(bell(k,.2)+bell(k,.5))};const libSteps=(n=6)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return Math.floor(k*n)/n};const attentionPing=(peak=.35,decay=2)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(Math.PI*k)*Math.exp(-decay*k)};const attentionWiggle=(count=4,amplitude=.25)=>k=>{if(k<=0||k>=1)return 0;const env=1-k;return amplitude*env*Math.sin(k*Math.PI*2*count)};const attentionStrum=(notes=4,peak=.4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*.05*.05))}return peak*sum}};const Attention=Object.freeze({Ping:attentionPing(),Wiggle:attentionWiggle(),Strum:attentionStrum()});const breathNormal=(cycles=2,peak=.15)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(k*Math.PI*2*cycles)*Math.sin(k*Math.PI)};const breathDeep=(peak=.3,riseRatio=.35,holdRatio=.15)=>{const holdEnd=riseRatio+holdRatio;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const envelope=Math.sin(k*Math.PI);const wave=.5+.5*Math.sin(k*Math.PI*2*cycles-Math.PI/2);return peak*envelope*wave};const breathSigh=(peak=.25,riseRatio=.2)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return peak*Math.exp(-((k-center)**2)/(2*width*width))};const heartExcited=(beats=4,peak=.3,width=.04)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*width*width))}return peak*sum}};const heartLubDub=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return peak*(bell(k,.25,.045)+.6*bell(k,.42,.03))};const Heart=Object.freeze({Calm:heartCalm(),Excited:heartExcited(),LubDub:heartLubDub()});const mathJumpArc=()=>k=>{if(k<=0||k>=1)return 0;return 4*k*(1-k)};const mathPendulum=(damping=3,freq=2.5)=>k=>{if(k<=0||k>=1)return 0;return Math.sin(k*Math.PI)*Math.exp(-damping*k)*Math.cos(freq*Math.PI*k)};const mathTremor=(amplitude=.04,freq=22)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return k+amplitude*Math.sin(k*Math.PI*2*freq)};const mathBoomerang=fn=>k=>{if(k<=0||k>=1)return 0;return k<.5?fn(k*2):fn(2-k*2)};const MathExt=Object.freeze({JumpArc:mathJumpArc(),Pendulum:mathPendulum(),Tremor:mathTremor()});const explosionImpulse=(sharpness=6)=>{const tail=sharpness*Math.exp(1-sharpness);return k=>{if(k<=0||k>=1)return 0;const h=sharpness*k;return h*Math.exp(1-h)-tail*k}};const explosionFlash=(rise=.05,decay=5)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return-Math.exp(-decay*k)*Math.cos(freq*Math.PI*k)};const explosionImplosion=(charge=.3,depth=.4,burstPeak=1.2)=>{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const w=Math.sin(k*Math.PI*2*cycles)+.5*Math.sin(k*Math.PI*2*cycles*1.5+1.2)+.25*Math.sin(k*Math.PI*2*cycles*3+2.4);return amplitude*env*w*.6};const natureFlicker=(rate=15,intensity=.2,seed=7)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=rate+1;i++)samples.push(rand());return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*rate;const idx=Math.floor(pos);const t=pos-idx;const a=samples[idx];const b=samples[idx+1];const interp=a+(b-a)*t;return intensity*env*(interp-.5)*2}};const natureGust=(gusts=3,peak=.25)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*.08*.08))}return peak*sum/gusts*1.8}};const Nature=Object.freeze({Wave:natureWave(),Flicker:natureFlicker(),Gust:natureGust()});const impactRain=(impactAt=.7,rippleAmp=.08)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const liftEnd=.35,strikeEnd=.6;return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return t*t}const t=(k-.4)/.6;const env=Math.exp(-2.5*t);const wave=Math.abs(Math.sin(t*Math.PI*bounces));return 1-env*wave*rebound};const impactSlap=(contactAt=.3,holdRatio=.1)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return.4*Math.pow(t,2.5)}if(k<.48){const t=(k-.4)/.08;return.4-.2*t}if(k<.52){const t=(k-.48)/.04;return.2+.8*t}const t=(k-.52)/.48;return 1-.04*Math.sin(t*Math.PI*8)*(1-t)};const rhythmPunchCombo=(peak=.4)=>{const pattern=[{c:.15,w:.04,a:.75},{c:.35,w:.04,a:.75},{c:.7,w:.055,a:1}];return k=>{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of pattern){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return peak*sum}};const rhythmStaccato=(beats=4,duty=.3)=>k=>{if(k<=0||k>=1)return 0;const beatLen=1/beats;const phase=k/beatLen-Math.floor(k/beatLen);if(phase>duty)return 0;const t=phase/duty;return Math.sin(t*Math.PI)};const rhythmKick=(peak=1.2)=>k=>{if(k<=0||k>=1)return 0;if(k<.05)return peak*k/.05;const t=(k-.05)/.95;return peak*Math.exp(-4*t)};const rhythmCrescendo=(beats=4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return sum}};const rhythmDunDunDun=()=>{const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return k=>{if(k<=0||k>=1)return 0;return.3*bell(k,.15,.025)+.6*bell(k,.35,.03)+1*bell(k,.68,.09)}};const rhythmBellToll=(decay=3,freq=8)=>{const strike=.05;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.2){const t=k/.2;return-pressDepth*Math.sin(t*Math.PI/2)}if(k<.5){const t=(k-.2)/.3;return-pressDepth+(pressDepth+reboundPeak)*(1-Math.pow(1-t,3))}const t=(k-.5)/.5;return reboundPeak*Math.exp(-4*t)*Math.cos(t*Math.PI*3)};const uiHoverBloom=(riseRatio=.2,fallRatio=.3)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=1-k;const raw=Math.sin(k*Math.PI*2*count);const clipped=Math.sign(raw)*Math.min(1,Math.abs(raw)*1.8);return amplitude*env*clipped};const uiSuccessPop=(overshoot=.2)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return(1+overshoot)*(1-Math.pow(1-t,2))}const t=(k-.4)/.6;return 1+overshoot*Math.exp(-5*t)*Math.cos(t*Math.PI*3)};const uiRippleOut=()=>k=>{if(k<=0||k>=1)return 0;return 6.75*k*Math.pow(1-k,2)};const UI=Object.freeze({ClickSnap:uiClickSnap(),HoverBloom:uiHoverBloom(),ErrorShake:uiErrorShake(),SuccessPop:uiSuccessPop(),RippleOut:uiRippleOut()});const magicManaCharge=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;const base=(Math.exp(3*k)-1)/(Math.exp(3)-1);const pulse=.04*Math.sin(k*Math.PI*8)*k;return base+pulse};const magicSpellCast=(chargeEnd=.4)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.45){const t=k/.45;return t*t*t}if(k<.55)return 1;const t=(k-.55)/.45;return Math.pow(1-t,3)};const magicShield=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.3){const t=k/.3;return 1.2*(1-Math.pow(1-t,2))}if(k<.6){const t=(k-.3)/.3;return 1.2-.2*t}const t=(k-.6)/.4;return 1+.03*Math.sin(t*Math.PI*3)};const magicAura=(peak=.15)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const fundamental=.6*Math.sin(k*Math.PI*2);const harmonic=.3*Math.sin(k*Math.PI*4+1);const overtone=.1*Math.sin(k*Math.PI*6+2);return peak*env*(fundamental+harmonic+overtone)};const Magic=Object.freeze({ManaCharge:magicManaCharge(),SpellCast:magicSpellCast(),Teleport:magicTeleport(),Shield:magicShield(),MagicAura:magicAura()});const animalCatPounce=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.2){const t=k/.2;return-.2*Math.sin(t*Math.PI)}if(k<.3){const t=(k-.2)/.1;return.5*t*t}if(k<.8){const t=(k-.3)/.5;return.5+.5*t+.2*Math.sin(t*Math.PI)}const t=(k-.8)/.2;return 1+.05*Math.sin(t*Math.PI)};const animalBirdFlap=(flaps=4)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const phase=k*Math.PI*2*flaps;const wave=Math.sin(phase)-.3*Math.sin(phase*2);return.2*env*wave};const animalSnakeSlither=(waves=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const wave=Math.sin(k*Math.PI*2*waves);return.2*env*wave};const animalButterflyFlit=(seed=13)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=26;i++)samples.push(rand()-.5);return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*25;const idx=Math.floor(pos);const t=pos-idx;const smooth=t*t*(3-2*t);const interp=samples[idx]+(samples[idx+1]-samples[idx])*smooth;return.3*env*interp}};const animalHorseGallop=(cycles=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const cyclePos=k*cycles-Math.floor(k*cycles);const bell=(c,w=.04)=>Math.exp(-((cyclePos-c)**2)/(2*w*w));return.25*env*(bell(0)+bell(.18)+bell(.36)+bell(.54))};const Animal=Object.freeze({CatPounce:animalCatPounce(),BirdFlap:animalBirdFlap(),SnakeSlither:animalSnakeSlither(),ButterflyFlit:animalButterflyFlit(),HorseGallop:animalHorseGallop()});const Progress=Object.freeze({Physics:Object.freeze({...Physics,Spring:libSpring()}),Motion:Motion,Step:Object.freeze({...Step,Steps6:libSteps()}),Math:Object.freeze({Tremor:MathExt.Tremor}),Impact:Object.freeze({Rain:Impact.Rain,Hammer:Impact.Hammer,BounceDrop:Impact.BounceDrop,ArrowHit:Impact.ArrowHit,Shatter:Impact.Shatter}),Rhythm:Object.freeze({BassDrop:Rhythm.BassDrop}),UI:Object.freeze({SuccessPop:UI.SuccessPop}),Magic:Object.freeze({ManaCharge:Magic.ManaCharge,Shield:Magic.Shield}),Animal:Object.freeze({CatPounce:Animal.CatPounce})});const Pulse=Object.freeze({Attention:Object.freeze({Ping:Attention.Ping}),Breath:Object.freeze({Deep:Breath.Deep,Sigh:Breath.Sigh}),Heart:Object.freeze({Calm:Heart.Calm}),Math:Object.freeze({JumpArc:MathExt.JumpArc,BoomerangSharp:mathBoomerang(E.Cubic.In),BoomerangSoft:mathBoomerang(E.Cubic.Out)}),Explosion:Object.freeze({Impulse:Explosion.Impulse,Flash:Explosion.Flash,Recoil:Explosion.Recoil,Implosion:Explosion.Implosion}),Impact:Object.freeze({Slap:Impact.Slap}),Rhythm:Object.freeze({Kick:Rhythm.Kick}),UI:Object.freeze({ClickSnap:UI.ClickSnap,HoverBloom:UI.HoverBloom,RippleOut:UI.RippleOut}),Magic:Object.freeze({SpellCast:Magic.SpellCast,Teleport:Magic.Teleport})});const Wave=Object.freeze({Attention:Object.freeze({Wiggle:Attention.Wiggle,Strum:Attention.Strum}),Breath:Object.freeze({Normal:Breath.Normal,Panting:Breath.Panting}),Heart:Object.freeze({Excited:Heart.Excited,LubDub:Heart.LubDub,Beat:libHeartBeat()}),Math:Object.freeze({Pendulum:MathExt.Pendulum}),Nature:Nature,Rhythm:Object.freeze({PunchCombo:Rhythm.PunchCombo,Staccato:Rhythm.Staccato,Crescendo:Rhythm.Crescendo,DunDunDun:Rhythm.DunDunDun,BellToll:Rhythm.BellToll}),UI:Object.freeze({ErrorShake:UI.ErrorShake}),Magic:Object.freeze({MagicAura:Magic.MagicAura}),Animal:Object.freeze({BirdFlap:Animal.BirdFlap,SnakeSlither:Animal.SnakeSlither,ButterflyFlit:Animal.ButterflyFlit,HorseGallop:Animal.HorseGallop})});const customEasings=Object.freeze({makeOutIn:makeOutIn,OutIn:OutIn,Progress:Progress,Pulse:Pulse,Wave:Wave,cubicBezier:cubicBezier});exports.customEasings=customEasings;exports.default=customEasings; \ No newline at end of file diff --git a/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/scriptScene.js b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/scriptScene.js new file mode 100644 index 0000000000000000000000000000000000000000..5d5f0a8bde54f7efa0912b77bb0a8298e3fb04e9 --- /dev/null +++ b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/scriptScene.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/three-amg-wrapper.js b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/three-amg-wrapper.js new file mode 100644 index 0000000000000000000000000000000000000000..c2037e314e032c4d36912923d4cc1258cba3ab19 --- /dev/null +++ b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/three-amg-wrapper.js @@ -0,0 +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;iobj.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; \ No newline at end of file diff --git a/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/tween.js b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/tween.js new file mode 100644 index 0000000000000000000000000000000000000000..690fb9e4284728629129deed5a5a3f4bcec291ed --- /dev/null +++ b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/tween.js @@ -0,0 +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=power1e4?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;_i0){this._tweensAddedDuringUpdate={};for(var i=0;i1){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[m1;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;itotalTime){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;ithis.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;ithis.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.xthis.max.x||box.max.ythis.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; \ No newline at end of file diff --git a/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Box3.js b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Box3.js new file mode 100644 index 0000000000000000000000000000000000000000..4100dc7442d3a622827c8a415e24557f68c491f1 --- /dev/null +++ b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Box3.js @@ -0,0 +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=3?array[offset+2]:0;if(xthis.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=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.xthis.max.x||box.max.ythis.max.y||box.max.zthis.max.z)}}exports.Box3=Box3; \ No newline at end of file diff --git a/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..be3b8b1334a62f5e88c45feee098063a199fca55 --- /dev/null +++ b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js @@ -0,0 +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=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; \ No newline at end of file diff --git a/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..af9a8a13a46500e78f082a35e18d0b5932061234 --- /dev/null +++ b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js @@ -0,0 +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;iObject.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;i1?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; \ No newline at end of file diff --git a/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Constants.js b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Constants.js new file mode 100644 index 0000000000000000000000000000000000000000..6b8adda19a4d67236719804f5170889b39fd4582 --- /dev/null +++ b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Constants.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js new file mode 100644 index 0000000000000000000000000000000000000000..29b0aad5599401be17f967ba1d48851acb70c2ac --- /dev/null +++ b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js @@ -0,0 +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;i0||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;i0?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;imaxX)maxX=p.x;if(p.ymaxY)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; \ No newline at end of file diff --git a/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..f3dee08bf1c089e040fcfef228902ab9a39c93cb --- /dev/null +++ b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Earcut.js b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Earcut.js new file mode 100644 index 0000000000000000000000000000000000000000..953abffdf38c2def26df73fed180eff8c7644ced --- /dev/null +++ b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Earcut.js @@ -0,0 +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;imaxX)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=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=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.x&&p.x>=mx&&hx!==p.x&&pointInTriangle(hym.x||p.x===m.x&§orContainsSector(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.xb.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;i0||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=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;i0){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;imaxX)maxX=contour[i].x;if(contour[i].ymaxY)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;layerIdx0?-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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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; \ No newline at end of file diff --git a/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Group.js b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Group.js new file mode 100644 index 0000000000000000000000000000000000000000..90c4dbef65aa04d7a3bb6b6d76ec3317ea65a228 --- /dev/null +++ b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Group.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");class Group extends Object3D{constructor(name="Group_w"){super(name)}dispose(){super.dispose()}}exports.Group=Group; \ No newline at end of file diff --git a/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Material.js b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Material.js new file mode 100644 index 0000000000000000000000000000000000000000..81b97053ad9d1e4b1ef05d5ac6ed992487b2ca8e --- /dev/null +++ b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Material.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..dcf34d4cffb9de0869382a24690f78f60dda6049 --- /dev/null +++ b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js new file mode 100644 index 0000000000000000000000000000000000000000..41e6cd0a0eee7dd7bc497be5deac584806b68dc3 --- /dev/null +++ b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Mesh.js b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Mesh.js new file mode 100644 index 0000000000000000000000000000000000000000..254d69b074e797dd34c16d7dad723bbcc3b4895d --- /dev/null +++ b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Mesh.js @@ -0,0 +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;imaterial,set:value=>{material=value;if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;im.dispose&&m.dispose());else if(this.material.dispose)this.material.dispose()}}}exports.MeshWrapper=MeshWrapper; \ No newline at end of file diff --git a/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..ac394f66efc4e113a7127ee0f50ec672e4c5e9eb --- /dev/null +++ b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Object3D.js b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Object3D.js new file mode 100644 index 0000000000000000000000000000000000000000..8532c6122f839460aab34fe88957802ff523318b --- /dev/null +++ b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Object3D.js @@ -0,0 +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{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&¤tScene._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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js new file mode 100644 index 0000000000000000000000000000000000000000..ba39801de50d38ec04424f3c2ebfa2ff5d28fded --- /dev/null +++ b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js @@ -0,0 +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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..bc595fb80ad9e7c2f4d8360c67dbef556f3d6cbe --- /dev/null +++ b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js @@ -0,0 +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;iy0){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; \ No newline at end of file diff --git a/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..02dc1be955bc766de744222a7e75c65bf147bb61 --- /dev/null +++ b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js @@ -0,0 +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&¶meters.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{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=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=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=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; \ No newline at end of file diff --git a/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Shape.js b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Shape.js new file mode 100644 index 0000000000000000000000000000000000000000..ecde48b5ceb30812c922aa5c7cfe2aa7b50cabe4 --- /dev/null +++ b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Shape.js @@ -0,0 +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;i0){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;i0||(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;imaxX)maxX=p.x;if(p.ymaxY)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;i0?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;ipoints.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;itwoPi)deltaAngle-=twoPi;if(deltaAngle>4;uuid[i]=chars[i===19?r&3|8:r]}}return uuid.join("")}exports.Shape=Shape; \ No newline at end of file diff --git a/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..3786abc7d64ed80b56101c4ac9d30ce9fcb8f941 --- /dev/null +++ b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js @@ -0,0 +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;i0){const bounds=calculateBounds(flatVertices);const vertexOffset=vertices.length/3;for(let j=0;j0){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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}function calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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; \ No newline at end of file diff --git a/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..1ea27a55fbce9fc3771c66840c068e5ff6347092 --- /dev/null +++ b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Texture.js b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Texture.js new file mode 100644 index 0000000000000000000000000000000000000000..35bff49d732c9884e07bfcb5682f18a860485e1f --- /dev/null +++ b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Texture.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Vector2.js b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Vector2.js new file mode 100644 index 0000000000000000000000000000000000000000..a30a2431264ee62cec937714dfa9e50932ddedeb --- /dev/null +++ b/scripts/7681574665201962261/AmazingFeature/js/ThreeJS/wrapper/Vector2.js @@ -0,0 +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)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)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) 1.0)) + { + return vec4(-1.0); + } + vec3 _107 = cross(_87, _61); + float _113 = dot(_p1, _107) / _74; + bool _115 = _113 < 0.0; + bool _123; + if (!_115) + { + _123 = (_93 + _113) > 1.0; + } + else + { + _123 = _115; + } + if (_123) + { + return vec4(-1.0); + } + return vec4(_93, _113, dot(_65, _107) / _74, 1.0); +} + +vec2 _f2(mat4 _p0, mat4 _p1, vec2 _p2) +{ + vec3 _162 = (_p0 * vec4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + vec3 _168 = (_p0 * vec4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _173 = (_p0 * vec4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _178 = (_p0 * vec4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + vec4 _189 = _p1 * vec4((_p2 * 2.0) - vec2(1.0), 0.0, 1.0); + vec4 _t17 = _189; + vec3 _206 = normalize((_189.xyz / vec3(_t17.w)) - vec3(0.0)); + vec3 param = vec3(0.0); + vec3 param_1 = _206; + vec3 _214 = (_p0 * vec4(-10.0, -10.0, 0.0, 1.0)).xyz; + vec3 param_2 = _214; + vec3 param_3 = _162; + vec3 param_4 = _173; + vec4 _t21 = _f1(param, param_1, param_2, param_3, param_4); + vec3 param_5 = vec3(0.0); + vec3 param_6 = _206; + vec3 param_7 = _178; + vec3 param_8 = _168; + vec3 _231 = (_p0 * vec4(10.0, 10.0, 0.0, 1.0)).xyz; + vec3 param_9 = _231; + vec4 _t22 = _f1(param_5, param_6, param_7, param_8, param_9); + vec3 param_10 = vec3(0.0); + vec3 param_11 = _206; + vec3 param_12 = _214; + vec3 param_13 = _173; + vec3 param_14 = _162; + vec4 _t23 = _f1(param_10, param_11, param_12, param_13, param_14); + vec3 param_15 = vec3(0.0); + vec3 param_16 = _206; + vec3 param_17 = _178; + vec3 param_18 = _231; + vec3 param_19 = _168; + vec4 _t24 = _f1(param_15, param_16, param_17, param_18, param_19); + vec2 _397 = (((((((vec2(-4.5) * ((1.0 - _t21.x) - _t21.y)) + (vec2(5.5, -4.5) * _t21.x)) + (vec2(-4.5, 5.5) * _t21.y)) * step(0.0, _t21.w)) + ((((vec2(-4.5, 5.5) * ((1.0 - _t22.x) - _t22.y)) + (vec2(5.5, -4.5) * _t22.x)) + (vec2(5.5) * _t22.y)) * (step(_t21.w, 0.0) * step(0.0, _t22.w)))) + ((((vec2(-4.5) * ((1.0 - _t23.x) - _t23.y)) + (vec2(-4.5, 5.5) * _t23.x)) + (vec2(5.5, -4.5) * _t23.y)) * ((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(0.0, _t23.w)))) + ((((vec2(-4.5, 5.5) * ((1.0 - _t24.x) - _t24.y)) + (vec2(5.5) * _t24.x)) + (vec2(5.5, -4.5) * _t24.y)) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(0.0, _t24.w)))) + (vec2(-10000.0) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(_t24.w, 0.0))); + return _397; +} + +vec2 _f4(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +float _f3(vec2 _p0) +{ + vec2 _t30 = step(vec2(0.0), _p0) * step(_p0, vec2(1.0)); + return _t30.x * _t30.y; +} + +float _f0(vec3 _p0) +{ + return dot(_p0, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +vec4 _f5(vec4 _p0) +{ + vec4 _t31 = vec4(0.0); + if (u_enableMatte == 1) + { + _t31 = texture2D(u_maskTexture, uv0); + } + float _t32 = _t31.w; + if (u_matteMode == 1) + { + vec3 param = _t31.xyz; + _t32 = _f0(param); + } + else + { + if (u_matteMode == 2) + { + _t32 = 1.0 - _t31.w; + } + else + { + if (u_matteMode == 3) + { + vec3 param_1 = _t31.xyz; + _t32 = 1.0 - _f0(param_1); + } + } + } + return _p0 * _t32; +} + +vec4 _f6(inout vec4 _p0, inout vec4 _p1) +{ + float _483 = _p0.w; + vec4 _486 = _p0; + vec3 _489 = _486.xyz / vec3(max(_483, 9.9999997473787516355514526367188e-06)); + _p0.x = _489.x; + _p0.y = _489.y; + _p0.z = _489.z; + float _498 = _p1.w; + vec4 _500 = _p1; + vec3 _503 = _500.xyz / vec3(max(_498, 9.9999997473787516355514526367188e-06)); + _p1.x = _503.x; + _p1.y = _503.y; + _p1.z = _503.z; + vec4 _t33 = _p1; + _t33.x = _p0.xyz.x; + _t33.y = _p0.xyz.y; + _t33.z = _p0.xyz.z; + vec4 _t34 = vec4(0.0); + if (u_layerType == 1) + { + float _t35 = 1.0; + if (u_hasMatte == 1) + { + vec4 param = vec4(1.0); + _t35 = _f5(param).w; + } + vec4 _551 = mix(_p1, vec4(_t33.xyz, _p0.w), vec4(u_layerOpacity * _t35)); + _t34 = _551; + float _553 = _t34.w; + vec3 _556 = _551.xyz * _553; + _t34.x = _556.x; + _t34.y = _556.y; + _t34.z = _556.z; + } + else + { + vec3 _591 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t33.xyz * (_p0.w * _p1.w)); + _t34.x = _591.x; + _t34.y = _591.y; + _t34.z = _591.z; + _t34.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t34; +} + +void main() +{ + vec4 _t36 = vec4(0.0); + bool _614 = u_hasBlend == 1; + if (_614) + { + if (u_hasBaseTexture == 1) + { + _t36 = texture2D(u_baseTexure, uv0); + } + if (u_hasSourceTexture == 0) + { + gl_FragData[0] = _t36; + return; + } + } + vec4 _t37 = vec4(0.0); + if (u_hasTrs == 1) + { + mat4 param = u_mvMat; + mat4 param_1 = u_pMat; + vec2 param_2 = uv0; + vec2 _652 = _f2(param, param_1, param_2); + float _656 = step(u_mirrorEdge, 0.5); + vec2 param_3 = _652; + vec2 _666 = (_652 * _656) + (_f4(param_3) * (1.0 - _656)); + vec2 param_4 = _666; + _t37 = (texture2D(u_sourceTexture, _666) * u_alpha) * _f3(param_4); + } + else + { + if (u_hasSourceTexture == 1) + { + _t37 = texture2D(u_sourceTexture, uv0); + } + } + if ((u_layerType != 1) && (u_hasMatte == 1)) + { + vec4 param_5 = _t37; + _t37 = _f5(param_5); + } + if (_614) + { + vec4 param_6 = _t37; + vec4 param_7 = _t36; + vec4 _704 = _f6(param_6, param_7); + _t37 = _704; + } + gl_FragData[0] = _t37; +} + diff --git a/scripts/7681581724236582164/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681581724236582164/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..705dd9f8b691def7eaafc9c1b6e2528c0b0c0165 --- /dev/null +++ b/scripts/7681581724236582164/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681581724236582164/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag b/scripts/7681581724236582164/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag new file mode 100644 index 0000000000000000000000000000000000000000..7b5f204904818053699abc060be6bfa62f2ab74e --- /dev/null +++ b/scripts/7681581724236582164/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag @@ -0,0 +1,268 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + int u_enableMatte; + int u_matteMode; + int u_layerType; + int u_hasMatte; + float u_layerOpacity; + int u_hasBlend; + int u_hasBaseTexture; + int u_hasSourceTexture; + int u_hasTrs; + float4x4 u_mvMat; + float4x4 u_pMat; + float u_mirrorEdge; + float u_alpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f1(thread const float3& _p0, thread const float3& _p1, thread const float3& _p2, thread const float3& _p3, thread const float3& _p4) +{ + float3 _61 = _p3 - _p2; + float3 _65 = _p4 - _p2; + float3 _69 = cross(_p1, _65); + float _74 = dot(_61, _69); + if (_74 <= 1.0000000116860974230803549289703e-07) + { + return float4(-1.0); + } + float3 _87 = _p0 - _p2; + float _93 = dot(_87, _69) / _74; + if ((_93 < 0.0) || (_93 > 1.0)) + { + return float4(-1.0); + } + float3 _107 = cross(_87, _61); + float _113 = dot(_p1, _107) / _74; + bool _115 = _113 < 0.0; + bool _123; + if (!_115) + { + _123 = (_93 + _113) > 1.0; + } + else + { + _123 = _115; + } + if (_123) + { + return float4(-1.0); + } + return float4(_93, _113, dot(_65, _107) / _74, 1.0); +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float4x4& _p0, thread const float4x4& _p1, thread const float2& _p2) +{ + float3 _162 = (_p0 * float4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + float3 _168 = (_p0 * float4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _173 = (_p0 * float4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _178 = (_p0 * float4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + float4 _189 = _p1 * float4((_p2 * 2.0) - float2(1.0), 0.0, 1.0); + float4 _t17 = _189; + float3 _206 = fast::normalize((_189.xyz / float3(_t17.w)) - float3(0.0)); + float3 param = float3(0.0); + float3 param_1 = _206; + float3 _214 = (_p0 * float4(-10.0, -10.0, 0.0, 1.0)).xyz; + float3 param_2 = _214; + float3 param_3 = _162; + float3 param_4 = _173; + float4 _t21 = _f1(param, param_1, param_2, param_3, param_4); + float3 param_5 = float3(0.0); + float3 param_6 = _206; + float3 param_7 = _178; + float3 param_8 = _168; + float3 _231 = (_p0 * float4(10.0, 10.0, 0.0, 1.0)).xyz; + float3 param_9 = _231; + float4 _t22 = _f1(param_5, param_6, param_7, param_8, param_9); + float3 param_10 = float3(0.0); + float3 param_11 = _206; + float3 param_12 = _214; + float3 param_13 = _173; + float3 param_14 = _162; + float4 _t23 = _f1(param_10, param_11, param_12, param_13, param_14); + float3 param_15 = float3(0.0); + float3 param_16 = _206; + float3 param_17 = _178; + float3 param_18 = _231; + float3 param_19 = _168; + float4 _t24 = _f1(param_15, param_16, param_17, param_18, param_19); + float2 _397 = (((((((float2(-4.5) * ((1.0 - _t21.x) - _t21.y)) + (float2(5.5, -4.5) * _t21.x)) + (float2(-4.5, 5.5) * _t21.y)) * step(0.0, _t21.w)) + ((((float2(-4.5, 5.5) * ((1.0 - _t22.x) - _t22.y)) + (float2(5.5, -4.5) * _t22.x)) + (float2(5.5) * _t22.y)) * (step(_t21.w, 0.0) * step(0.0, _t22.w)))) + ((((float2(-4.5) * ((1.0 - _t23.x) - _t23.y)) + (float2(-4.5, 5.5) * _t23.x)) + (float2(5.5, -4.5) * _t23.y)) * ((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(0.0, _t23.w)))) + ((((float2(-4.5, 5.5) * ((1.0 - _t24.x) - _t24.y)) + (float2(5.5) * _t24.x)) + (float2(5.5, -4.5) * _t24.y)) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(0.0, _t24.w)))) + (float2(-10000.0) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(_t24.w, 0.0))); + return _397; +} + +static inline __attribute__((always_inline)) +float2 _f4(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0) +{ + float2 _t30 = step(float2(0.0), _p0) * step(_p0, float2(1.0)); + return _t30.x * _t30.y; +} + +static inline __attribute__((always_inline)) +float _f0(thread const float3& _p0) +{ + return dot(_p0, float3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread const float4& _p0, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode) +{ + float4 _t31 = float4(0.0); + if (u_enableMatte == 1) + { + _t31 = u_maskTexture.sample(u_maskTextureSmplr, uv0); + } + float _t32 = _t31.w; + if (u_matteMode == 1) + { + float3 param = _t31.xyz; + _t32 = _f0(param); + } + else + { + if (u_matteMode == 2) + { + _t32 = 1.0 - _t31.w; + } + else + { + if (u_matteMode == 3) + { + float3 param_1 = _t31.xyz; + _t32 = 1.0 - _f0(param_1); + } + } + } + return _p0 * _t32; +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, thread float4& _p1, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode, constant int& u_layerType, constant int& u_hasMatte, constant float& u_layerOpacity) +{ + float _483 = _p0.w; + float4 _486 = _p0; + float3 _489 = _486.xyz / float3(fast::max(_483, 9.9999997473787516355514526367188e-06)); + _p0.x = _489.x; + _p0.y = _489.y; + _p0.z = _489.z; + float _498 = _p1.w; + float4 _500 = _p1; + float3 _503 = _500.xyz / float3(fast::max(_498, 9.9999997473787516355514526367188e-06)); + _p1.x = _503.x; + _p1.y = _503.y; + _p1.z = _503.z; + float4 _t33 = _p1; + _t33.x = _p0.xyz.x; + _t33.y = _p0.xyz.y; + _t33.z = _p0.xyz.z; + float4 _t34 = float4(0.0); + if (u_layerType == 1) + { + float _t35 = 1.0; + if (u_hasMatte == 1) + { + float4 param = float4(1.0); + _t35 = _f5(param, u_enableMatte, u_maskTexture, u_maskTextureSmplr, uv0, u_matteMode).w; + } + float4 _551 = mix(_p1, float4(_t33.xyz, _p0.w), float4(u_layerOpacity * _t35)); + _t34 = _551; + float _553 = _t34.w; + float3 _556 = _551.xyz * _553; + _t34.x = _556.x; + _t34.y = _556.y; + _t34.z = _556.z; + } + else + { + float3 _591 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t33.xyz * (_p0.w * _p1.w)); + _t34.x = _591.x; + _t34.y = _591.y; + _t34.z = _591.z; + _t34.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t34; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_maskTexture [[texture(0)]], texture2d u_baseTexure [[texture(1)]], texture2d u_sourceTexture [[texture(2)]], sampler u_maskTextureSmplr [[sampler(0)]], sampler u_baseTexureSmplr [[sampler(1)]], sampler u_sourceTextureSmplr [[sampler(2)]]) +{ + main0_out out = {}; + float4 _t36 = float4(0.0); + bool _614 = buffer.u_hasBlend == 1; + if (_614) + { + if (buffer.u_hasBaseTexture == 1) + { + _t36 = u_baseTexure.sample(u_baseTexureSmplr, in.uv0); + } + if (buffer.u_hasSourceTexture == 0) + { + out.o_fragColor = _t36; + return out; + } + } + float4 _t37 = float4(0.0); + if (buffer.u_hasTrs == 1) + { + float4x4 param = buffer.u_mvMat; + float4x4 param_1 = buffer.u_pMat; + float2 param_2 = in.uv0; + float2 _652 = _f2(param, param_1, param_2); + float _656 = step(buffer.u_mirrorEdge, 0.5); + float2 param_3 = _652; + float2 _666 = (_652 * _656) + (_f4(param_3) * (1.0 - _656)); + float2 param_4 = _666; + _t37 = (u_sourceTexture.sample(u_sourceTextureSmplr, _666) * buffer.u_alpha) * _f3(param_4); + } + else + { + if (buffer.u_hasSourceTexture == 1) + { + _t37 = u_sourceTexture.sample(u_sourceTextureSmplr, in.uv0); + } + } + if ((buffer.u_layerType != 1) && (buffer.u_hasMatte == 1)) + { + float4 param_5 = _t37; + _t37 = _f5(param_5, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode); + } + if (_614) + { + float4 param_6 = _t37; + float4 param_7 = _t36; + float4 _704 = _f6(param_6, param_7, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode, buffer.u_layerType, buffer.u_hasMatte, buffer.u_layerOpacity); + _t37 = _704; + } + out.o_fragColor = _t37; + return out; +} + diff --git a/scripts/7681581724236582164/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681581724236582164/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..d7349349d1805ff40c01eddcceaf24b19c0e17d2 --- /dev/null +++ b/scripts/7681581724236582164/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681581724236582164/AmazingFeature/lua/LumiFamily/AETools.lua b/scripts/7681581724236582164/AmazingFeature/lua/LumiFamily/AETools.lua new file mode 100644 index 0000000000000000000000000000000000000000..07ad317cd97ebb4ef6a4b329cdda5e775c5c2b2c --- /dev/null +++ b/scripts/7681581724236582164/AmazingFeature/lua/LumiFamily/AETools.lua @@ -0,0 +1,273 @@ +local AETools = AETools or {} +AETools.__index = AETools + +-- AE PropertyValueType +local ThreeD_SPATIAL = 6413 +local ThreeD = 6414 +local TwoD_SPATIAL = 6415 +local TwoD = 6416 +local OneD = 6417 + +local function deepcopy(orig) + local copy + if type(orig) == "table" then + copy = {} + for orig_key, orig_value in next, orig, nil do + copy[deepcopy(orig_key)] = deepcopy(orig_value) + end + -- setmetatable(copy, deepcopy(getmetatable(orig))) + else + copy = orig + end + return copy +end + +function AETools.new(attrs) + if attrs == nil then return nil end + + local self = setmetatable({}, AETools) + self.attrs = attrs + + local max_frame = 0 + local min_frame = 100000 + for _,v in pairs(attrs) do + for i = 1, #v do + local content = v[i] + local cur_frame_min = content[2][1] + local cur_frame_max = content[2][2] + max_frame = math.max(cur_frame_max, max_frame) + min_frame = math.min(cur_frame_min, min_frame) + + if content[4] ~= nil + and content[5] ~= nil + and (content[4][1] == ThreeD_SPATIAL or content[4][1] == TwoD_SPATIAL) + and content[5][1] == 0 + then + local p0 = content[3][1] + local totalLen = 0 + local lenInfo = {} + lenInfo[0] = 0 + for test=1,200,1 do + local coord = self._cubicBezier3D(content[3][1], content[3][3], content[3][4], content[3][2], test/200) + local length = 0 + if #p0 >= 3 then + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])+(coord[3]-p0[3])*(coord[3]-p0[3])) + else + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])) + end + p0 = coord + totalLen = totalLen + length + lenInfo[test] = totalLen + -- print(test/200 .. " coord: "..coord[1].." - "..coord[2]) + end + for test=1,200,1 do + lenInfo[test] = lenInfo[test]/(lenInfo[200]+0.000001) + -- print(test/200 .. " "..lenInfo[test]) + end + content['lenInfo'] = lenInfo + end + end + end + + self.all_frame = max_frame - min_frame + self.min_frame = min_frame + + return self +end + +function AETools:CurFrame(_p) + local frame = math.floor(_p*self.all_frame) + return frame + self.min_frame +end + +function AETools:AllFrame(_p) + return self.all_frame +end + +function AETools._remap01(a,b,x) + if x < a then return 0 end + if x > b then return 1 end + return (x-a)/(b-a) +end + +function AETools._cubicBezier(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + return { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + } +end + +function AETools._cubicBezier3D(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + local value = { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + 0, + } + if #p1 >= 3 then + value[3] = p1[3] * _t3 + 3 * p2[3] * _t2 * t + 3 * p3[3] * _t * t2 + p4[3] * t3 + end + return value +end + +function AETools:_cubicBezierSpatial(lenInfo, p1, p2, p3, p4, t) + local p = 0 + if t <= 0 then + p = 0 + elseif t >= 1 then + p = 1 + else + local ts = 199 + local te = 200 + for i=1,200,1 do + if lenInfo[i] >= t then + te = i + ts = i-1 + break + end + end + p = ts/200. + 0.005*(t-lenInfo[ts])/(lenInfo[te]-lenInfo[ts]+0.000001) + end + return self._cubicBezier3D(p1, p2, p3, p4, p) +end + +function AETools:_cubicBezier01(_bezier_val, p, y_len) + local x = self:_getBezier01X(_bezier_val, p, y_len) + return self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + x + )[2] +end + +function AETools:AllFrame() + return self.all_frame +end + +function AETools:_getBezier01X(_bezier_val, x, y_len) + local ts = 0 + local te = 1 + -- divide and conque + local times = 1 + repeat + local tm = (ts+te)*0.5 + local value = self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + tm) + if(value[1]>x) then + te = tm + else + ts = tm + end + times = times +1 + until(te-ts < 0.001 and times < 50) + + return (te+ts)*0.5 +end + +function AETools._mix(a, b, x, type) + if type == 1 then + return a * (1-x) + b * x + end + return a + x +end + +function AETools:GetVal(_name, _progress) + local content = self.attrs[_name] + if content == nil then + return nil + end + + -- local cur_frame = _progress * self.all_frame + self.min_frame + local cur_frame = _progress + + for i = 1, #content do + local info = content[i] + local start_frame = info[2][1] + local end_frame = info[2][2] + if cur_frame >= start_frame and cur_frame < end_frame then + local cur_progress = self._remap01(start_frame, end_frame, cur_frame) + local bezier = info[1] + local value_range = info[3] + local y_len = 1 + if (value_range[2][1] == value_range[1][1] and info[5] and info[5][1]==0 and #(value_range[1])==1) then + y_len = 0 + end + + if info[5] and info[5][1] == 2 then + return deepcopy(info[3][1]) + end + + if #bezier > 4 then + -- currently scale attrs contains more than 4 bezier values + local res = {} + for k = 1, 3 do + local cur_bezier = {bezier[k], bezier[k+3], bezier[k+3*2], bezier[k+3*3]} + local p = self:_cubicBezier01(cur_bezier, cur_progress, y_len) + res[k] = self._mix(value_range[1][k], value_range[2][k], p, y_len) + end + return res + + else + local p = self:_cubicBezier01(bezier, cur_progress, y_len) + if info[4] ~= nil + and info[5] ~= nil + and (info[4][1] == ThreeD_SPATIAL or info[4][1] == TwoD_SPATIAL) + and info[5][1] == 0 + then + local coord = self:_cubicBezierSpatial( + info['lenInfo'], + value_range[1], + value_range[3], + value_range[4], + value_range[2], + p + ) + if info[4][1] == TwoD_SPATIAL then + return {coord[1], coord[2]} + end + return coord + end + + if type(value_range[1]) == "table" then + local res = {} + for j = 1, #value_range[1] do + res[j] = self._mix(value_range[1][j], value_range[2][j], p, y_len) + end + return res + end + return self._mix(value_range[1], value_range[2], p, y_len) + end + end + end + + local first_info = content[1] + local start_frame = first_info[2][1] + if cur_frame=end_frame then + return deepcopy(last_info[3][2]) + end + + return nil +end + +return AETools diff --git a/scripts/7681581724236582164/AmazingFeature/lua/LumiFamily/LumiEffect.lua b/scripts/7681581724236582164/AmazingFeature/lua/LumiFamily/LumiEffect.lua new file mode 100644 index 0000000000000000000000000000000000000000..bee4c14190a8231d06c80826ceaa131067ca8ad2 --- /dev/null +++ b/scripts/7681581724236582164/AmazingFeature/lua/LumiFamily/LumiEffect.lua @@ -0,0 +1,32 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiEffect = LumiEffect or {} +LumiEffect.__index = LumiEffect +---@class LumiEffect : ScriptComponent + +function LumiEffect.new(construct, ...) + local self = setmetatable({}, LumiEffect) + + self.__lumi_type = "lumi_effect" + self.__lumi_rt_pingpong_type = "custom" + + return self +end + +function LumiEffect:constructor() +end + +function LumiEffect:onStart(comp) +end + +function LumiEffect:onDestroy(comp) +end + +function LumiEffect:updateMaterials(comp, deltaTime) +end + +function LumiEffect:onUpdate(comp, deltaTime) +end + +exports.LumiEffect = LumiEffect +return exports diff --git a/scripts/7681581724236582164/AmazingFeature/lua/LumiFamily/LumiExportData.lua b/scripts/7681581724236582164/AmazingFeature/lua/LumiFamily/LumiExportData.lua new file mode 100644 index 0000000000000000000000000000000000000000..a3dc0aff0a06f7902d1b591d4633141f4be9e8a8 --- /dev/null +++ b/scripts/7681581724236582164/AmazingFeature/lua/LumiFamily/LumiExportData.lua @@ -0,0 +1,539 @@ +local data = {} + +local ae_compDurations = {0, 2} +data.ae_compDurations = ae_compDurations + +local ae_effectType = 'transition' +data.ae_effectType = ae_effectType + +local ae_transitionInputIndex = { + {'LumiLayer_3207-trs', 'InputTex', 1}, + {'LumiLayer_3206-trs-matte-blend', 'InputTex', 0}, + {'LumiLayer_3204-trs-matte-blend', 'InputTex', 0}, +} +data.ae_transitionInputIndex = ae_transitionInputIndex + +local ae_durations = { + ['LumiLayer_3207-trs'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + }, + }, + ['LumiLayer_3205-trs'] = { + ['nodeDuration'] = {{0, 1.43333333333333}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 1.43333333333333}, }, + }, + }, + ['LumiLayer_3206-trs-matte-blend'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 1.43333333333333}, }, + ['baseTex'] = {{0, 2}, }, + ['maskTex'] = {{0, 1.43333333333333}, }, + }, + }, + ['LumiLayer_3203-trs'] = { + ['nodeDuration'] = {{0, 1.43333333333333}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 1.43333333333333}, }, + }, + }, + ['LumiLayer_3204-trs-matte-blend'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 1.43333333333333}, }, + ['baseTex'] = {{0, 2}, }, + ['maskTex'] = {{0, 1.43333333333333}, }, + }, + }, + ['LumiLayer_3201-trs-blend'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['baseTex'] = {{0, 2}, }, + }, + }, +} +data.ae_durations = ae_durations + +local ae_attribute = { + ['LumiLayer_3207-trs'] = { + ['hasBlend'] = false, + ['hasMatte'] = false, + ['hasTransform'] = true, + ['layerType'] = 'Precomp', + ['anchorPoint'] = Amaz.Vector3f(540, 540, 0), + ['position'] = Amaz.Vector3f(540, 540, 0), + ['scale'] = Amaz.Vector3f(98.9609530725875, 98.9609530725875, 98.9609530725875), + ['orientation'] = Amaz.Vector3f(0, 0, 0), + ['xRotation'] = 0, + ['yRotation'] = 0, + ['rotation'] = -0.93514223467123, + ['opacity'] = 100, + ['active_cam_fovx'] = 39.6, + ['compositeSize'] = Amaz.Vector2f(1080, 1080), + ['layerSize'] = Amaz.Vector2f(1080, 1080), + ['mirrorEdge'] = true, + }, + ['LumiLayer_3205-trs'] = { + ['hasBlend'] = false, + ['hasMatte'] = false, + ['hasTransform'] = true, + ['layerType'] = 'Solid', + ['anchorPoint'] = Amaz.Vector3f(540, 270.5, 0), + ['position'] = Amaz.Vector3f(0, -270, 0), + ['scale'] = Amaz.Vector3f(90, 90, 100), + ['orientation'] = Amaz.Vector3f(0, 0, 0), + ['xRotation'] = 0, + ['yRotation'] = 10, + ['rotation'] = 0, + ['opacity'] = 100, + ['active_cam_fovx'] = 39.6, + ['p0_anchorPoint'] = Amaz.Vector3f(0, 0, 0), + ['p0_position'] = Amaz.Vector3f(540, 540, -1500), + ['p0_scale'] = Amaz.Vector3f(100, 100, 100), + ['p0_orientation'] = Amaz.Vector3f(0, 0, 0), + ['p0_xRotation'] = 0, + ['p0_yRotation'] = 0, + ['p0_rotation'] = 90, + ['p0_opacity'] = 100, + ['p0_active_cam_fovx'] = 39.6, + ['compositeSize'] = Amaz.Vector2f(1080, 1080), + ['layerSize'] = Amaz.Vector2f(1080, 541), + ['mirrorEdge'] = false, + }, + ['LumiLayer_3206-trs-matte-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = true, + ['hasTransform'] = true, + ['layerType'] = 'Precomp', + ['anchorPoint'] = Amaz.Vector3f(540, 540, 0), + ['position'] = Amaz.Vector3f(540, 540.5, 0), + ['scale'] = Amaz.Vector3f(100, 100, 100), + ['orientation'] = Amaz.Vector3f(0, 0, 0), + ['xRotation'] = 0, + ['yRotation'] = 0, + ['rotation'] = 0, + ['opacity'] = 100, + ['active_cam_fovx'] = 39.6, + ['p0_anchorPoint'] = Amaz.Vector3f(540, 270.5, 0), + ['p0_position'] = Amaz.Vector3f(0, -270, 0), + ['p0_scale'] = Amaz.Vector3f(90, 90, 100), + ['p0_orientation'] = Amaz.Vector3f(0, 0, 0), + ['p0_xRotation'] = 0, + ['p0_yRotation'] = 10, + ['p0_rotation'] = 0, + ['p0_opacity'] = 100, + ['p0_active_cam_fovx'] = 39.6, + ['p1_anchorPoint'] = Amaz.Vector3f(0, 0, 0), + ['p1_position'] = Amaz.Vector3f(540, 540, -1500), + ['p1_scale'] = Amaz.Vector3f(100, 100, 100), + ['p1_orientation'] = Amaz.Vector3f(0, 0, 0), + ['p1_xRotation'] = 0, + ['p1_yRotation'] = 0, + ['p1_rotation'] = 90, + ['p1_opacity'] = 100, + ['p1_active_cam_fovx'] = 39.6, + ['compositeSize'] = Amaz.Vector2f(1080, 1080), + ['layerSize'] = Amaz.Vector2f(1080, 1080), + ['mirrorEdge'] = false, + ['matteMode'] = 0, + ['blendMode'] = 0, + }, + ['LumiLayer_3203-trs'] = { + ['hasBlend'] = false, + ['hasMatte'] = false, + ['hasTransform'] = true, + ['layerType'] = 'Solid', + ['anchorPoint'] = Amaz.Vector3f(540, 270.5, 0), + ['position'] = Amaz.Vector3f(0, 270, 0), + ['scale'] = Amaz.Vector3f(90, 90, 100), + ['orientation'] = Amaz.Vector3f(0, 0, 0), + ['xRotation'] = 0, + ['yRotation'] = -10, + ['rotation'] = 0, + ['opacity'] = 100, + ['active_cam_fovx'] = 39.6, + ['p0_anchorPoint'] = Amaz.Vector3f(0, 0, 0), + ['p0_position'] = Amaz.Vector3f(540, 540, -1500), + ['p0_scale'] = Amaz.Vector3f(100, 100, 100), + ['p0_orientation'] = Amaz.Vector3f(0, 0, 0), + ['p0_xRotation'] = 0, + ['p0_yRotation'] = 0, + ['p0_rotation'] = 90, + ['p0_opacity'] = 100, + ['p0_active_cam_fovx'] = 39.6, + ['compositeSize'] = Amaz.Vector2f(1080, 1080), + ['layerSize'] = Amaz.Vector2f(1080, 541), + ['mirrorEdge'] = false, + }, + ['LumiLayer_3204-trs-matte-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = true, + ['hasTransform'] = true, + ['layerType'] = 'Precomp', + ['anchorPoint'] = Amaz.Vector3f(540, 540, 0), + ['position'] = Amaz.Vector3f(540, 0.5, 0), + ['scale'] = Amaz.Vector3f(100, 100, 100), + ['orientation'] = Amaz.Vector3f(0, 0, 0), + ['xRotation'] = 0, + ['yRotation'] = 0, + ['rotation'] = 0, + ['opacity'] = 100, + ['active_cam_fovx'] = 39.6, + ['p0_anchorPoint'] = Amaz.Vector3f(540, 270.5, 0), + ['p0_position'] = Amaz.Vector3f(0, 270, 0), + ['p0_scale'] = Amaz.Vector3f(90, 90, 100), + ['p0_orientation'] = Amaz.Vector3f(0, 0, 0), + ['p0_xRotation'] = 0, + ['p0_yRotation'] = -10, + ['p0_rotation'] = 0, + ['p0_opacity'] = 100, + ['p0_active_cam_fovx'] = 39.6, + ['p1_anchorPoint'] = Amaz.Vector3f(0, 0, 0), + ['p1_position'] = Amaz.Vector3f(540, 540, -1500), + ['p1_scale'] = Amaz.Vector3f(100, 100, 100), + ['p1_orientation'] = Amaz.Vector3f(0, 0, 0), + ['p1_xRotation'] = 0, + ['p1_yRotation'] = 0, + ['p1_rotation'] = 90, + ['p1_opacity'] = 100, + ['p1_active_cam_fovx'] = 39.6, + ['compositeSize'] = Amaz.Vector2f(1080, 1080), + ['layerSize'] = Amaz.Vector2f(1080, 1080), + ['mirrorEdge'] = false, + ['matteMode'] = 0, + ['blendMode'] = 0, + }, + ['LumiLayer_3201-trs-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = true, + ['layerType'] = 'Solid', + ['anchorPoint'] = Amaz.Vector3f(540, 540, 0), + ['position'] = Amaz.Vector3f(540, 540, 0), + ['scale'] = Amaz.Vector3f(100, 100, 100), + ['orientation'] = Amaz.Vector3f(0, 0, 0), + ['xRotation'] = 0, + ['yRotation'] = 0, + ['rotation'] = 0, + ['opacity'] = 0, + ['active_cam_fovx'] = 39.6, + ['compositeSize'] = Amaz.Vector2f(1080, 1080), + ['layerSize'] = Amaz.Vector2f(1080, 1080), + ['mirrorEdge'] = false, + ['blendMode'] = 0, + }, +} +data.ae_attribute = ae_attribute + +local ae_keyframes = { + ['LumiLayer_3207-trs#scale#vector'] = +{ + { + {0.65,0.65,0.65, 0,0,0, 0.1,0.1,0.1, 1,1,1, }, + {0.833333, 1.966667, }, + {{0, 0, 0, }, {100, 100, 100, }, }, + {6414, }, + {0, }, + }, +}, + ['LumiLayer_3207-trs#rotation#number'] = +{ + { + {0.65, 0, 0.1, 1, }, + {0.833333, 1.966667, }, + {{-90, }, {0, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiLayer_3207-trs#opacity#number'] = +{ + { + {1, 0, 0, 1, }, + {1.166667, 1.5, }, + {{0, }, {100, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiLayer_3205-trs#scale#vector'] = +{ + { + {0.3,0.3,0.3, 0,0,0.3, 0.2,0.2,0.2, 1,1,0.2, }, + {0, 0.833333, }, + {{100, 100, 100, }, {90, 90, 100, }, }, + {6414, }, + {0, }, + }, +}, + ['LumiLayer_3205-trs#yRotation#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {0, 1, }, + {{0, }, {10, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiLayer_3205-trs#p0_position#vector'] = +{ + { + {0.9, 0, 0.2, 1, }, + {0.666667, 1.666667, }, + {{540, 540, 0, }, {540, 540, -1500, }, {540, 540, -250, }, {540, 540, -1250, }, }, + {6413, }, + {0, }, + }, +}, + ['LumiLayer_3205-trs#p0_scale#vector'] = +{ + { + {0.3,0.3,0.3, 0,0,0.3, 0.2,0.2,0.2, 1,1,0.2, }, + {0, 0.833333, }, + {{100, 100, 100, }, {65, 65, 100, }, }, + {6414, }, + {0, }, + }, + { + {0.67,0.67,0.67, 0,0,0.67, 0.4,0.4,0.4, 1,1,0.4, }, + {0.833333, 1.666667, }, + {{65, 65, 100, }, {100, 100, 100, }, }, + {6414, }, + {0, }, + }, +}, + ['LumiLayer_3205-trs#p0_rotation#number'] = +{ + { + {0.9, 0, 0.2, 1, }, + {0.666667, 1.666667, }, + {{0, }, {90, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiLayer_3206-trs-matte-blend#p0_scale#vector'] = +{ + { + {0.3,0.3,0.3, 0,0,0.3, 0.2,0.2,0.2, 1,1,0.2, }, + {0, 0.833333, }, + {{100, 100, 100, }, {90, 90, 100, }, }, + {6414, }, + {0, }, + }, +}, + ['LumiLayer_3206-trs-matte-blend#p0_yRotation#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {0, 1, }, + {{0, }, {10, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiLayer_3206-trs-matte-blend#p1_position#vector'] = +{ + { + {0.9, 0, 0.2, 1, }, + {0.666667, 1.666667, }, + {{540, 540, 0, }, {540, 540, -1500, }, {540, 540, -250, }, {540, 540, -1250, }, }, + {6413, }, + {0, }, + }, +}, + ['LumiLayer_3206-trs-matte-blend#p1_scale#vector'] = +{ + { + {0.3,0.3,0.3, 0,0,0.3, 0.2,0.2,0.2, 1,1,0.2, }, + {0, 0.833333, }, + {{100, 100, 100, }, {65, 65, 100, }, }, + {6414, }, + {0, }, + }, + { + {0.67,0.67,0.67, 0,0,0.67, 0.4,0.4,0.4, 1,1,0.4, }, + {0.833333, 1.666667, }, + {{65, 65, 100, }, {100, 100, 100, }, }, + {6414, }, + {0, }, + }, +}, + ['LumiLayer_3206-trs-matte-blend#p1_rotation#number'] = +{ + { + {0.9, 0, 0.2, 1, }, + {0.666667, 1.666667, }, + {{0, }, {90, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiLayer_3203-trs#scale#vector'] = +{ + { + {0.3,0.3,0.3, 0,0,0.3, 0.2,0.2,0.2, 1,1,0.2, }, + {0, 0.833333, }, + {{100, 100, 100, }, {90, 90, 100, }, }, + {6414, }, + {0, }, + }, +}, + ['LumiLayer_3203-trs#yRotation#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {0, 1, }, + {{0, }, {-10, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiLayer_3203-trs#p0_position#vector'] = +{ + { + {0.9, 0, 0.2, 1, }, + {0.666667, 1.666667, }, + {{540, 540, 0, }, {540, 540, -1500, }, {540, 540, -250, }, {540, 540, -1250, }, }, + {6413, }, + {0, }, + }, +}, + ['LumiLayer_3203-trs#p0_scale#vector'] = +{ + { + {0.3,0.3,0.3, 0,0,0.3, 0.2,0.2,0.2, 1,1,0.2, }, + {0, 0.833333, }, + {{100, 100, 100, }, {65, 65, 100, }, }, + {6414, }, + {0, }, + }, + { + {0.67,0.67,0.67, 0,0,0.67, 0.4,0.4,0.4, 1,1,0.4, }, + {0.833333, 1.666667, }, + {{65, 65, 100, }, {100, 100, 100, }, }, + {6414, }, + {0, }, + }, +}, + ['LumiLayer_3203-trs#p0_rotation#number'] = +{ + { + {0.9, 0, 0.2, 1, }, + {0.666667, 1.666667, }, + {{0, }, {90, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiLayer_3204-trs-matte-blend#p0_scale#vector'] = +{ + { + {0.3,0.3,0.3, 0,0,0.3, 0.2,0.2,0.2, 1,1,0.2, }, + {0, 0.833333, }, + {{100, 100, 100, }, {90, 90, 100, }, }, + {6414, }, + {0, }, + }, +}, + ['LumiLayer_3204-trs-matte-blend#p0_yRotation#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {0, 1, }, + {{0, }, {-10, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiLayer_3204-trs-matte-blend#p1_position#vector'] = +{ + { + {0.9, 0, 0.2, 1, }, + {0.666667, 1.666667, }, + {{540, 540, 0, }, {540, 540, -1500, }, {540, 540, -250, }, {540, 540, -1250, }, }, + {6413, }, + {0, }, + }, +}, + ['LumiLayer_3204-trs-matte-blend#p1_scale#vector'] = +{ + { + {0.3,0.3,0.3, 0,0,0.3, 0.2,0.2,0.2, 1,1,0.2, }, + {0, 0.833333, }, + {{100, 100, 100, }, {65, 65, 100, }, }, + {6414, }, + {0, }, + }, + { + {0.67,0.67,0.67, 0,0,0.67, 0.4,0.4,0.4, 1,1,0.4, }, + {0.833333, 1.666667, }, + {{65, 65, 100, }, {100, 100, 100, }, }, + {6414, }, + {0, }, + }, +}, + ['LumiLayer_3204-trs-matte-blend#p1_rotation#number'] = +{ + { + {0.9, 0, 0.2, 1, }, + {0.666667, 1.666667, }, + {{0, }, {90, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiLayer_3201-trs-blend#opacity#number'] = +{ + { + {0.9, 0, 0.9, 1, }, + {1.2, 1.366667, }, + {{0, }, {100, }, }, + {6417, }, + {0, }, + }, + { + {0.1, 0, 0.1, 1, }, + {1.366667, 1.533333, }, + {{100, }, {0, }, }, + {6417, }, + {0, }, + }, +}, +} +data.ae_keyframes = ae_keyframes + +local ae_reverseKeyframes = false +data.ae_reverseKeyframes = ae_reverseKeyframes + +local ae_sliderInfos = { +} +data.ae_sliderInfos = ae_sliderInfos + +local ae_fadeinInfos = { + time = 0, + infos = { + } +} +data.ae_fadeinInfos = ae_fadeinInfos + +local ae_fadeoutInfos = { + time = 0, + infos = { + } +} +data.ae_fadeoutInfos = ae_fadeoutInfos + +local ae_animationInfos = { + animationMode = 0, + loopStart = 0, + speedInfo = {1, 0, 1, }, +} +data.ae_animationInfos = ae_animationInfos + +return data diff --git a/scripts/7681581724236582164/AmazingFeature/lua/LumiFamily/LumiManager.lua b/scripts/7681581724236582164/AmazingFeature/lua/LumiFamily/LumiManager.lua new file mode 100644 index 0000000000000000000000000000000000000000..7a07ee24e9b82500e89114ce8cb3a85474915e38 --- /dev/null +++ b/scripts/7681581724236582164/AmazingFeature/lua/LumiFamily/LumiManager.lua @@ -0,0 +1,554 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiManager = LumiManager or {} +LumiManager.__index = LumiManager +---@class LumiManager : ScriptComponent +---@field debugTime number [UI(Range={0, 6}, Drag)] +---@field autoPlay boolean +---@field lumiEffectRoot Transform +---@field start_render_layer int +---@field start_render_order int + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local EffectType = { + Effect = 'effect', + Transition = 'transition', + VideoAnimation = 'videoAnimation', + EffectXT = 'xtEffect', + FilterXT = 'xtFilter', +} + +local AnimationMode = { + Once = 0, + Loop = 1, + StretchOnce = 2, + StretchLoop = 3, +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +local function remap(value, srcMin, srcMax, dstMin, dstMax) + return dstMin + (value - srcMin) * (dstMax - dstMin) / (srcMax - srcMin) +end + +local function handleAllEntityBySingleParent(_trans, func, ...) + if _trans.children:size() > 0 then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i - 1) + handleAllEntityBySingleParent(child, func, ...) + end + end + func(_trans, ...) +end + +local function intervalIntersection(intervals1, intervals2) + local result = {} + local i = 1 + local j = 1 + + while i <= #intervals1 and j <= #intervals2 do + local start1 = intervals1[i][1] + local end1 = intervals1[i][2] + local start2 = intervals2[j][1] + local end2 = intervals2[j][2] + + local start = math.max(start1, start2) + local end_ = math.min(end1, end2) + + if start <= end_ then + table.insert(result, {start, end_}) + end + if end1 < end2 then + i = i + 1 + else + j = j + 1 + end + end + return result +end + +function LumiManager.new(construct, ...) + local self = setmetatable({}, LumiManager) + + self.lumiEffectRoot = nil + self.start_render_layer = 1 + self.start_render_order = 1 + + self.InputTex = nil + self.OutputTex = nil + self.PingPongTex = nil + + self.startTime = 0.0 + self.endTime = 6.0 + self.curTime = 0.0 + + self.speed = 1.0 + self.animationMode = AnimationMode.Once + self.autoPlay = true + self.debugTime = 0.0 + + -- for XT + self.cameraStartTime = 0 + self.lastCycle = -1 + + return self +end + +function LumiManager:getKeyframeAeTime(aeTime) + if self.isReverseKeyframes ~= true then + return aeTime + end + return self.compDurations[1] + self.compDurations[2] - aeTime +end + +function LumiManager:onStart(comp) + self.entity = comp.entity + + self.lumi_obj_extension = includeRelativePath("LumiObjectExtension") + self.lumi_obj = nil + + self.keyframes = nil + self.durations = nil + self.params = nil + self.compDurations = {0, 6} + self.animationInfos = 0 + self.sliderInfos = {} + self.fadeinInfos = {} + self.fadeoutInfos = {} + self.effectType = "effect" + self.transitionInputIndex = {} + + self.LumiParamsSetter = includeRelativePath("LumiParamsSetter") + local ae_export_data = includeRelativePath("LumiExportData") + if ae_export_data then + if ae_export_data.ae_keyframes then + local ae_tools = includeRelativePath("AETools") + if ae_tools then + self.keyframes = ae_tools.new(ae_export_data.ae_keyframes) + end + end + if ae_export_data.ae_reverseKeyframes ~= nil then + self.isReverseKeyframes = ae_export_data.ae_reverseKeyframes + end + if ae_export_data.ae_durations ~= nil then + self.durations = ae_export_data.ae_durations + end + if ae_export_data.ae_attribute ~= nil then + self.params = ae_export_data.ae_attribute + end + if ae_export_data.ae_compDurations ~= nil then + self.compDurations = ae_export_data.ae_compDurations + self.compDurations[2] = self.compDurations[2] + end + if ae_export_data.ae_animationInfos ~= nil then + self.animationInfos = ae_export_data.ae_animationInfos + self.animationMode = self.animationInfos.animationMode + self.loopStart = self.animationInfos.loopStart + self.speed = self.animationInfos.speedInfo[1] + end + if ae_export_data.ae_sliderInfos ~= nil then + self.sliderInfos = ae_export_data.ae_sliderInfos + end + if ae_export_data.ae_fadeinInfos ~= nil then + self.fadeinInfos = ae_export_data.ae_fadeinInfos + end + if ae_export_data.ae_fadeoutInfos ~= nil then + self.fadeoutInfos = ae_export_data.ae_fadeoutInfos + end + if ae_export_data.ae_effectType ~= nil then + self.effectType = ae_export_data.ae_effectType + end + if ae_export_data.ae_cameraMode ~= nil then + self.cameraMode = ae_export_data.ae_cameraMode + end + if ae_export_data.ae_transitionInputIndex ~= nil then + self.transitionInputIndex = ae_export_data.ae_transitionInputIndex + end + end + if self.LumiParamsSetter then + self.lumi_params_setter = self.LumiParamsSetter.new( + self, + self.params, + self.keyframes, + self.effectType, + self.sliderInfos, + self.fadeinInfos, + self.fadeoutInfos + ) + end + + if self.effectType == EffectType.VideoAnimation then + local baseEntity = self.entity:searchEntity('base') + local videoCamera = baseEntity:searchEntity('videoCamera'):getComponent('Camera') + local videoRenderer = baseEntity:searchEntity('video'):getComponent('MeshRenderer') + local modelCamera = baseEntity:searchEntity('modelCamera'):getComponent('Camera') + local modelRenderer = baseEntity:searchEntity('model'):searchEntity('quad'):getComponent('MeshRenderer') + local fxaaCamera = baseEntity:searchEntity('fxaaCamera'):getComponent('Camera') + local fxaaRenderer = baseEntity:searchEntity('fxaa'):getComponent('MeshRenderer') + local bgCamera = baseEntity:searchEntity('bgCamera'):getComponent('Camera') + local bgRenderer = baseEntity:searchEntity('bg'):getComponent('MeshRenderer') + local blendCamera = baseEntity:searchEntity('blendCamera'):getComponent('Camera') + local blendRenderer = baseEntity:searchEntity('blend'):getComponent('MeshRenderer') + self.videoAnimationCameraAndRenderer = { + { camera = videoCamera, renderer = videoRenderer }, + { camera = modelCamera, renderer = modelRenderer }, + { camera = fxaaCamera, renderer = fxaaRenderer }, + { camera = bgCamera, renderer = bgRenderer }, + { camera = blendCamera, renderer = blendRenderer }, + } + end +end + +function LumiManager:onDestroy(comp) + if self.lumiEffectRoot and self.lumi_obj_extension then + self.lumi_obj_extension.deregister(self.lumiEffectRoot.entity) + end + self.lumi_obj = nil + self.LumiParamsSetter = nil +end + +function LumiManager:getCameraCount() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return 0 + end + + self.lumi_obj = nil + self:ReRender() + + local cam_count = 0 + if self.lumi_obj then + cam_count = self.lumi_obj:getCameraCount() + Amaz.LOGI(AE_EFFECT_TAG, self.lumi_obj.entity.name .. " camera_count: " .. tostring(cam_count)) + end + return cam_count +end + +function LumiManager:ReRender() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + -- re register + self.lumi_obj = nil + self:registerLumiObj(self.lumiEffectRoot, 1) + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'No lumi_obj register') + return + end + + -- change layer & order + self:updateCameraLayerAndOrder() + + -- change rt pingpong + self:updateRtPingpong() +end + +function LumiManager:registerLumiObj(_trans, _idx) + if _trans == nil then return end + local script_comp = _trans.entity:getComponent("ScriptComponent") + if script_comp then + local lua_obj = Amaz.ScriptUtils.getLuaObj(script_comp:getScript()) + if lua_obj then + self.lumi_obj_extension.deregister(_trans.entity) + self.lumi_obj = self.lumi_obj_extension.register(_trans.entity) + end + end +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str .. "0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiManager:updateCameraLayerAndOrder() + if self.lumi_obj then + local cur_start_layer, cur_start_order = self.lumi_obj:updateCameraLayerAndOrder(self.start_render_layer, self.start_render_order) + + if self.effectType == EffectType.VideoAnimation then + cur_start_layer = cur_start_layer + 10 + cur_start_order = cur_start_order + 10 + + for i = 1, #self.videoAnimationCameraAndRenderer do + local cameraAndRenderer = self.videoAnimationCameraAndRenderer[i] + local camera = cameraAndRenderer.camera + local renderer = cameraAndRenderer.renderer + camera.renderOrder = cur_start_order + _setLayer(camera, cur_start_layer) + renderer.entity.layer = cur_start_layer + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end +end + +function LumiManager:updateRtPingpong() + if self.lumi_obj then + self.lumi_obj:updateRt(self.InputTex, self.OutputTex, self.PingPongTex) + end +end + +function LumiManager:updateOutputRtSize() + if self.lumi_obj then + self.lumi_obj:updateOutputRtSize(self.width, self.height) + end +end + +function LumiManager:initVideoAnimationLua(comp) + local modelEntity = comp.entity:searchEntity("model") + if modelEntity then + local scriptComp = modelEntity:getComponent("ScriptComponent") + if scriptComp then + self.videoAnimationLua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + end + end +end + +function LumiManager:onUpdate(comp, deltaTime) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.durations and not self.isSetDuration then + for entityName, durationMap in pairs(self.durations) do + local isLumiLayer = string.sub(entityName, 1, string.len('LumiLayer')) == 'LumiLayer' + if isLumiLayer then + local texDuration = durationMap['texDuration'] + local srcDuration = texDuration['InputTex'] + local baseDuration = texDuration['baseTex'] + local maskDuration = texDuration['maskTex'] + if srcDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'srcDuration', srcDuration) + end + if baseDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'baseDuration', baseDuration) + end + if maskDuration then + local matteDuration = intervalIntersection(maskDuration, srcDuration) + self.lumi_obj:setSubEffectAttr(entityName, 'matteDuration', matteDuration) + end + end + end + self.isSetDuration = true + end + + local w = Amaz.BuiltinObject.getInputTextureWidth() + local h = Amaz.BuiltinObject.getInputTextureHeight() + if self.InputTex then + w = self.InputTex.width + h = self.InputTex.height + end + if self.OutputTex and (self.OutputTex.width ~= w or self.OutputTex.height ~= h) then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid rt size, input: ' .. w .. 'x' .. h .. ', output: ' .. self.OutputTex.width .. 'x' .. self.OutputTex.height) + end + if self.width == nil or self.width ~= w or self.height == nil or self.height ~= h then + self.width = w + self.height = h + self:updateOutputRtSize() + end + + self.curTime = self.curTime + deltaTime + if isEditor then + self.curTime = self.curTime % self.endTime + end + local curTime = (self.curTime - self.startTime) * self.speed + self.startTime + local startTime = self.startTime + local endTime = (self.endTime - self.startTime) * self.speed + self.startTime + + if self.cameraMode then + if self.animationMode ~= AnimationMode.Loop then + Amaz.LOGE(AE_EFFECT_TAG, 'Camera mode is not support animationMode: ' .. tostring(self.animationMode)) + return + end + curTime = self.curTime - self.cameraStartTime + endTime = math.huge + elseif self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT then -- deprecated after 1810 in XT + startTime = 0 + if self.isVideo == 1 then + endTime = self.videoTime + else + curTime = 0 + endTime = 3 + end + end + + local aeTime = curTime; + local aeDuration = math.max(0.001, self.compDurations[2] - self.compDurations[1]) + if endTime < curTime then + aeTime = math.max(self.compDurations[1], self.compDurations[2] - (self.endTime - self.curTime)) + else + local lvDuration = math.max(0.001, endTime - startTime) + if self.animationMode == AnimationMode.Once then + aeTime = self.compDurations[1] + curTime - startTime + aeTime = math.min(aeTime, self.compDurations[2]) + elseif self.animationMode == AnimationMode.Loop then + if self.cameraMode then + local cycle = math.floor((curTime - startTime) / aeDuration) + if self.lastCycle ~= cycle then + self.lastCycle = cycle + comp.entity.scene:sendMessage(4999, 1, 0, '') + end + end + if math.floor((curTime - startTime) / aeDuration) < 1 then + aeTime = self.compDurations[1] + (curTime - startTime) % aeDuration + else + local curLoopStart = (self.loopStart - self.compDurations[1]) * self.speed + self.compDurations[1] + aeTime = self.loopStart + (curTime - startTime - curLoopStart) % (aeDuration - self.loopStart) + end + elseif self.animationMode == AnimationMode.StretchOnce then + aeTime = remap(curTime, startTime, self.endTime, self.compDurations[1], self.compDurations[2]) + aeTime = clamp(aeTime, self.compDurations[1], self.compDurations[2]) + elseif self.animationMode == AnimationMode.StretchLoop then + local newCurTime = startTime + (curTime - startTime) * self.speed % lvDuration + aeTime = remap(newCurTime, startTime, endTime, self.compDurations[1], self.compDurations[2]) + + if math.floor((curTime - startTime) * self.speed / lvDuration) >= 1 then + aeTime = self.compDurations[1] + (aeTime - self.compDurations[1]) % (self.compDurations[2] - self.loopStart) + self.loopStart + end + end + end + + if self.effectType == EffectType.Transition then + local input1 = Amaz.BuiltinObject.getUserTexture("#TransitionInput0") + local input2 = Amaz.BuiltinObject.getUserTexture("#TransitionInput1") + if input1 and input2 then + for index, transitionInputInfo in ipairs(self.transitionInputIndex) do + local entityName = transitionInputInfo[1] + local texName = transitionInputInfo[2] + local inputIndex = transitionInputInfo[3] + if inputIndex == 0 then + self.lumi_obj:setSubEffectAttr(entityName, texName, input1) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 0) + else + self.lumi_obj:setSubEffectAttr(entityName, texName, input2) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 1) + end + end + aeTime = Amaz.Input.frameTimestamp * (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + end + elseif self.effectType == EffectType.VideoAnimation then + if self.videoAnimationLua == nil then + self:initVideoAnimationLua(comp) + end + if self.videoAnimationLua ~= nil then + aeTime = remap(self.videoAnimationLua.curTime, 0, self.videoAnimationLua.duration, self.compDurations[1], self.compDurations[2]) + end + end + + if isEditor then + if self.autoPlay then + self.debugTime = curTime % (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + aeTime = self.debugTime + else + aeTime = self.debugTime + end + elseif self.effectType == EffectType.VideoAnimation or self.effectType == EffectType.Transition then + self.curTime = aeTime + end + + if self.lumi_obj then + self.lumi_obj:setEffectAttrRecursively("startTime", self.startTime) + self.lumi_obj:setEffectAttrRecursively("endTime", self.endTime) + self.lumi_obj:setEffectAttrRecursively("curTime", self.curTime) + self.lumi_obj:setEffectAttrRecursively("aeTime", aeTime) + self.lumi_obj:setEffectAttrRecursively("aeDuration", aeDuration) + end + + if self.lumi_params_setter and self.lumi_params_setter.initParams then + self.lumi_params_setter:initParams(self.lumi_obj) + end + if self.lumi_params_setter and self.lumi_params_setter.updateKeyFrameData then + self.lumi_params_setter:updateKeyFrameData(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateSlider then + self.lumi_params_setter:updateSlider(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateFade then + if self.effectType == EffectType.Effect then + self.lumi_params_setter:updateFade(self.lumi_obj, self.startTime, self.endTime, self.curTime, self.compDurations, aeTime) + end + end + + if self.lumi_obj and self.durations ~= nil then + aeTime = math.min(math.max(aeTime, self.compDurations[1]), self.compDurations[2]) + for entityName, durationMap in pairs(self.durations) do + local nodeDuration = durationMap['nodeDuration'] + local visible = false + for j = 1, #nodeDuration do + if nodeDuration[j][1] <= aeTime and aeTime < nodeDuration[j][2] then + visible = true + break + end + end + self.lumi_obj:setVisible(entityName, visible) + end + end + if self.lumi_obj and self.lumi_obj.updateMaterials then + self.lumi_obj:updateMaterials(deltaTime) + end +end + +-- function LumiManager:onLateUpdate(comp, deltaTime) +-- collectgarbage("collect") +-- end + +function LumiManager:onEvent(comp, event) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Failed to find lumi_obj') + return + end + + if self.effectType == EffectType.Effect then + if event.args:get(0) == 'effects_adjust_speed' then + local value = event.args:get(1) + if self.animationInfos then + if value < 0 or value > 1 then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid effects_adjust_speed value: ' .. value) + end + self.speed = remap(clamp(value, 0, 1), 0, 1, self.animationInfos.speedInfo[2], self.animationInfos.speedInfo[3]) + else + self.speed = value + end + end + elseif event.args:get(0) == 'start_time' and self.cameraMode then + self.cameraStartTime = event.args:get(2) + elseif event.args:get(0) == 'is_video' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.isVideo = event.args:get(2) + elseif event.args:get(0) == 'video_time' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.videoTime = event.args:get(2) + end + + if self.lumi_params_setter and self.lumi_params_setter.onEvent then + self.lumi_params_setter:onEvent(self.lumi_obj, event) + end +end + +exports.LumiManager = LumiManager +return exports diff --git a/scripts/7681581724236582164/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua b/scripts/7681581724236582164/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua new file mode 100644 index 0000000000000000000000000000000000000000..c1e528b6007352c9831b71df7a92892be83703dc --- /dev/null +++ b/scripts/7681581724236582164/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua @@ -0,0 +1,436 @@ + +local LumiObjectExtension = {} +LumiObjectExtension.__index = LumiObjectExtension + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag-LumiObjectExtension' + +local function handleAllEntityBySingleParent(_trans, func, func2, ...) + if _trans.children:size() > 0 and func2(_trans, ...) then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i-1) + handleAllEntityBySingleParent(child, func, func2, ...) + end + end + func(_trans, ...) +end + +local function CreateRenderTexture(width, height) + local rt = Amaz.RenderTexture() + rt.width = width + rt.height = height + rt.depth = 1 + rt.filterMag = Amaz.FilterMode.LINEAR + rt.filterMin = Amaz.FilterMode.LINEAR + rt.filterMipmap = Amaz.FilterMipmapMode.NONE + rt.attachment = Amaz.RenderTextureAttachment.NONE + return rt +end + +function LumiObjectExtension.register(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + + local self = setmetatable({}, LumiObjectExtension) + self.entity = _ent + self.scriptComp = scriptComp + self.trans = _ent:getComponent("Transform") + self.effect_lua = effect_lua + if effect_lua.__lumi_type~= nil then + self.__lumi_type = effect_lua.__lumi_type + else + self.__lumi_type = "lumi_obj" + end + if effect_lua.__lumi_rt_pingpong_type~= nil then + self.__lumi_rt_pingpong_type = effect_lua.__lumi_rt_pingpong_type + else + self.__lumi_rt_pingpong_type = "custom" + end + + if self.entity:getComponents("Camera"):size() > 0 then + Amaz.LOGE(AE_EFFECT_TAG, "Error: root entity has camera attached") + return nil + end + self.subLumiObjExt = {} + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local objExt = LumiObjectExtension.register(child.entity) + if objExt and child.entity.name ~= '' then + self.subLumiObjExt[child.entity.name] = objExt + end + end + end + effect_lua.__lumi_obj_ext = self + return self +end + +function LumiObjectExtension.deregister(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + local lumi_obj = effect_lua.__lumi_obj_ext + if lumi_obj == nil then return nil end + + if lumi_obj.__lumi_type == "lumi_effect" then + for i = 1, lumi_obj.trans.children:size() do + local child = lumi_obj.trans.children:get(i-1) + LumiObjectExtension.deregister(child.entity) + end + end + lumi_obj.entity = nil + lumi_obj.trans = nil + lumi_obj.effect_lua = nil + lumi_obj.scriptComp = nil + lumi_obj.subLumiObjExt = nil + lumi_obj.__lumi_type = nil + lumi_obj.__lumi_rt_pingpong_type = nil + effect_lua.__lumi_obj_ext = nil +end + +function LumiObjectExtension.getLumiObjExt(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + return effect_lua.__lumi_obj_ext +end + +function LumiObjectExtension:searchSubLumiObjExt(name) + if self.trans.entity.name == name then + return self + end + if name and self.subLumiObjExt[name] then + return self.subLumiObjExt[name] + end + for _, subObj in pairs(self.subLumiObjExt) do + local obj = subObj:searchSubLumiObjExt(name) + if obj then + return obj + end + end + return nil +end + +function LumiObjectExtension:setInputTex(_tex) + if self.effect_lua then + self.effect_lua.InputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('InputTex', _tex) + end + end +end + +function LumiObjectExtension:setOutputTex(_tex) + if self.effect_lua then + self.effect_lua.OutputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('OutputTex', _tex) + end + end +end + +function LumiObjectExtension:getInputTex() + if self.effect_lua then + return self.effect_lua.InputTex + end + return nil +end + +function LumiObjectExtension:getOutputTex() + if self.effect_lua then + return self.effect_lua.OutputTex + end + return nil +end + +function LumiObjectExtension:setInputTexSizes(inputSize, originalSize) + assert(type(inputSize)=="table", "inputSize should be table") + if self.effect_lua and self.effect_lua.setInputTexSize then + self.effect_lua:setInputTexSize(inputSize) + end + if self.effect_lua and self.effect_lua.setInputOriginalTexSize then + self.effect_lua:setInputOriginalTexSize(originalSize) + end + self._inputTexSize, self._originalTexSize = inputSize, originalSize +end + +function LumiObjectExtension:getOutputTexSizes() + local inputSize = (self.effect_lua and self.effect_lua.getOutputTexSize) and self.effect_lua:getOutputTexSize() or self._inputTexSize + local originalSize = (self.effect_lua and self.effect_lua.getOutputOriginalTexSize) and self.effect_lua:getOutputOriginalTexSize() or self._originalTexSize + return inputSize, originalSize +end + +function LumiObjectExtension:needChangeOutputTexSize() + if self.effect_lua and self.effect_lua.__lumi_will_change_out_size then + return self.effect_lua.__lumi_will_change_out_size + end + if self._inputTexSize~=nil and self.effect_lua and self.effect_lua.getOutputTexSize then + local outSize = self.effect_lua:getOutputTexSize() + return (outSize[1] ~= self._inputTexSize[1] or outSize[2] ~= self._inputTexSize[2]) + end + return false +end + +function LumiObjectExtension:updateRt(_input_tex, _output_tex, _pingpong_tex) + self:setInputTex(_input_tex) + self:setOutputTex(_output_tex) + if self.effect_lua and self.effect_lua.updateRenderTexture ~= nil then + self.effect_lua:updateRenderTexture() + end + if self.__lumi_type == "lumi_effect" and self.__lumi_rt_pingpong_type == "auto" then + local lumi_obj_list = {} + local function collect_lumi_obj(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and (lumi_obj_ext.__lumi_type == "lumi_obj" or lumi_obj_ext.__lumi_rt_pingpong_type == "custom") then + table.insert(lumi_obj_list, lumi_obj_ext) + end + end + local function collect_lumi_obj_flag(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and lumi_obj_ext.__lumi_type == "lumi_effect" and lumi_obj_ext.__lumi_rt_pingpong_type == "auto" then + return true + end + return false + end + handleAllEntityBySingleParent(self.trans, collect_lumi_obj, collect_lumi_obj_flag) + + if _pingpong_tex then + self._pingpong_tex = _pingpong_tex + elseif #lumi_obj_list > 1 then + self._pingpong_tex = CreateRenderTexture(_output_tex.width, _output_tex.height) + end + local pingpong = { _output_tex, self._pingpong_tex } + if #lumi_obj_list%2 == 0 then + pingpong = { self._pingpong_tex, _output_tex } + end + for i = 1, #lumi_obj_list do + local lumi_obj = lumi_obj_list[i] + if lumi_obj then + local idx1 = (i-1)%2+1 + local idx2 = (i)%2+1 + if i == 1 then + lumi_obj:setInputTex(_input_tex) + lumi_obj:setOutputTex(pingpong[idx1]) + else + lumi_obj:setInputTex(pingpong[idx2]) + lumi_obj:setOutputTex(pingpong[idx1]) + end + if lumi_obj.effect_lua and lumi_obj.effect_lua.updateRenderTexture ~= nil then + lumi_obj.effect_lua:updateRenderTexture() + end + end + end + end +end + +function LumiObjectExtension:updateOutputRtSize(width, height) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i - 1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateOutputRtSize(width, height) + end + end + end + local tex = self:getOutputTex() + if tex then + tex.width = width + tex.height = height + end +end + +function LumiObjectExtension:getCameraCount() + local cam_count = 0 + + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + cam_count = cam_count + lumi_obj_ext:getCameraCount() + else + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + elseif self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + + return cam_count +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str.."0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiObjectExtension:updateCameraLayerAndOrder(_start_layer, _start_order) + function updateRendererEntityLayer(trans, layer) + local renderers = trans.entity:getComponentsRecursive("Renderer") + for i = 0, renderers:size() - 1 do + local renderer = renderers:get(i) + if renderer then + renderer.entity.layer = layer + end + end + end + + local lastCamera = nil + + local cur_start_layer = _start_layer + local cur_start_order = _start_order + + if self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local curTrans = self.trans.children:get(i-1) + local cam = curTrans.entity:getComponent("Camera") + if cam then + if lastCamera then + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + lastCamera = cam + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, curTrans.children:size() do + local rendererTrans = curTrans.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + elseif lastCamera then + updateRendererEntityLayer(curTrans, cur_start_layer) + end + end + + elseif self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateCameraLayerAndOrder(cur_start_layer, cur_start_order) + local cam_count = lumi_obj_ext:getCameraCount() + cur_start_layer = cur_start_layer + cam_count + cur_start_order = cur_start_order + cam_count + else + local cam = child.entity:getComponent("Camera") + if cam then + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, child.children:size() do + local rendererTrans = child.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end + end + + return cur_start_layer, cur_start_order +end + +function LumiObjectExtension:setEffectAttr(key, value) + if self.effect_lua and self.effect_lua.setEffectAttr ~= nil then + self.effect_lua:setEffectAttr(key, value, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + self.effect_lua[key] = value + if self.scriptComp and self.scriptComp.properties ~= nil then + self.scriptComp.properties:set(key, value) + end + end + end +end + +function LumiObjectExtension:getEffectAttr(key) + if self.effect_lua and self.effect_lua.getEffectAttr ~= nil then + return self.effect_lua:getEffectAttr(key, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + return self.effect_lua[key] + end + end + return nil +end + +function LumiObjectExtension:setSubEffectAttr(subName, key, value) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + subObj:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:getSubEffectAttr(subName, key) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + return subObj:getEffectAttr(key) + end + return nil +end + +function LumiObjectExtension:setEffectAttrRecursively(key, value) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:setEffectAttrRecursively(key, value) + end + end + self:setEffectAttr(key, value) + elseif self.__lumi_type == "lumi_obj" then + self:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:updateMaterials(time) + if self.effect_lua and self.scriptComp and self.entity and self.entity.visible then + if self.effect_lua.updateMaterial ~= nil then + self.effect_lua:updateMaterial(self.scriptComp, time) + elseif self.effect_lua.onUpdate ~= nil then + self.effect_lua:onUpdate(self.scriptComp, time) + end + + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateMaterials(time) + end + end + end +end + +function LumiObjectExtension:setVisible(subName, visible) + local subObj = self:searchSubLumiObjExt(subName) + if subObj and subObj.effect_lua then + if subObj.effect_lua.setVisible then + subObj.effect_lua:setVisible(visible) + else + subObj.entity.visible = visible + end + end +end + +return LumiObjectExtension diff --git a/scripts/7681581724236582164/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua b/scripts/7681581724236582164/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua new file mode 100644 index 0000000000000000000000000000000000000000..91587ae17803e82e95608198114893dfe226a5c9 --- /dev/null +++ b/scripts/7681581724236582164/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua @@ -0,0 +1,388 @@ +local LumiParamsSetter = {} +LumiParamsSetter.__index = LumiParamsSetter + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +function LumiParamsSetter.new(lumiManager, params, keyframes, effectType, sliderInfos, fadeinInfos, fadeoutInfos) + local self = setmetatable({}, LumiParamsSetter) + self.lumiManager = lumiManager + self.params = params + self.keyframes = keyframes + self.sliderInfos = sliderInfos + self.sliderParams = {} + self.XTEvent = (effectType == 'xtFilter' or effectType == 'xtEffect') + self.fadeinInfos = fadeinInfos + self.fadeoutInfos = fadeoutInfos + self.afterSliderParams = {} + + return self +end + +local function clamp(val, min, max) + return math.max(math.min(val, max), min) +end + +local function mix(a, b, t) + return a * (1 - t) + b * t +end + +local function cvtTable2Amaz(attrType, v) + local value = nil + if attrType == "number" then + if #v == 1 then + value = v[1] + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "vector" then + if #v == 2 then + value = Amaz.Vector2f(v[1], v[2]) + elseif #v == 3 then + value = Amaz.Vector3f(v[1], v[2], v[3]) + elseif #v == 4 then + value = Amaz.Vector4f(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "color" then + if #v == 3 then + value = Amaz.Color(v[1], v[2], v[3], 1.0) + elseif #v == 4 then + value = Amaz.Color(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. "unsupported type: " .. attrType) + end + return value +end + +local function getValueType(value) + local valueType = type(value) + if valueType == 'userdata' then + local str = tostring(value) + if string.sub(str, 1, 6) == 'Vector' then + valueType = 'vector' + elseif string.sub(str, 1, 5) == 'Color' then + valueType = 'color' + end + end + + return valueType +end + +local function add(value, number) + local type = getValueType(value) + if type == 'number' then + return value + number + elseif type == 'vector' then + local ret = value:copy() + ret.x = ret.x + number + ret.y = ret.y + number + if ret.z then ret.z = ret.z + number end + if ret.w then ret.w = ret.w + number end + return ret + elseif type == 'color' then + return Amaz.Color( + value.r + number, + value.g + number, + value.b + number, + value.a + number + ) + end + return nil +end + +local function mul(value, number) + local type = getValueType(value) + if type == 'color' then + return Amaz.Color( + value.r * number, + value.g * number, + value.b * number, + value.a * number + ) + end + return value * number +end + +function LumiParamsSetter:getCurrentDefaultParam(entityName, key, aeTime) + local keyframeName = nil + local keyframeType = 'number' + if self.keyframes ~= nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'number' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'vector' + keyframeType = 'vector' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'color' + keyframeType = 'color' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = nil + end + end + end + + if keyframeName == nil then + if entityName:sub(1, #'LumiLayer') == 'LumiLayer' and key:sub(-#'position') == 'position' then + local entity = self.params[entityName] + if entity ~= nil then + local position = entity[key] + if position ~= nil then + local hasSeparated = false + local newPosition = position:copy() + + local newKey = string.gsub(key, 'position', 'xPosition') + local newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.x = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'yPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.y = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'zPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.z = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + if hasSeparated then + return newPosition + end + end + end + end + end + end + + local value = nil + if keyframeName ~= nil then + value = cvtTable2Amaz(keyframeType, self.keyframes:GetVal(keyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + else + local entity = self.params[entityName] + if entity ~= nil then + value = entity[key] + end + end + return value +end + +function LumiParamsSetter:updateSlider(lumi_obj, aeTime) + -- local sliderIntensity = self.sliderParams['effects_adjust_blur'] + -- local gaussianIntensity = self:getCurrentDefaultParam("Gaussian_Blur_Root_353-effect2", 'intensity', aeTime) + -- if sliderIntensity and gaussianIntensity then + -- lumi_obj:setSubEffectAttr("Gaussian_Blur_Root_353-effect2", 'intensity', gaussianIntensity*sliderIntensity) + -- end + + local function fsub(value, slider, valueA, valueB) + -- (param - sliderValue) * valueA + valueB + return (value - slider) * valueA + valueB + end + + local function fmul(value, slider, valueA, valueB) + -- (param - valueA) * sliderValue + valueB + return (value - valueA) * slider + valueB + end + + local function fadd(value, slider, valueA, valueB) + -- (param - valueA) * valueB + sliderValue + return (value - valueA) * valueB + slider + end + + self.afterSliderParams = {} + for sliderKey, paramsInfos in pairs(self.sliderInfos) do + if self.sliderParams[sliderKey] ~= nil then + for index, value in ipairs(paramsInfos) do + local sliderIntensity = self.sliderParams[sliderKey] + local entityName = value[1] + local paramKey = value[2] + local paramType = value[3] + local paramDimensionFlag = value[4] + local calcType = value[5] + local maxValue = value[6] + local minValue = value[7] + local defaultValue = value[8] + local valueA = value[9] + local valueB = value[10] + sliderIntensity = sliderIntensity * (maxValue - minValue) + minValue + local oriValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + oriValue = self.afterSliderParams[entityName .. '#' .. paramKey] + end + local newValue = oriValue + local calcFunc = nil + if calcType == 0 then + calcFunc = fsub + elseif calcType == 1 then + calcFunc = fmul + elseif calcType == 2 then + calcFunc = fadd + else + Amaz.LOGE(AE_EFFECT_TAG, 'Unknown calcType: ' .. calcType) + return + end + if paramType == 'number' then + if paramDimensionFlag[1] then newValue = calcFunc(oriValue, sliderIntensity, valueA[1], valueB[1]) end + elseif paramType == 'color' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.r = calcFunc(oriValue.r, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.g = calcFunc(oriValue.g, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.b = calcFunc(oriValue.b, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.a = calcFunc(oriValue.a, sliderIntensity, valueA[4], valueB[4]) end + elseif paramType == 'vector' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.x = calcFunc(oriValue.x, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.y = calcFunc(oriValue.y, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.z = calcFunc(oriValue.z, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.w = calcFunc(oriValue.w, sliderIntensity, valueA[4], valueB[4]) end + end + lumi_obj:setSubEffectAttr(entityName, paramKey, newValue) + self.afterSliderParams[entityName .. '#' .. paramKey] = newValue + end + end + end +end + +function LumiParamsSetter:updateFadeParams(lumi_obj, fadeInfos, factor, aeTime) + for i = 1, #fadeInfos.infos do + local entityName = fadeInfos.infos[i][1] + local paramKey = fadeInfos.infos[i][2] + local valueType = fadeInfos.infos[i][3] + local value = fadeInfos.infos[i][4] + + local curValue = nil + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + curValue = self.afterSliderParams[entityName .. '#' .. paramKey] + else + curValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + end + + if curValue ~= nil then + local needRenew = true + if valueType == 'number' then + curValue = mix(value[1], curValue, factor) + elseif valueType == 'color' then + curValue.r = mix(value[1], curValue.r, factor) + curValue.g = mix(value[2], curValue.g, factor) + curValue.b = mix(value[3], curValue.b, factor) + curValue.a = mix(value[4], curValue.a, factor) + elseif valueType == 'vector' then + if #value <= 1 or #value >= 5 then + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid value size: ' .. #value) + else + if #value >= 2 then + curValue.x = mix(value[1], curValue.x, factor) + curValue.y = mix(value[2], curValue.y, factor) + end + if #value >= 3 then + curValue.z = mix(value[3], curValue.z, factor) + end + if #value >= 4 then + curValue.w = mix(value[4], curValue.w, factor) + end + end + else + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid valye type: ' .. valueType) + end + if needRenew then + lumi_obj:setSubEffectAttr(entityName, paramKey, curValue) + end + end + end +end + +function LumiParamsSetter:updateFade(lumi_obj, startTime, endTime, curTime, compDurations, aeTime) + local scale = (endTime - startTime) / (compDurations[2] - compDurations[1]) + scale = clamp(scale, 0, 1) + local runningTime = curTime - startTime + local remainingTime = endTime - curTime + + local isInFadein = false + if self.fadeinInfos + and self.fadeinInfos.time and self.fadeinInfos.time > 0 + and self.fadeinInfos.infos and #self.fadeinInfos.infos > 0 + then + local fadeinTime = self.fadeinInfos.time * scale + if runningTime <= fadeinTime then + isInFadein = true + local factor = runningTime / fadeinTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeinInfos, factor, aeTime) + end + end + + if self.fadeoutInfos + and self.fadeoutInfos.time and self.fadeoutInfos.time > 0 + and self.fadeoutInfos.infos and #self.fadeoutInfos.infos > 0 + then + local fadeoutTime = self.fadeoutInfos.time * scale + if remainingTime <= fadeoutTime or not isInFadein then + local factor = remainingTime / fadeoutTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeoutInfos, factor, aeTime) + end + end +end + +function LumiParamsSetter:onEvent(lumi_obj, event) + if lumi_obj == nil or event == nil then return end + local key = event.args:get(0) + if self.sliderInfos[key] ~= nil then + if self.XTEvent then + self.sliderParams[key] = event.args:get(2); + else + self.sliderParams[key] = event.args:get(1); + end + end +end + +function LumiParamsSetter:initParams(lumi_obj) + if lumi_obj == nil then return end + if self.params == nil then return end + if self.init then return end + + for entityName, params in pairs(self.params) do + for key, value in pairs(params) do + lumi_obj:setSubEffectAttr(entityName, key, value) + end + end + + self.init = true +end + +function LumiParamsSetter:updateKeyFrameData(lumi_obj, aeTime) + if lumi_obj == nil then return end + if self.keyframes == nil then return end + + local p = aeTime + for key, _ in pairs(self.keyframes.attrs) do + local keys = {} + for substr in string.gmatch(key, "[^#]+") do + table.insert(keys, substr) + end + if #keys == 3 then + local entityName = keys[1] + local attrName = keys[2] + local attrType = keys[3] + local v = self.keyframes:GetVal(key, self.lumiManager:getKeyframeAeTime(p)) + local value = cvtTable2Amaz(attrType, v) + if value then + lumi_obj:setSubEffectAttr(entityName, attrName, value) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key) + end + end +end + +return LumiParamsSetter diff --git a/scripts/7681581724236582164/config.json b/scripts/7681581724236582164/config.json new file mode 100644 index 0000000000000000000000000000000000000000..f9f7287f3fcdee5ab82c91658a262c507bc8d2f1 --- /dev/null +++ b/scripts/7681581724236582164/config.json @@ -0,0 +1,15 @@ +{ + "ae_tool": "AEExporter:1.5.4", + "bALG_BACH_CONFIG": false, + "effect": { + "Link": [ + { + "path": "AmazingFeature/", + "type": "AmazingFeature", + "zorder": 8029 + } + ] + }, + "name": "AE2Effect_20260904161203855", + "version": "14.8.0" +} \ No newline at end of file diff --git a/scripts/7681581724236582164/extra.json b/scripts/7681581724236582164/extra.json new file mode 100644 index 0000000000000000000000000000000000000000..f4e6b748e1b7b1b6f1c714fedd8c7b87ebaef725 --- /dev/null +++ b/scripts/7681581724236582164/extra.json @@ -0,0 +1,6 @@ +{ + "transition": { + "defaultDura": 2.000001, + "isOverlap": true + } +} \ No newline at end of file diff --git a/scripts/7681583945162444053/AmazingFeature/content.json b/scripts/7681583945162444053/AmazingFeature/content.json new file mode 100644 index 0000000000000000000000000000000000000000..df43720515b1b6981b24c4268c902195fa613d43 --- /dev/null +++ b/scripts/7681583945162444053/AmazingFeature/content.json @@ -0,0 +1,7 @@ +{ + "ae_tool" : "AmazingEditor", + "content" : {}, + "needblend" : false, + "tag" : "AMG_1515088281693380358513659446614427937212", + "version" : "1.0" +} \ No newline at end of file diff --git a/scripts/7681583945162444053/AmazingFeature/js/JSSys.js b/scripts/7681583945162444053/AmazingFeature/js/JSSys.js new file mode 100644 index 0000000000000000000000000000000000000000..bbcbf36f0f75c1beebe88c33dd0464bb4477158e --- /dev/null +++ b/scripts/7681583945162444053/AmazingFeature/js/JSSys.js @@ -0,0 +1,89 @@ +const effect_api = "undefined" != typeof effect ? effect : "undefined" != typeof tt ? tt : "undefined" != typeof lynx ? lynx : {}; +const Amaz = effect_api.getAmaz(); + +const { ScriptScene } = require('./ThreeJS/scriptScene'); +const THREE = require('./ThreeJS/three-amg-wrapper').THREE; + +class JSSys { + constructor() { + this.name = "JSSys"; + this.comps = {} + this.compsdirty = true + } + + onComponentAdded(comp) { + // console.log("running:JSSys:onComponentAdded"); + } + onComponentRemoved(comp) { + // console.log("running:JSSys:onComponentRemoved"); + } + + onStart() { + console.log("running:JSSys:onStart"); + + this.renderTexture = this.scene.assetMgr.SyncLoad('rt/outputTex.rt'); + + // 添加光源到场景 + console.log('JSSys: 创建ScriptScene实例'); + this.scriptScene = new ScriptScene(this.scene); + + this.input = Amaz.AmazingManager.getSingleton("Input"); + const builtinObject = Amaz.AmazingManager.getSingleton("BuiltinObject"); + + if (builtinObject.getUserTexture("#TransitionInput0") && builtinObject.getUserTexture("#TransitionInput1")) { + this.scriptScene.texture1 = new THREE.Texture(); + this.scriptScene.texture1.setImage(builtinObject.getUserTexture("#TransitionInput0")); + this.scriptScene.texture2 = new THREE.Texture(); + this.scriptScene.texture2.setImage(builtinObject.getUserTexture("#TransitionInput1")); + console.log("JSSys: 获取到纹理"); + } + else + { + this.scriptScene.texture1 = new THREE.Texture(); + this.scriptScene.texture1.setImage(this.scene.assetMgr.SyncLoad('image/Sample1.jpg')); + this.scriptScene.texture2 = new THREE.Texture(); + this.scriptScene.texture2.setImage(this.scene.assetMgr.SyncLoad('image/Sample2.jpg')); + console.log("JSSys: 未获取到纹理,使用默认纹理"); + } + + this.scriptScene.setupScene(); + // 初始化后处理效果 + if (this.scriptScene.initPostProcessing != null) { + this.scriptScene.initPostProcessing(); + } + } + + onUpdate(deltaTime) { + this.time = this.input.getFrameTimestamp(); + // this.time = this.time % 2; + // this.time = this.time / 2.0; + this.scriptScene.seekToTime(this.time * this.scriptScene.Duration); + // this.scriptScene.updateScene(); + } + onLateUpdate(deltaTime) { + // console.log("running:JSSys:onLateUpdate"); + this.scriptScene.scene.seekToTime(this.time * this.scriptScene.Duration); + } + + onEvent(event) { + console.log("running:JSSys:onEvent"); + if (event.type == Amaz.EventType.VIEWER) { + // console.log("JSSys: 窗口大小改变"); + console.log("renderTexture.width",this.renderTexture.width); + console.log("renderTexture.height",this.renderTexture.height); + + window.innerWidth = this.renderTexture.width; + window.innerHeight = this.renderTexture.height; + // console.log("JSSys: 窗口大小改变"); + this.scriptScene.handleResize(); + } + } + + onDestroy() { + // console.log("running:JSSys:onDestroy"); + this.scriptScene.destroy(); + } +} + +exports.JSSys = JSSys; + diff --git a/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/EffectComposer.js b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/EffectComposer.js new file mode 100644 index 0000000000000000000000000000000000000000..e7d8fd7a3f3978d9da1a9bf29af1854806f60014 --- /dev/null +++ b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/EffectComposer.js @@ -0,0 +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{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-6*k)*Math.cos(12*k)};const springStiff=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(18*k)};const dampedOscillation=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(10*k)};const Physics=Object.freeze({SpringSoft:springSoft,SpringStiff:springStiff,DampedOscillation:dampedOscillation});const anticipate=k=>{if(k<=0)return 0;if(k>=1)return 1;const pullback=.1;if(k<.3){const p=k/.3;return-pullback*p*(2-p)}const p=(k-.3)/.7;return-pullback+(1+pullback)*p*p*(3-2*p)};const overshootFactory=peak=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return peak*p*(2-p)}const p=(k-.6)/.4;return peak+(1-peak)*(1-Math.pow(1-p,3))};const overshoot110=overshootFactory(1.1);const overshoot125=overshootFactory(1.25);const snapBack=k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return 1.05*(1-Math.pow(1-p,3))}const p=(k-.6)/.4;return 1.05-.05*p*p*(3-2*p)};const swing=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.cos(1.5*Math.PI*k)*Math.exp(-2.5*k)};const Motion=Object.freeze({Anticipate:anticipate,Overshoot110:overshoot110,Overshoot125:overshoot125,SnapBack:snapBack,Swing:swing});const makeStep=(n,jumpTerm="end")=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(jumpTerm==="start")return Math.ceil(k*n)/n;return Math.floor(k*n)/n};const Step=Object.freeze({Steps4End:makeStep(4,"end"),Steps8End:makeStep(8,"end"),Steps12End:makeStep(12,"end")});function buildCubicBezier(x1,y1,x2,y2){const cx=3*x1,bx=3*(x2-x1)-cx,ax=1-cx-bx;const cy=3*y1,by=3*(y2-y1)-cy,ay=1-cy-by;const sampleX=s=>((ax*s+bx)*s+cx)*s;const sampleY=s=>((ay*s+by)*s+cy)*s;const sampleDX=s=>(3*ax*s+2*bx)*s+cx;const solveS=x=>{let s=x;for(let i=0;i<8;i++){const cur=sampleX(s)-x;if(Math.abs(cur)<1e-6)return s;const d=sampleDX(s);if(Math.abs(d)<1e-6)break;s-=cur/d;if(s<0)s=0;if(s>1)s=1}let lo=0,hi=1;for(let i=0;i<32&&hi-lo>1e-6;i++){const mid=(lo+hi)/2;if(sampleX(mid){if(k<=0)return 0;if(k>=1)return 1;return sampleY(solveS(k))}}const BEZIER_PRESETS=Object.freeze({"Material.Standard":[.4,0,.2,1],"Material.Accelerate":[.4,0,1,1],"Material.Decelerate":[0,0,.2,1],"CSS.Ease":[.25,.1,.25,1]});const _bezierCache=new Map;function _cachedBezier(x1,y1,x2,y2){const key=x1+","+y1+","+x2+","+y2;let fn=_bezierCache.get(key);if(!fn){fn=buildCubicBezier(x1,y1,x2,y2);_bezierCache.set(key,fn)}return fn}function cubicBezier(a,b,c,d){if(typeof a==="string"){let preset=BEZIER_PRESETS[a];if(!preset){console.warn("[customEasings.cubicBezier] unknown preset, falling back to Material.Standard:",a);preset=BEZIER_PRESETS["Material.Standard"]}return _cachedBezier(preset[0],preset[1],preset[2],preset[3])}const clamp=(v,lo,hi)=>Math.max(lo,Math.min(hi,v));const x1=clamp(a,0,1);const y1=clamp(b,-.5,1.5);const x2=clamp(c,0,1);const y2=clamp(d,-.5,1.5);return _cachedBezier(x1,y1,x2,y2)}const libSpring=({stiffness=180,damping=12,mass=1}={})=>{const DT=1/240;const T=1.5;let x=0,v=0;const samples=[];for(let t=0;t<=T;t+=DT){const force=-stiffness*(x-1)-damping*v;v+=force/mass*DT;x+=v*DT;samples.push({t:t,x:x})}let T_end=T;for(let i=samples.length-1;i>=0;i--){if(Math.abs(samples[i].x-1)>.01){T_end=samples[i].t;break}}return k=>{if(k<=0)return 0;if(k>=1)return 1;const t=k*T_end;const idx=Math.min(samples.length-1,Math.floor(t/DT));return samples[idx].x}};const libHeartBeat=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c)=>Math.exp(-((t-c)**2)/(2*.07*.07));return peak*(bell(k,.2)+bell(k,.5))};const libSteps=(n=6)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return Math.floor(k*n)/n};const attentionPing=(peak=.35,decay=2)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(Math.PI*k)*Math.exp(-decay*k)};const attentionWiggle=(count=4,amplitude=.25)=>k=>{if(k<=0||k>=1)return 0;const env=1-k;return amplitude*env*Math.sin(k*Math.PI*2*count)};const attentionStrum=(notes=4,peak=.4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*.05*.05))}return peak*sum}};const Attention=Object.freeze({Ping:attentionPing(),Wiggle:attentionWiggle(),Strum:attentionStrum()});const breathNormal=(cycles=2,peak=.15)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(k*Math.PI*2*cycles)*Math.sin(k*Math.PI)};const breathDeep=(peak=.3,riseRatio=.35,holdRatio=.15)=>{const holdEnd=riseRatio+holdRatio;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const envelope=Math.sin(k*Math.PI);const wave=.5+.5*Math.sin(k*Math.PI*2*cycles-Math.PI/2);return peak*envelope*wave};const breathSigh=(peak=.25,riseRatio=.2)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return peak*Math.exp(-((k-center)**2)/(2*width*width))};const heartExcited=(beats=4,peak=.3,width=.04)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*width*width))}return peak*sum}};const heartLubDub=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return peak*(bell(k,.25,.045)+.6*bell(k,.42,.03))};const Heart=Object.freeze({Calm:heartCalm(),Excited:heartExcited(),LubDub:heartLubDub()});const mathJumpArc=()=>k=>{if(k<=0||k>=1)return 0;return 4*k*(1-k)};const mathPendulum=(damping=3,freq=2.5)=>k=>{if(k<=0||k>=1)return 0;return Math.sin(k*Math.PI)*Math.exp(-damping*k)*Math.cos(freq*Math.PI*k)};const mathTremor=(amplitude=.04,freq=22)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return k+amplitude*Math.sin(k*Math.PI*2*freq)};const mathBoomerang=fn=>k=>{if(k<=0||k>=1)return 0;return k<.5?fn(k*2):fn(2-k*2)};const MathExt=Object.freeze({JumpArc:mathJumpArc(),Pendulum:mathPendulum(),Tremor:mathTremor()});const explosionImpulse=(sharpness=6)=>{const tail=sharpness*Math.exp(1-sharpness);return k=>{if(k<=0||k>=1)return 0;const h=sharpness*k;return h*Math.exp(1-h)-tail*k}};const explosionFlash=(rise=.05,decay=5)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return-Math.exp(-decay*k)*Math.cos(freq*Math.PI*k)};const explosionImplosion=(charge=.3,depth=.4,burstPeak=1.2)=>{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const w=Math.sin(k*Math.PI*2*cycles)+.5*Math.sin(k*Math.PI*2*cycles*1.5+1.2)+.25*Math.sin(k*Math.PI*2*cycles*3+2.4);return amplitude*env*w*.6};const natureFlicker=(rate=15,intensity=.2,seed=7)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=rate+1;i++)samples.push(rand());return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*rate;const idx=Math.floor(pos);const t=pos-idx;const a=samples[idx];const b=samples[idx+1];const interp=a+(b-a)*t;return intensity*env*(interp-.5)*2}};const natureGust=(gusts=3,peak=.25)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*.08*.08))}return peak*sum/gusts*1.8}};const Nature=Object.freeze({Wave:natureWave(),Flicker:natureFlicker(),Gust:natureGust()});const impactRain=(impactAt=.7,rippleAmp=.08)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const liftEnd=.35,strikeEnd=.6;return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return t*t}const t=(k-.4)/.6;const env=Math.exp(-2.5*t);const wave=Math.abs(Math.sin(t*Math.PI*bounces));return 1-env*wave*rebound};const impactSlap=(contactAt=.3,holdRatio=.1)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return.4*Math.pow(t,2.5)}if(k<.48){const t=(k-.4)/.08;return.4-.2*t}if(k<.52){const t=(k-.48)/.04;return.2+.8*t}const t=(k-.52)/.48;return 1-.04*Math.sin(t*Math.PI*8)*(1-t)};const rhythmPunchCombo=(peak=.4)=>{const pattern=[{c:.15,w:.04,a:.75},{c:.35,w:.04,a:.75},{c:.7,w:.055,a:1}];return k=>{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of pattern){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return peak*sum}};const rhythmStaccato=(beats=4,duty=.3)=>k=>{if(k<=0||k>=1)return 0;const beatLen=1/beats;const phase=k/beatLen-Math.floor(k/beatLen);if(phase>duty)return 0;const t=phase/duty;return Math.sin(t*Math.PI)};const rhythmKick=(peak=1.2)=>k=>{if(k<=0||k>=1)return 0;if(k<.05)return peak*k/.05;const t=(k-.05)/.95;return peak*Math.exp(-4*t)};const rhythmCrescendo=(beats=4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return sum}};const rhythmDunDunDun=()=>{const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return k=>{if(k<=0||k>=1)return 0;return.3*bell(k,.15,.025)+.6*bell(k,.35,.03)+1*bell(k,.68,.09)}};const rhythmBellToll=(decay=3,freq=8)=>{const strike=.05;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.2){const t=k/.2;return-pressDepth*Math.sin(t*Math.PI/2)}if(k<.5){const t=(k-.2)/.3;return-pressDepth+(pressDepth+reboundPeak)*(1-Math.pow(1-t,3))}const t=(k-.5)/.5;return reboundPeak*Math.exp(-4*t)*Math.cos(t*Math.PI*3)};const uiHoverBloom=(riseRatio=.2,fallRatio=.3)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=1-k;const raw=Math.sin(k*Math.PI*2*count);const clipped=Math.sign(raw)*Math.min(1,Math.abs(raw)*1.8);return amplitude*env*clipped};const uiSuccessPop=(overshoot=.2)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return(1+overshoot)*(1-Math.pow(1-t,2))}const t=(k-.4)/.6;return 1+overshoot*Math.exp(-5*t)*Math.cos(t*Math.PI*3)};const uiRippleOut=()=>k=>{if(k<=0||k>=1)return 0;return 6.75*k*Math.pow(1-k,2)};const UI=Object.freeze({ClickSnap:uiClickSnap(),HoverBloom:uiHoverBloom(),ErrorShake:uiErrorShake(),SuccessPop:uiSuccessPop(),RippleOut:uiRippleOut()});const magicManaCharge=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;const base=(Math.exp(3*k)-1)/(Math.exp(3)-1);const pulse=.04*Math.sin(k*Math.PI*8)*k;return base+pulse};const magicSpellCast=(chargeEnd=.4)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.45){const t=k/.45;return t*t*t}if(k<.55)return 1;const t=(k-.55)/.45;return Math.pow(1-t,3)};const magicShield=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.3){const t=k/.3;return 1.2*(1-Math.pow(1-t,2))}if(k<.6){const t=(k-.3)/.3;return 1.2-.2*t}const t=(k-.6)/.4;return 1+.03*Math.sin(t*Math.PI*3)};const magicAura=(peak=.15)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const fundamental=.6*Math.sin(k*Math.PI*2);const harmonic=.3*Math.sin(k*Math.PI*4+1);const overtone=.1*Math.sin(k*Math.PI*6+2);return peak*env*(fundamental+harmonic+overtone)};const Magic=Object.freeze({ManaCharge:magicManaCharge(),SpellCast:magicSpellCast(),Teleport:magicTeleport(),Shield:magicShield(),MagicAura:magicAura()});const animalCatPounce=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.2){const t=k/.2;return-.2*Math.sin(t*Math.PI)}if(k<.3){const t=(k-.2)/.1;return.5*t*t}if(k<.8){const t=(k-.3)/.5;return.5+.5*t+.2*Math.sin(t*Math.PI)}const t=(k-.8)/.2;return 1+.05*Math.sin(t*Math.PI)};const animalBirdFlap=(flaps=4)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const phase=k*Math.PI*2*flaps;const wave=Math.sin(phase)-.3*Math.sin(phase*2);return.2*env*wave};const animalSnakeSlither=(waves=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const wave=Math.sin(k*Math.PI*2*waves);return.2*env*wave};const animalButterflyFlit=(seed=13)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=26;i++)samples.push(rand()-.5);return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*25;const idx=Math.floor(pos);const t=pos-idx;const smooth=t*t*(3-2*t);const interp=samples[idx]+(samples[idx+1]-samples[idx])*smooth;return.3*env*interp}};const animalHorseGallop=(cycles=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const cyclePos=k*cycles-Math.floor(k*cycles);const bell=(c,w=.04)=>Math.exp(-((cyclePos-c)**2)/(2*w*w));return.25*env*(bell(0)+bell(.18)+bell(.36)+bell(.54))};const Animal=Object.freeze({CatPounce:animalCatPounce(),BirdFlap:animalBirdFlap(),SnakeSlither:animalSnakeSlither(),ButterflyFlit:animalButterflyFlit(),HorseGallop:animalHorseGallop()});const Progress=Object.freeze({Physics:Object.freeze({...Physics,Spring:libSpring()}),Motion:Motion,Step:Object.freeze({...Step,Steps6:libSteps()}),Math:Object.freeze({Tremor:MathExt.Tremor}),Impact:Object.freeze({Rain:Impact.Rain,Hammer:Impact.Hammer,BounceDrop:Impact.BounceDrop,ArrowHit:Impact.ArrowHit,Shatter:Impact.Shatter}),Rhythm:Object.freeze({BassDrop:Rhythm.BassDrop}),UI:Object.freeze({SuccessPop:UI.SuccessPop}),Magic:Object.freeze({ManaCharge:Magic.ManaCharge,Shield:Magic.Shield}),Animal:Object.freeze({CatPounce:Animal.CatPounce})});const Pulse=Object.freeze({Attention:Object.freeze({Ping:Attention.Ping}),Breath:Object.freeze({Deep:Breath.Deep,Sigh:Breath.Sigh}),Heart:Object.freeze({Calm:Heart.Calm}),Math:Object.freeze({JumpArc:MathExt.JumpArc,BoomerangSharp:mathBoomerang(E.Cubic.In),BoomerangSoft:mathBoomerang(E.Cubic.Out)}),Explosion:Object.freeze({Impulse:Explosion.Impulse,Flash:Explosion.Flash,Recoil:Explosion.Recoil,Implosion:Explosion.Implosion}),Impact:Object.freeze({Slap:Impact.Slap}),Rhythm:Object.freeze({Kick:Rhythm.Kick}),UI:Object.freeze({ClickSnap:UI.ClickSnap,HoverBloom:UI.HoverBloom,RippleOut:UI.RippleOut}),Magic:Object.freeze({SpellCast:Magic.SpellCast,Teleport:Magic.Teleport})});const Wave=Object.freeze({Attention:Object.freeze({Wiggle:Attention.Wiggle,Strum:Attention.Strum}),Breath:Object.freeze({Normal:Breath.Normal,Panting:Breath.Panting}),Heart:Object.freeze({Excited:Heart.Excited,LubDub:Heart.LubDub,Beat:libHeartBeat()}),Math:Object.freeze({Pendulum:MathExt.Pendulum}),Nature:Nature,Rhythm:Object.freeze({PunchCombo:Rhythm.PunchCombo,Staccato:Rhythm.Staccato,Crescendo:Rhythm.Crescendo,DunDunDun:Rhythm.DunDunDun,BellToll:Rhythm.BellToll}),UI:Object.freeze({ErrorShake:UI.ErrorShake}),Magic:Object.freeze({MagicAura:Magic.MagicAura}),Animal:Object.freeze({BirdFlap:Animal.BirdFlap,SnakeSlither:Animal.SnakeSlither,ButterflyFlit:Animal.ButterflyFlit,HorseGallop:Animal.HorseGallop})});const customEasings=Object.freeze({makeOutIn:makeOutIn,OutIn:OutIn,Progress:Progress,Pulse:Pulse,Wave:Wave,cubicBezier:cubicBezier});exports.customEasings=customEasings;exports.default=customEasings; \ No newline at end of file diff --git a/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/scriptScene.js b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/scriptScene.js new file mode 100644 index 0000000000000000000000000000000000000000..5d5f0a8bde54f7efa0912b77bb0a8298e3fb04e9 --- /dev/null +++ b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/scriptScene.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/three-amg-wrapper.js b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/three-amg-wrapper.js new file mode 100644 index 0000000000000000000000000000000000000000..c2037e314e032c4d36912923d4cc1258cba3ab19 --- /dev/null +++ b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/three-amg-wrapper.js @@ -0,0 +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;iobj.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; \ No newline at end of file diff --git a/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/tween.js b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/tween.js new file mode 100644 index 0000000000000000000000000000000000000000..690fb9e4284728629129deed5a5a3f4bcec291ed --- /dev/null +++ b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/tween.js @@ -0,0 +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=power1e4?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;_i0){this._tweensAddedDuringUpdate={};for(var i=0;i1){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[m1;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;itotalTime){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;ithis.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;ithis.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.xthis.max.x||box.max.ythis.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; \ No newline at end of file diff --git a/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Box3.js b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Box3.js new file mode 100644 index 0000000000000000000000000000000000000000..4100dc7442d3a622827c8a415e24557f68c491f1 --- /dev/null +++ b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Box3.js @@ -0,0 +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=3?array[offset+2]:0;if(xthis.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=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.xthis.max.x||box.max.ythis.max.y||box.max.zthis.max.z)}}exports.Box3=Box3; \ No newline at end of file diff --git a/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..be3b8b1334a62f5e88c45feee098063a199fca55 --- /dev/null +++ b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js @@ -0,0 +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=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; \ No newline at end of file diff --git a/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..af9a8a13a46500e78f082a35e18d0b5932061234 --- /dev/null +++ b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js @@ -0,0 +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;iObject.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;i1?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; \ No newline at end of file diff --git a/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Constants.js b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Constants.js new file mode 100644 index 0000000000000000000000000000000000000000..6b8adda19a4d67236719804f5170889b39fd4582 --- /dev/null +++ b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Constants.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js new file mode 100644 index 0000000000000000000000000000000000000000..29b0aad5599401be17f967ba1d48851acb70c2ac --- /dev/null +++ b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js @@ -0,0 +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;i0||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;i0?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;imaxX)maxX=p.x;if(p.ymaxY)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; \ No newline at end of file diff --git a/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..f3dee08bf1c089e040fcfef228902ab9a39c93cb --- /dev/null +++ b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Earcut.js b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Earcut.js new file mode 100644 index 0000000000000000000000000000000000000000..953abffdf38c2def26df73fed180eff8c7644ced --- /dev/null +++ b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Earcut.js @@ -0,0 +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;imaxX)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=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=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.x&&p.x>=mx&&hx!==p.x&&pointInTriangle(hym.x||p.x===m.x&§orContainsSector(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.xb.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;i0||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=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;i0){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;imaxX)maxX=contour[i].x;if(contour[i].ymaxY)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;layerIdx0?-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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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; \ No newline at end of file diff --git a/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Group.js b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Group.js new file mode 100644 index 0000000000000000000000000000000000000000..90c4dbef65aa04d7a3bb6b6d76ec3317ea65a228 --- /dev/null +++ b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Group.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");class Group extends Object3D{constructor(name="Group_w"){super(name)}dispose(){super.dispose()}}exports.Group=Group; \ No newline at end of file diff --git a/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Material.js b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Material.js new file mode 100644 index 0000000000000000000000000000000000000000..81b97053ad9d1e4b1ef05d5ac6ed992487b2ca8e --- /dev/null +++ b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Material.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..dcf34d4cffb9de0869382a24690f78f60dda6049 --- /dev/null +++ b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js new file mode 100644 index 0000000000000000000000000000000000000000..41e6cd0a0eee7dd7bc497be5deac584806b68dc3 --- /dev/null +++ b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Mesh.js b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Mesh.js new file mode 100644 index 0000000000000000000000000000000000000000..254d69b074e797dd34c16d7dad723bbcc3b4895d --- /dev/null +++ b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Mesh.js @@ -0,0 +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;imaterial,set:value=>{material=value;if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;im.dispose&&m.dispose());else if(this.material.dispose)this.material.dispose()}}}exports.MeshWrapper=MeshWrapper; \ No newline at end of file diff --git a/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..ac394f66efc4e113a7127ee0f50ec672e4c5e9eb --- /dev/null +++ b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Object3D.js b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Object3D.js new file mode 100644 index 0000000000000000000000000000000000000000..8532c6122f839460aab34fe88957802ff523318b --- /dev/null +++ b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Object3D.js @@ -0,0 +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{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&¤tScene._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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js new file mode 100644 index 0000000000000000000000000000000000000000..ba39801de50d38ec04424f3c2ebfa2ff5d28fded --- /dev/null +++ b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js @@ -0,0 +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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..bc595fb80ad9e7c2f4d8360c67dbef556f3d6cbe --- /dev/null +++ b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js @@ -0,0 +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;iy0){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; \ No newline at end of file diff --git a/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..02dc1be955bc766de744222a7e75c65bf147bb61 --- /dev/null +++ b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js @@ -0,0 +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&¶meters.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{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=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=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=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; \ No newline at end of file diff --git a/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Shape.js b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Shape.js new file mode 100644 index 0000000000000000000000000000000000000000..ecde48b5ceb30812c922aa5c7cfe2aa7b50cabe4 --- /dev/null +++ b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Shape.js @@ -0,0 +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;i0){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;i0||(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;imaxX)maxX=p.x;if(p.ymaxY)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;i0?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;ipoints.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;itwoPi)deltaAngle-=twoPi;if(deltaAngle>4;uuid[i]=chars[i===19?r&3|8:r]}}return uuid.join("")}exports.Shape=Shape; \ No newline at end of file diff --git a/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..3786abc7d64ed80b56101c4ac9d30ce9fcb8f941 --- /dev/null +++ b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js @@ -0,0 +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;i0){const bounds=calculateBounds(flatVertices);const vertexOffset=vertices.length/3;for(let j=0;j0){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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}function calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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; \ No newline at end of file diff --git a/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..1ea27a55fbce9fc3771c66840c068e5ff6347092 --- /dev/null +++ b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Texture.js b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Texture.js new file mode 100644 index 0000000000000000000000000000000000000000..35bff49d732c9884e07bfcb5682f18a860485e1f --- /dev/null +++ b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Texture.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Vector2.js b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Vector2.js new file mode 100644 index 0000000000000000000000000000000000000000..a30a2431264ee62cec937714dfa9e50932ddedeb --- /dev/null +++ b/scripts/7681583945162444053/AmazingFeature/js/ThreeJS/wrapper/Vector2.js @@ -0,0 +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)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)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){if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-6*k)*Math.cos(12*k)};const springStiff=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(18*k)};const dampedOscillation=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(10*k)};const Physics=Object.freeze({SpringSoft:springSoft,SpringStiff:springStiff,DampedOscillation:dampedOscillation});const anticipate=k=>{if(k<=0)return 0;if(k>=1)return 1;const pullback=.1;if(k<.3){const p=k/.3;return-pullback*p*(2-p)}const p=(k-.3)/.7;return-pullback+(1+pullback)*p*p*(3-2*p)};const overshootFactory=peak=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return peak*p*(2-p)}const p=(k-.6)/.4;return peak+(1-peak)*(1-Math.pow(1-p,3))};const overshoot110=overshootFactory(1.1);const overshoot125=overshootFactory(1.25);const snapBack=k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return 1.05*(1-Math.pow(1-p,3))}const p=(k-.6)/.4;return 1.05-.05*p*p*(3-2*p)};const swing=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.cos(1.5*Math.PI*k)*Math.exp(-2.5*k)};const Motion=Object.freeze({Anticipate:anticipate,Overshoot110:overshoot110,Overshoot125:overshoot125,SnapBack:snapBack,Swing:swing});const makeStep=(n,jumpTerm="end")=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(jumpTerm==="start")return Math.ceil(k*n)/n;return Math.floor(k*n)/n};const Step=Object.freeze({Steps4End:makeStep(4,"end"),Steps8End:makeStep(8,"end"),Steps12End:makeStep(12,"end")});function buildCubicBezier(x1,y1,x2,y2){const cx=3*x1,bx=3*(x2-x1)-cx,ax=1-cx-bx;const cy=3*y1,by=3*(y2-y1)-cy,ay=1-cy-by;const sampleX=s=>((ax*s+bx)*s+cx)*s;const sampleY=s=>((ay*s+by)*s+cy)*s;const sampleDX=s=>(3*ax*s+2*bx)*s+cx;const solveS=x=>{let s=x;for(let i=0;i<8;i++){const cur=sampleX(s)-x;if(Math.abs(cur)<1e-6)return s;const d=sampleDX(s);if(Math.abs(d)<1e-6)break;s-=cur/d;if(s<0)s=0;if(s>1)s=1}let lo=0,hi=1;for(let i=0;i<32&&hi-lo>1e-6;i++){const mid=(lo+hi)/2;if(sampleX(mid){if(k<=0)return 0;if(k>=1)return 1;return sampleY(solveS(k))}}const BEZIER_PRESETS=Object.freeze({"Material.Standard":[.4,0,.2,1],"Material.Accelerate":[.4,0,1,1],"Material.Decelerate":[0,0,.2,1],"CSS.Ease":[.25,.1,.25,1]});const _bezierCache=new Map;function _cachedBezier(x1,y1,x2,y2){const key=x1+","+y1+","+x2+","+y2;let fn=_bezierCache.get(key);if(!fn){fn=buildCubicBezier(x1,y1,x2,y2);_bezierCache.set(key,fn)}return fn}function cubicBezier(a,b,c,d){if(typeof a==="string"){let preset=BEZIER_PRESETS[a];if(!preset){console.warn("[customEasings.cubicBezier] unknown preset, falling back to Material.Standard:",a);preset=BEZIER_PRESETS["Material.Standard"]}return _cachedBezier(preset[0],preset[1],preset[2],preset[3])}const clamp=(v,lo,hi)=>Math.max(lo,Math.min(hi,v));const x1=clamp(a,0,1);const y1=clamp(b,-.5,1.5);const x2=clamp(c,0,1);const y2=clamp(d,-.5,1.5);return _cachedBezier(x1,y1,x2,y2)}const libSpring=({stiffness=180,damping=12,mass=1}={})=>{const DT=1/240;const T=1.5;let x=0,v=0;const samples=[];for(let t=0;t<=T;t+=DT){const force=-stiffness*(x-1)-damping*v;v+=force/mass*DT;x+=v*DT;samples.push({t:t,x:x})}let T_end=T;for(let i=samples.length-1;i>=0;i--){if(Math.abs(samples[i].x-1)>.01){T_end=samples[i].t;break}}return k=>{if(k<=0)return 0;if(k>=1)return 1;const t=k*T_end;const idx=Math.min(samples.length-1,Math.floor(t/DT));return samples[idx].x}};const libHeartBeat=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c)=>Math.exp(-((t-c)**2)/(2*.07*.07));return peak*(bell(k,.2)+bell(k,.5))};const libSteps=(n=6)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return Math.floor(k*n)/n};const attentionPing=(peak=.35,decay=2)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(Math.PI*k)*Math.exp(-decay*k)};const attentionWiggle=(count=4,amplitude=.25)=>k=>{if(k<=0||k>=1)return 0;const env=1-k;return amplitude*env*Math.sin(k*Math.PI*2*count)};const attentionStrum=(notes=4,peak=.4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*.05*.05))}return peak*sum}};const Attention=Object.freeze({Ping:attentionPing(),Wiggle:attentionWiggle(),Strum:attentionStrum()});const breathNormal=(cycles=2,peak=.15)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(k*Math.PI*2*cycles)*Math.sin(k*Math.PI)};const breathDeep=(peak=.3,riseRatio=.35,holdRatio=.15)=>{const holdEnd=riseRatio+holdRatio;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const envelope=Math.sin(k*Math.PI);const wave=.5+.5*Math.sin(k*Math.PI*2*cycles-Math.PI/2);return peak*envelope*wave};const breathSigh=(peak=.25,riseRatio=.2)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return peak*Math.exp(-((k-center)**2)/(2*width*width))};const heartExcited=(beats=4,peak=.3,width=.04)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*width*width))}return peak*sum}};const heartLubDub=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return peak*(bell(k,.25,.045)+.6*bell(k,.42,.03))};const Heart=Object.freeze({Calm:heartCalm(),Excited:heartExcited(),LubDub:heartLubDub()});const mathJumpArc=()=>k=>{if(k<=0||k>=1)return 0;return 4*k*(1-k)};const mathPendulum=(damping=3,freq=2.5)=>k=>{if(k<=0||k>=1)return 0;return Math.sin(k*Math.PI)*Math.exp(-damping*k)*Math.cos(freq*Math.PI*k)};const mathTremor=(amplitude=.04,freq=22)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return k+amplitude*Math.sin(k*Math.PI*2*freq)};const mathBoomerang=fn=>k=>{if(k<=0||k>=1)return 0;return k<.5?fn(k*2):fn(2-k*2)};const MathExt=Object.freeze({JumpArc:mathJumpArc(),Pendulum:mathPendulum(),Tremor:mathTremor()});const explosionImpulse=(sharpness=6)=>{const tail=sharpness*Math.exp(1-sharpness);return k=>{if(k<=0||k>=1)return 0;const h=sharpness*k;return h*Math.exp(1-h)-tail*k}};const explosionFlash=(rise=.05,decay=5)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return-Math.exp(-decay*k)*Math.cos(freq*Math.PI*k)};const explosionImplosion=(charge=.3,depth=.4,burstPeak=1.2)=>{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const w=Math.sin(k*Math.PI*2*cycles)+.5*Math.sin(k*Math.PI*2*cycles*1.5+1.2)+.25*Math.sin(k*Math.PI*2*cycles*3+2.4);return amplitude*env*w*.6};const natureFlicker=(rate=15,intensity=.2,seed=7)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=rate+1;i++)samples.push(rand());return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*rate;const idx=Math.floor(pos);const t=pos-idx;const a=samples[idx];const b=samples[idx+1];const interp=a+(b-a)*t;return intensity*env*(interp-.5)*2}};const natureGust=(gusts=3,peak=.25)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*.08*.08))}return peak*sum/gusts*1.8}};const Nature=Object.freeze({Wave:natureWave(),Flicker:natureFlicker(),Gust:natureGust()});const impactRain=(impactAt=.7,rippleAmp=.08)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const liftEnd=.35,strikeEnd=.6;return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return t*t}const t=(k-.4)/.6;const env=Math.exp(-2.5*t);const wave=Math.abs(Math.sin(t*Math.PI*bounces));return 1-env*wave*rebound};const impactSlap=(contactAt=.3,holdRatio=.1)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return.4*Math.pow(t,2.5)}if(k<.48){const t=(k-.4)/.08;return.4-.2*t}if(k<.52){const t=(k-.48)/.04;return.2+.8*t}const t=(k-.52)/.48;return 1-.04*Math.sin(t*Math.PI*8)*(1-t)};const rhythmPunchCombo=(peak=.4)=>{const pattern=[{c:.15,w:.04,a:.75},{c:.35,w:.04,a:.75},{c:.7,w:.055,a:1}];return k=>{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of pattern){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return peak*sum}};const rhythmStaccato=(beats=4,duty=.3)=>k=>{if(k<=0||k>=1)return 0;const beatLen=1/beats;const phase=k/beatLen-Math.floor(k/beatLen);if(phase>duty)return 0;const t=phase/duty;return Math.sin(t*Math.PI)};const rhythmKick=(peak=1.2)=>k=>{if(k<=0||k>=1)return 0;if(k<.05)return peak*k/.05;const t=(k-.05)/.95;return peak*Math.exp(-4*t)};const rhythmCrescendo=(beats=4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return sum}};const rhythmDunDunDun=()=>{const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return k=>{if(k<=0||k>=1)return 0;return.3*bell(k,.15,.025)+.6*bell(k,.35,.03)+1*bell(k,.68,.09)}};const rhythmBellToll=(decay=3,freq=8)=>{const strike=.05;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.2){const t=k/.2;return-pressDepth*Math.sin(t*Math.PI/2)}if(k<.5){const t=(k-.2)/.3;return-pressDepth+(pressDepth+reboundPeak)*(1-Math.pow(1-t,3))}const t=(k-.5)/.5;return reboundPeak*Math.exp(-4*t)*Math.cos(t*Math.PI*3)};const uiHoverBloom=(riseRatio=.2,fallRatio=.3)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=1-k;const raw=Math.sin(k*Math.PI*2*count);const clipped=Math.sign(raw)*Math.min(1,Math.abs(raw)*1.8);return amplitude*env*clipped};const uiSuccessPop=(overshoot=.2)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return(1+overshoot)*(1-Math.pow(1-t,2))}const t=(k-.4)/.6;return 1+overshoot*Math.exp(-5*t)*Math.cos(t*Math.PI*3)};const uiRippleOut=()=>k=>{if(k<=0||k>=1)return 0;return 6.75*k*Math.pow(1-k,2)};const UI=Object.freeze({ClickSnap:uiClickSnap(),HoverBloom:uiHoverBloom(),ErrorShake:uiErrorShake(),SuccessPop:uiSuccessPop(),RippleOut:uiRippleOut()});const magicManaCharge=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;const base=(Math.exp(3*k)-1)/(Math.exp(3)-1);const pulse=.04*Math.sin(k*Math.PI*8)*k;return base+pulse};const magicSpellCast=(chargeEnd=.4)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.45){const t=k/.45;return t*t*t}if(k<.55)return 1;const t=(k-.55)/.45;return Math.pow(1-t,3)};const magicShield=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.3){const t=k/.3;return 1.2*(1-Math.pow(1-t,2))}if(k<.6){const t=(k-.3)/.3;return 1.2-.2*t}const t=(k-.6)/.4;return 1+.03*Math.sin(t*Math.PI*3)};const magicAura=(peak=.15)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const fundamental=.6*Math.sin(k*Math.PI*2);const harmonic=.3*Math.sin(k*Math.PI*4+1);const overtone=.1*Math.sin(k*Math.PI*6+2);return peak*env*(fundamental+harmonic+overtone)};const Magic=Object.freeze({ManaCharge:magicManaCharge(),SpellCast:magicSpellCast(),Teleport:magicTeleport(),Shield:magicShield(),MagicAura:magicAura()});const animalCatPounce=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.2){const t=k/.2;return-.2*Math.sin(t*Math.PI)}if(k<.3){const t=(k-.2)/.1;return.5*t*t}if(k<.8){const t=(k-.3)/.5;return.5+.5*t+.2*Math.sin(t*Math.PI)}const t=(k-.8)/.2;return 1+.05*Math.sin(t*Math.PI)};const animalBirdFlap=(flaps=4)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const phase=k*Math.PI*2*flaps;const wave=Math.sin(phase)-.3*Math.sin(phase*2);return.2*env*wave};const animalSnakeSlither=(waves=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const wave=Math.sin(k*Math.PI*2*waves);return.2*env*wave};const animalButterflyFlit=(seed=13)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=26;i++)samples.push(rand()-.5);return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*25;const idx=Math.floor(pos);const t=pos-idx;const smooth=t*t*(3-2*t);const interp=samples[idx]+(samples[idx+1]-samples[idx])*smooth;return.3*env*interp}};const animalHorseGallop=(cycles=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const cyclePos=k*cycles-Math.floor(k*cycles);const bell=(c,w=.04)=>Math.exp(-((cyclePos-c)**2)/(2*w*w));return.25*env*(bell(0)+bell(.18)+bell(.36)+bell(.54))};const Animal=Object.freeze({CatPounce:animalCatPounce(),BirdFlap:animalBirdFlap(),SnakeSlither:animalSnakeSlither(),ButterflyFlit:animalButterflyFlit(),HorseGallop:animalHorseGallop()});const Progress=Object.freeze({Physics:Object.freeze({...Physics,Spring:libSpring()}),Motion:Motion,Step:Object.freeze({...Step,Steps6:libSteps()}),Math:Object.freeze({Tremor:MathExt.Tremor}),Impact:Object.freeze({Rain:Impact.Rain,Hammer:Impact.Hammer,BounceDrop:Impact.BounceDrop,ArrowHit:Impact.ArrowHit,Shatter:Impact.Shatter}),Rhythm:Object.freeze({BassDrop:Rhythm.BassDrop}),UI:Object.freeze({SuccessPop:UI.SuccessPop}),Magic:Object.freeze({ManaCharge:Magic.ManaCharge,Shield:Magic.Shield}),Animal:Object.freeze({CatPounce:Animal.CatPounce})});const Pulse=Object.freeze({Attention:Object.freeze({Ping:Attention.Ping}),Breath:Object.freeze({Deep:Breath.Deep,Sigh:Breath.Sigh}),Heart:Object.freeze({Calm:Heart.Calm}),Math:Object.freeze({JumpArc:MathExt.JumpArc,BoomerangSharp:mathBoomerang(E.Cubic.In),BoomerangSoft:mathBoomerang(E.Cubic.Out)}),Explosion:Object.freeze({Impulse:Explosion.Impulse,Flash:Explosion.Flash,Recoil:Explosion.Recoil,Implosion:Explosion.Implosion}),Impact:Object.freeze({Slap:Impact.Slap}),Rhythm:Object.freeze({Kick:Rhythm.Kick}),UI:Object.freeze({ClickSnap:UI.ClickSnap,HoverBloom:UI.HoverBloom,RippleOut:UI.RippleOut}),Magic:Object.freeze({SpellCast:Magic.SpellCast,Teleport:Magic.Teleport})});const Wave=Object.freeze({Attention:Object.freeze({Wiggle:Attention.Wiggle,Strum:Attention.Strum}),Breath:Object.freeze({Normal:Breath.Normal,Panting:Breath.Panting}),Heart:Object.freeze({Excited:Heart.Excited,LubDub:Heart.LubDub,Beat:libHeartBeat()}),Math:Object.freeze({Pendulum:MathExt.Pendulum}),Nature:Nature,Rhythm:Object.freeze({PunchCombo:Rhythm.PunchCombo,Staccato:Rhythm.Staccato,Crescendo:Rhythm.Crescendo,DunDunDun:Rhythm.DunDunDun,BellToll:Rhythm.BellToll}),UI:Object.freeze({ErrorShake:UI.ErrorShake}),Magic:Object.freeze({MagicAura:Magic.MagicAura}),Animal:Object.freeze({BirdFlap:Animal.BirdFlap,SnakeSlither:Animal.SnakeSlither,ButterflyFlit:Animal.ButterflyFlit,HorseGallop:Animal.HorseGallop})});const customEasings=Object.freeze({makeOutIn:makeOutIn,OutIn:OutIn,Progress:Progress,Pulse:Pulse,Wave:Wave,cubicBezier:cubicBezier});exports.customEasings=customEasings;exports.default=customEasings; \ No newline at end of file diff --git a/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/scriptScene.js b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/scriptScene.js new file mode 100644 index 0000000000000000000000000000000000000000..5d5f0a8bde54f7efa0912b77bb0a8298e3fb04e9 --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/scriptScene.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/three-amg-wrapper.js b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/three-amg-wrapper.js new file mode 100644 index 0000000000000000000000000000000000000000..c2037e314e032c4d36912923d4cc1258cba3ab19 --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/three-amg-wrapper.js @@ -0,0 +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;iobj.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; \ No newline at end of file diff --git a/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/tween.js b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/tween.js new file mode 100644 index 0000000000000000000000000000000000000000..690fb9e4284728629129deed5a5a3f4bcec291ed --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/tween.js @@ -0,0 +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=power1e4?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;_i0){this._tweensAddedDuringUpdate={};for(var i=0;i1){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[m1;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;itotalTime){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;ithis.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;ithis.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.xthis.max.x||box.max.ythis.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; \ No newline at end of file diff --git a/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Box3.js b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Box3.js new file mode 100644 index 0000000000000000000000000000000000000000..4100dc7442d3a622827c8a415e24557f68c491f1 --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Box3.js @@ -0,0 +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=3?array[offset+2]:0;if(xthis.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=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.xthis.max.x||box.max.ythis.max.y||box.max.zthis.max.z)}}exports.Box3=Box3; \ No newline at end of file diff --git a/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..be3b8b1334a62f5e88c45feee098063a199fca55 --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js @@ -0,0 +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=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; \ No newline at end of file diff --git a/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..af9a8a13a46500e78f082a35e18d0b5932061234 --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js @@ -0,0 +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;iObject.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;i1?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; \ No newline at end of file diff --git a/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Constants.js b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Constants.js new file mode 100644 index 0000000000000000000000000000000000000000..6b8adda19a4d67236719804f5170889b39fd4582 --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Constants.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js new file mode 100644 index 0000000000000000000000000000000000000000..29b0aad5599401be17f967ba1d48851acb70c2ac --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js @@ -0,0 +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;i0||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;i0?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;imaxX)maxX=p.x;if(p.ymaxY)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; \ No newline at end of file diff --git a/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..f3dee08bf1c089e040fcfef228902ab9a39c93cb --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Earcut.js b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Earcut.js new file mode 100644 index 0000000000000000000000000000000000000000..953abffdf38c2def26df73fed180eff8c7644ced --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Earcut.js @@ -0,0 +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;imaxX)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=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=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.x&&p.x>=mx&&hx!==p.x&&pointInTriangle(hym.x||p.x===m.x&§orContainsSector(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.xb.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;i0||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=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;i0){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;imaxX)maxX=contour[i].x;if(contour[i].ymaxY)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;layerIdx0?-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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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; \ No newline at end of file diff --git a/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Group.js b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Group.js new file mode 100644 index 0000000000000000000000000000000000000000..90c4dbef65aa04d7a3bb6b6d76ec3317ea65a228 --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Group.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");class Group extends Object3D{constructor(name="Group_w"){super(name)}dispose(){super.dispose()}}exports.Group=Group; \ No newline at end of file diff --git a/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Material.js b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Material.js new file mode 100644 index 0000000000000000000000000000000000000000..81b97053ad9d1e4b1ef05d5ac6ed992487b2ca8e --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Material.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..dcf34d4cffb9de0869382a24690f78f60dda6049 --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js new file mode 100644 index 0000000000000000000000000000000000000000..41e6cd0a0eee7dd7bc497be5deac584806b68dc3 --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Mesh.js b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Mesh.js new file mode 100644 index 0000000000000000000000000000000000000000..254d69b074e797dd34c16d7dad723bbcc3b4895d --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Mesh.js @@ -0,0 +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;imaterial,set:value=>{material=value;if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;im.dispose&&m.dispose());else if(this.material.dispose)this.material.dispose()}}}exports.MeshWrapper=MeshWrapper; \ No newline at end of file diff --git a/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..ac394f66efc4e113a7127ee0f50ec672e4c5e9eb --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Object3D.js b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Object3D.js new file mode 100644 index 0000000000000000000000000000000000000000..8532c6122f839460aab34fe88957802ff523318b --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Object3D.js @@ -0,0 +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{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&¤tScene._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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js new file mode 100644 index 0000000000000000000000000000000000000000..ba39801de50d38ec04424f3c2ebfa2ff5d28fded --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js @@ -0,0 +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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..bc595fb80ad9e7c2f4d8360c67dbef556f3d6cbe --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js @@ -0,0 +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;iy0){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; \ No newline at end of file diff --git a/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..02dc1be955bc766de744222a7e75c65bf147bb61 --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js @@ -0,0 +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&¶meters.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{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=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=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=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; \ No newline at end of file diff --git a/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Shape.js b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Shape.js new file mode 100644 index 0000000000000000000000000000000000000000..ecde48b5ceb30812c922aa5c7cfe2aa7b50cabe4 --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Shape.js @@ -0,0 +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;i0){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;i0||(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;imaxX)maxX=p.x;if(p.ymaxY)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;i0?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;ipoints.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;itwoPi)deltaAngle-=twoPi;if(deltaAngle>4;uuid[i]=chars[i===19?r&3|8:r]}}return uuid.join("")}exports.Shape=Shape; \ No newline at end of file diff --git a/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..3786abc7d64ed80b56101c4ac9d30ce9fcb8f941 --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js @@ -0,0 +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;i0){const bounds=calculateBounds(flatVertices);const vertexOffset=vertices.length/3;for(let j=0;j0){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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}function calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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; \ No newline at end of file diff --git a/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..1ea27a55fbce9fc3771c66840c068e5ff6347092 --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Texture.js b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Texture.js new file mode 100644 index 0000000000000000000000000000000000000000..35bff49d732c9884e07bfcb5682f18a860485e1f --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Texture.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Vector2.js b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Vector2.js new file mode 100644 index 0000000000000000000000000000000000000000..a30a2431264ee62cec937714dfa9e50932ddedeb --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/js/ThreeJS/wrapper/Vector2.js @@ -0,0 +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)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)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)= 1.0) { + return texel2; + } + + vec2 center = vec2(0.5); + vec2 aspect = vec2(ratio, 1.0); + vec2 offset = vUv - center; + vec2 scaled = offset * aspect; + + float dist = length(scaled) + 1e-6; + float maxDist = length(aspect * 0.5) + 1e-6; + float normalizedDist = dist / maxDist; + + float baseAngle = atan(scaled.y, scaled.x); + float swirlEnvelope = 1.0 - smoothstep(0.3, 1.0, transitionProgress); + float tunnelSpin = transitionProgress * 3.14159265 * 3.0; + float twist = baseAngle + swirlEnvelope * 3.14159265 * 4.0 * (1.0 - normalizedDist) + tunnelSpin; + + vec2 rotated = vec2(cos(twist), sin(twist)) * dist; + float depth = 1.0 / (1.0 + dist * (1.4 - 0.6 * transitionProgress) * (0.4 + refractStrength)); + vec2 tunnel = rotated * depth; + vec2 warped = tunnel / aspect + center; + + vec2 dir = scaled / dist; + vec2 dispersionVec = dir * (1.0 - transitionProgress * 0.65) * 0.035 * refractStrength; + + vec3 tunnelCore = texture2D(tDiffuse, saturate(warped)).rgb; + vec3 tunnelDispPos = texture2D(tDiffuse, saturate(warped + dispersionVec)).rgb; + vec3 tunnelDispNeg = texture2D(tDiffuse, saturate(warped - dispersionVec)).rgb; + + vec2 layered = warped * (1.4 + transitionProgress * 2.6); + vec2 mirrored = abs(fract(layered) - 0.5) * 2.0; + vec3 reflection = texture2D(tDiffuse, saturate(mirrored)).rgb; + + vec3 prismMix = vec3(tunnelDispPos.r, tunnelCore.g, tunnelDispNeg.b); + vec3 reflected = mix(tunnelCore, reflection, 0.5 * transitionProgress); + vec3 portalEnergy = mix(prismMix, reflected, 0.4 + 0.3 * transitionProgress); + + float crystalGrid = abs(sin((baseAngle + transitionProgress * 2.0) * 4.0) * cos(dist * 12.0)); + float fractNoise = fract(sin(dot(rotated, vec2(21.289, 47.123))) * 12871.312); + float sparkle = pow(saturate(1.0 - normalizedDist * 1.2), 3.0) * (0.35 + 0.65 * fractNoise); + float shardFlash = pow(crystalGrid, 4.0) * (1.0 - transitionProgress * 0.3); + vec3 shardGlow = portalColor * (sparkle + shardFlash * 0.5); + + vec3 portalComposite = clamp(portalEnergy + shardGlow, 0.0, 1.0); + + vec2 uvDirection = normalize(vec2(offset.x, offset.y + 1e-6)); + vec2 refractOffset = uvDirection * transitionProgress * 0.05 * refractStrength; + vec3 future = texture2D(tDiffuse1, saturate(vUv + refractOffset)).rgb; + + vec2 perpendicularDir = rotate2D(uvDirection, 1.57079633); + vec3 futureFacet = texture2D(tDiffuse1, saturate(vUv + perpendicularDir * 0.03 * (1.0 - transitionProgress))).rgb; + + float portalRadius = mix(0.04, 0.65, transitionProgress); + float centerReveal = 1.0 - smoothstep(portalRadius, portalRadius + 0.08, dist); + + vec3 futureBlend = mix(futureFacet, future, saturate(centerReveal + 0.25 * transitionProgress)); + vec3 stage1 = mix(texel1.rgb, portalComposite, smoothstep(0.05, 0.85, transitionProgress)); + + vec3 finalRGB = mix(stage1, futureBlend, centerReveal); + finalRGB = clamp(finalRGB, 0.0, 1.0); + + float finalAlpha = mix(texel1.a, texel2.a, saturate(centerReveal + transitionProgress * 0.35)); + + return vec4(finalRGB, finalAlpha); +} + +void main() { + // Get the pixel color from both textures + vec4 texel1 = texture2D(tDiffuse, vUv); + vec4 texel2 = texture2D(tDiffuse1, vUv); + + // --- Transition Configuration --- + const float fadeInEnd = 0.1; + const float fadeOutStart = 0.9; + + // 1. Calculate the transition's own progress. + float transitionProgress = clamp((progress - fadeInEnd) / (fadeOutStart - fadeInEnd), 0.0, 1.0); + vec4 transitionColor = transition(texel1, texel2, transitionProgress); + + // 2. Calculate smooth blending factors for the start and end zones. + float blendInFactor = smoothstep(0.0, fadeInEnd, progress); + float blendOutFactor = smoothstep(fadeOutStart, 1.0, progress); + + // 3. Apply the blending. + vec4 finalColor = mix(texel1, transitionColor, blendInFactor); + finalColor = mix(finalColor, texel2, blendOutFactor); + + gl_FragColor = finalColor; +} +//===end_frag_code=== +`; \ No newline at end of file diff --git a/scripts/7681593274276056327/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js b/scripts/7681593274276056327/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js new file mode 100644 index 0000000000000000000000000000000000000000..2c87ab8ca97aecc86f650141dcf51ecc1ee7f46e --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js @@ -0,0 +1,8 @@ +exports.source=` +varying vec2 vUv; + +void main() { + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); +} +`; \ No newline at end of file diff --git a/scripts/7681593274276056327/AmazingFeature/xshader/Unlit.frag b/scripts/7681593274276056327/AmazingFeature/xshader/Unlit.frag new file mode 100644 index 0000000000000000000000000000000000000000..2b8ef6c235afd5362d14d87961e5b7fa2fe044b1 --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/xshader/Unlit.frag @@ -0,0 +1,25 @@ +precision highp float; +uniform sampler2D u_AlbedoTexture; +uniform vec4 u_AlbedoColor; +uniform vec2 u_Repeat; +uniform vec2 u_Offset; +uniform float u_Translucency; +uniform float u_Opacity; +varying vec2 g_vary_uv0; +void main () +{ + vec2 uv_1; + uv_1.x = g_vary_uv0.x; + uv_1.y = (g_vary_uv0.y); + lowp vec4 tmpvar_2; + tmpvar_2 = texture2D (u_AlbedoTexture, (uv_1 * u_Repeat + u_Offset)); + lowp vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2.xyz * u_AlbedoColor.xyz); + lowp float tmpvar_4; + tmpvar_4 = (tmpvar_2.w * u_Translucency); + mediump vec4 tmpvar_5; + tmpvar_5.xyz = tmpvar_3; + tmpvar_5.w = tmpvar_4; + gl_FragColor = vec4(tmpvar_5.xyz * u_Opacity, tmpvar_5.w * u_Opacity); +} + diff --git a/scripts/7681593274276056327/AmazingFeature/xshader/Unlit.vert b/scripts/7681593274276056327/AmazingFeature/xshader/Unlit.vert new file mode 100644 index 0000000000000000000000000000000000000000..64a27d816e6146a0fb85643a9991207e5fda2acb --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/xshader/Unlit.vert @@ -0,0 +1,35 @@ +precision highp float; +attribute vec3 attPosition; +attribute vec2 attTexcoord0; + +//#define AMAZING_USE_BONES + +#ifdef AMAZING_USE_BONES +attribute vec4 attBoneIds; +attribute vec4 attWeights; +const int MAX_BONES = 50; +uniform mat4 u_Palatte[MAX_BONES]; +#endif + +uniform mat4 u_Model; +uniform mat4 u_MVP; +varying vec2 g_vary_uv0; + + + +void main () +{ + vec3 modelPostiton = attPosition; + vec4 homogeneous_pos = vec4(attPosition, 1.0); + g_vary_uv0 = attTexcoord0; + +#ifdef AMAZING_USE_BONES + mat4 boneTransform = u_Palatte[int(attBoneIds.x)] * attWeights.x; + boneTransform += u_Palatte[int(attBoneIds.y)] * attWeights.y; + boneTransform += u_Palatte[int(attBoneIds.z)] * attWeights.z; + boneTransform += u_Palatte[int(attBoneIds.w)] * attWeights.w; + gl_Position = u_MVP * boneTransform * homogeneous_pos; +#else + gl_Position = u_MVP * homogeneous_pos; +#endif +} diff --git a/scripts/7681593274276056327/AmazingFeature/xshader/noface.frag b/scripts/7681593274276056327/AmazingFeature/xshader/noface.frag new file mode 100644 index 0000000000000000000000000000000000000000..88e9ec343761b2395bae9430e6e55466b0367d67 --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/xshader/noface.frag @@ -0,0 +1,7 @@ +precision lowp float; +varying highp vec2 uv0; +uniform sampler2D u_albedo; +void main() +{ + gl_FragColor = texture2D(u_albedo, uv0); +} diff --git a/scripts/7681593274276056327/AmazingFeature/xshader/noface.vert b/scripts/7681593274276056327/AmazingFeature/xshader/noface.vert new file mode 100644 index 0000000000000000000000000000000000000000..16450a4b5880cf8d83528ea1ae0f47d10b2ab1d8 --- /dev/null +++ b/scripts/7681593274276056327/AmazingFeature/xshader/noface.vert @@ -0,0 +1,12 @@ +precision highp float; + +attribute vec2 position; +attribute vec2 texcoord0; +varying vec2 uv0; +//uniform mat4 u_MVP; +void main() +{ + //gl_Position = u_MVP * position; + gl_Position = sign(vec4(position.xy, 0.0, 1.0)); + uv0 = texcoord0; +} diff --git a/scripts/7681593274276056327/config.json b/scripts/7681593274276056327/config.json new file mode 100644 index 0000000000000000000000000000000000000000..557ff9895b4c8c8a7d91baae310b40001cd6c20d --- /dev/null +++ b/scripts/7681593274276056327/config.json @@ -0,0 +1,16 @@ +{ + "ae_tool": "AmazingEditor", + "bALG_BACH_CONFIG": false, + "effect": { + "Link": [ + { + "path": "AmazingFeature/", + "type": "AmazingFeature", + "zorder": 8011 + } + ] + }, + "name": "AlgorithmGraph_7bdbHcdcscQkbEdcc9cIlcNdvTdtb", + "version": "13.4.0", + "item_source": "user_post_pc_lumi_ai" +} \ No newline at end of file diff --git a/scripts/7681593274276056327/extra.json b/scripts/7681593274276056327/extra.json new file mode 100644 index 0000000000000000000000000000000000000000..c10f4f095945798a8acbf1b462f874b31e7589bb --- /dev/null +++ b/scripts/7681593274276056327/extra.json @@ -0,0 +1,37 @@ +{ + "transition": { + "defaultDura": 2.0, + "isOverlap": true + }, + "External_Producer": true, + "setting": { + "lumiai_material_properties": [ + { + "effect_key": "progress", + "effect_key_cn": "progress", + "type": "float", + "default": 0, + "min": 0, + "max": 1 + }, + { + "effect_key": "refractStrength", + "effect_key_cn": "refractStrength", + "type": "float", + "default": 0.75, + "min": 0, + "max": 2 + }, + { + "effect_key": "portalColor", + "effect_key_cn": "portalColor", + "type": "color", + "default": [ + 0.82, + 0.92, + 1 + ] + } + ] + } +} \ No newline at end of file diff --git a/scripts/7681599071768956161/AmazingFeature/content.json b/scripts/7681599071768956161/AmazingFeature/content.json new file mode 100644 index 0000000000000000000000000000000000000000..91fbb9be9167ba1f5315de330b0f1903d08afc0b --- /dev/null +++ b/scripts/7681599071768956161/AmazingFeature/content.json @@ -0,0 +1,7 @@ +{ + "ae_tool" : "AmazingEditor", + "content" : {}, + "needblend" : false, + "tag" : "AMG_96763024926065909023875386850577846442", + "version" : "1.0" +} \ No newline at end of file diff --git a/scripts/7681599071768956161/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua b/scripts/7681599071768956161/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua new file mode 100644 index 0000000000000000000000000000000000000000..a498e06b924f116108617c6860cb4ca1fd5e9b15 --- /dev/null +++ b/scripts/7681599071768956161/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua @@ -0,0 +1,327 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiAnimSeqLoadAndCrop = LumiAnimSeqLoadAndCrop or {} +LumiAnimSeqLoadAndCrop.__index = LumiAnimSeqLoadAndCrop +---@class LumiAnimSeqLoadAndCrop : ScriptComponent +---@field animSeqType string [UI(Option={"Video", "Image", "Texture"})] +---@field cropType string [UI(Option={"Stretch", "Fill", "Fit", "Texture Size"})] +---@field edgeType string [UI(Option={"Tile", "Mirror", "Clamp", "Empty"})] +---@field pivot Vector2f +---@field position Vector2f +---@field rotation double [UI(Range={0, 360}, Drag)] +---@field scale double [UI(Range={0, 5}, Drag)] +---@field opacity double [UI(Range={0, 1}, Drag)] +---@field playMode string [UI(Option={"once", "loop"})] +---@field speed double [UI(Range={0.001, 10}, Drag)] +---@field seqTime number [UI(Range={0, 100}, Drag)] +---@field enableVideoAlphaBlend boolean +---@field videoFilename String +---@field animSeq AnimSeq +---@field seqTex Texture +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local animSeqTypeName = { + "Video", "Image", "Texture", +} +setmetatable(animSeqTypeName, {__index = function(_, _) return animSeqTypeName[1] end}) +local animSeqTypeIndex = {} +for index, value in ipairs(animSeqTypeName) do animSeqTypeIndex[value] = index - 1 end +setmetatable(animSeqTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, 'Unsupported AnimSeqType: ' .. key) + return 0 + end +}) + +local cropTypeName = { + "Stretch", "Fill", "Fit", "Texture Size" +} +setmetatable(cropTypeName, {__index = function(_, _) return cropTypeName[1] end}) +local cropTypeIndex = {} +for index, value in ipairs(cropTypeName) do cropTypeIndex[value] = index - 1 end +setmetatable(cropTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported SeqCrop Type: " .. key) + return 0 + end +}) + +local edgeTypeName = { + "Tile", "Mirror", "Clamp", "Empty", +} +setmetatable(edgeTypeName, {__index = function(_, _) return edgeTypeName[1] end}) +local edgeTypeIndex = {} +for index, value in ipairs(edgeTypeName) do edgeTypeIndex[value] = index - 1 end +setmetatable(edgeTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported Edge Type: " .. key) + return 0 + end +}) + +local playModeName = { + "once", "loop" +} +setmetatable(playModeName, {__index = function(_, _) return playModeName[1] end}) +local playModeIndex = {} +for index, value in ipairs(playModeName) do playModeIndex[value] = index - 1 end +setmetatable(playModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported Play Mode: " .. key) + return 0 + end +}) + +function LumiAnimSeqLoadAndCrop.new(construct, ...) + local self = setmetatable({}, LumiAnimSeqLoadAndCrop) + + self.AEPlugin = false + self.seqTime = 0.0 + self.globalRotation = 0.0 + self.globalScale = 1.0 + self.globalOpacity = 1.0 + self.globalSpeed = 1.0 + + self.paramInitInfo = { + {'specify', false}, + {'animSeqType', 'Texture'}, + {'cropType', 'Stretch'}, + {'edgeType', 'Empty'}, + {'pivot', Amaz.Vector2f(0.5, 0.5)}, + {'position', Amaz.Vector2f(0.5, 0.5)}, + {'rotation', 0}, + {'scale', 1.0}, + {'opacity', 1.0}, + {'playMode', 'loop'}, + {'speed', 1.0}, + -- Video seq + {'videoFilename', ''}, + {'enableVideoAlphaBlend', false}, + -- Image seq + {'animSeq', nil}, + -- Texture + {'seqTex', nil}, + } + + self.multiAspect = { + ['5.8'] = 1.125 / 2.436, -- 0.4618 + ['9_16'] = 9 / 16, -- 0.5625 + ['3_4'] = 3 / 4, -- 0.75 + ['1_1'] = 1, + ['4_3'] = 4 / 3, -- 1.3333 + ['16_9'] = 16 / 9, -- 1.7778 + ['1.85_1'] = 1.85, + ['2_1'] = 2, + ['2.35_1'] = 2.35, + } + + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self.paramInitInfo[i][2] + end + + for key, _ in pairs(self.multiAspect) do + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1] .. '_' .. key] = self.paramInitInfo[i][2] + end + end + + self.needUpdateSize = true + self.InputTex = nil + self.OutputTex = nil + + return self +end + +function LumiAnimSeqLoadAndCrop:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.camera = self.entity:searchEntity("AnimSeqCamera"):getComponent("Camera") + self.material = self.entity:searchEntity('AnimSeqPass'):getComponent('MeshRenderer').material + self.videoAnim = self.entity:searchEntity("AnimSeqPass"):getComponent("VideoAnimSeq") + self.seqAnim = self.entity:searchEntity("AnimSeqPass"):getComponent("AnimSeqComponent") +end + +function LumiAnimSeqLoadAndCrop:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value, _force) + if _force or self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if self[key] ~= nil then + if key:sub(1, #'cropType') == 'cropType' then + local type = cropTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'edgeType') == 'edgeType' then + local type = edgeTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'animSeqType') == 'animSeqType' then + local type = animSeqTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'playMode') == 'playMode' then + local type = playModeName[value + 1] + _setEffectAttr(key, type) + else + _setEffectAttr(key, value) + end + elseif key:sub(1, #'seqTex') == 'seqTex' + or key:sub(1, #'animSeq') == 'animSeq' + then + _setEffectAttr(key, value, true) + else + _setEffectAttr(key, value) + end +end + +function LumiAnimSeqLoadAndCrop:afterAnimSeqSystemUpdate(comp) + if self.animSeqType == "Image" then + if self.needUpdateSize and self.material then + local seqTex = self.material:getTex("u_seqTexture") + self.material:setVec2("u_seqTexSize", Amaz.Vector2f(seqTex.width, seqTex.height)) + seqTex = nil + self.needUpdateSize = false + end + end +end + +function LumiAnimSeqLoadAndCrop:onUpdate(comp, deltaTime) + if self.OutputTex then + self.camera.renderTexture = self.OutputTex + end + + local w = self.camera.renderTexture.width + local h = self.camera.renderTexture.height + + local ratio = w / h + local paramFlag = '' + local _diff = math.huge + for key, value in pairs(self.multiAspect) do + if self['specify_' .. key] then + local diff = math.abs(ratio - value) + if diff < _diff then + _diff = diff + paramFlag = key + end + end + end + + -- update parameters based on resolution + if paramFlag == '' then + if self.AEPlugin then + Amaz.LOGE(self.TAG, 'No aspect specified' .. ', ratio: ' .. ratio .. ', reset params!') + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self.paramInitInfo[i][2] + end + else + Amaz.LOGE(self.TAG, 'No aspect specified' .. ', ratio: ' .. ratio) + end + else + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self[self.paramInitInfo[i][1] .. '_' .. paramFlag] + end + end + + if self.AEPlugin then + self.animSeqType = 'Texture' + end + + self.material:setTex("u_inputTexture", self.InputTex) + self.material:setInt('u_cropType', cropTypeIndex[self.cropType]) + self.material:setInt('u_edgeType', edgeTypeIndex[self.edgeType]) + self.material:setFloat('u_opacity', self.opacity * self.globalOpacity) + self.material:setVec2('u_scale', Amaz.Vector2f(self.scale, self.scale) * self.globalScale) + self.material:setVec2('u_pivot', self.pivot - Amaz.Vector2f(0.5, 0.5)) + self.material:setVec2('u_position', self.position - Amaz.Vector2f(0.5, 0.5)) + self.material:setFloat('u_rotation', math.rad(self.rotation + self.globalRotation)) + + local playMode = Amaz.PlayMode.loop + if self.playMode == 'once' then + playMode = Amaz.PlayMode.once + end + + local speed = self.speed * self.globalSpeed + + if self.animSeqType == "Video" then + self.videoAnim.enabled = true + self.seqAnim.enabled = false + + if not isEditor then + self.videoAnim.enableFixedSeekMode = true + end + if self.videoAnim.videoFilename ~= self.videoFilename then + self.videoAnim.videoFilename = self.videoFilename + end + if self.videoAnim.enableAlphaBlend ~= self.enableVideoAlphaBlend then + self.videoAnim.enableAlphaBlend = self.enableVideoAlphaBlend + end + if self.videoAnim.playmode ~= playMode then + self.videoAnim.playmode = playMode + end + if self.videoAnim.speed ~= speed then + self.videoAnim.speed = speed + end + local frames = self.videoAnim:getFrameCount() + local duration = self.videoAnim:getDuration() + local videoFps = frames / duration * 1000 + self.videoAnim:seekToTime(self.seqTime + 0.5 / videoFps) + local videoSize = self.videoAnim:getVideoSize() + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", 0) + -- self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + self.material:setInt('u_yFlip', 1) + elseif self.animSeqType == "Image" then + self.videoAnim.enabled = false + self.seqAnim.enabled = true + + if self.seqAnim.animSeq ~= self.animSeq then + self.seqAnim.animSeq = self.animSeq + self.needUpdateSize = true + end + if self.seqAnim.playmode ~= playMode then + self.seqAnim.playmode = playMode + end + if self.seqAnim.speed ~= speed then + self.seqAnim.speed = speed + end + self.seqAnim:seekToTime(self.seqTime + 0.5 / self.animSeq.fps) + self.material:setInt("u_convertAlpha", 0) + self.material:setInt('u_yFlip', 1) + elseif self.animSeqType == "Texture" then + self.videoAnim.enabled = false + self.seqAnim.enabled = false + + if self.seqTex then + self.material:setTex("u_seqTexture", self.seqTex) + local videoSize = Amaz.Vector2f(self.seqTex.width, self.seqTex.height) + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + else + self.material:setTex("u_seqTexture", self.InputTex) + local inputWidth = Amaz.BuiltinObject.getInputTextureWidth() + local inputHeight = Amaz.BuiltinObject.getInputTextureHeight() + local videoSize = Amaz.Vector2f(inputWidth, inputHeight) + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + end + self.material:setInt('u_yFlip', 0) + end +end + +exports.LumiAnimSeqLoadAndCrop = LumiAnimSeqLoadAndCrop +return exports diff --git a/scripts/7681599071768956161/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag b/scripts/7681599071768956161/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag new file mode 100644 index 0000000000000000000000000000000000000000..776d48b9649c5f359d8b806bfa1895121567e7d5 --- /dev/null +++ b/scripts/7681599071768956161/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag @@ -0,0 +1,162 @@ +precision highp float; +precision highp int; + +uniform mediump int u_yFlip; +uniform mediump int u_convertAlpha; +uniform mediump sampler2D u_seqTexture; +uniform vec4 u_ScreenParams; +uniform vec2 u_scale; +uniform float u_rotation; +uniform vec2 u_position; +uniform vec2 u_pivot; +uniform vec2 u_seqTexSize; +uniform mediump int u_cropType; +uniform mediump int u_edgeType; +uniform float u_opacity; + +varying vec2 uv0; + +vec2 _f4(inout vec2 _p0, float _p1, vec2 _p2, vec2 _p3, vec2 _p4) +{ + _p0 -= _p2; + _p0 -= vec2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _169 = sin(_p1); + float _172 = cos(_p1); + _p0 = mat2(vec2(_172, _169), vec2(-_169, _172)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 /= _p4; + _p0 += vec2(0.5); + _p0 += _p3; + return _p0; +} + +vec2 _f2(vec2 _p0) +{ + vec2 _122 = mod(_p0, vec2(1.0)); + return _122 + (vec2(1.0) - step(vec2(0.0), _122)); +} + +vec2 _f1(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +vec4 _f0(inout vec2 _p0) +{ + if (u_yFlip == 1) + { + _p0 = vec2(_p0.x, 1.0 - _p0.y); + } + if (u_convertAlpha == 0) + { + return texture2D(u_seqTexture, _p0); + } + vec4 _t2; + _t2.w = texture2D(u_seqTexture, vec2(_p0.x * 0.5, _p0.y)).x; + mediump vec3 _97 = texture2D(u_seqTexture, vec2((_p0.x * 0.5) + 0.5, _p0.y)).xyz; + _t2.x = _97.x; + _t2.y = _97.y; + _t2.z = _97.z; + return _t2; +} + +float _f3(vec2 _p0) +{ + vec2 _t4 = step(vec2(0.0), _p0) * step(_p0, vec2(1.0)); + return _t4.x * _t4.y; +} + +void main() +{ + bool _214 = abs(u_scale.x) < 9.9999997473787516355514526367188e-05; + bool _222; + if (!_214) + { + _222 = abs(u_scale.y) < 9.9999997473787516355514526367188e-05; + } + else + { + _222 = _214; + } + if (_222) + { + gl_FragData[0] = vec4(0.0); + return; + } + vec2 param = uv0; + float param_1 = u_rotation; + vec2 param_2 = u_position; + vec2 param_3 = u_pivot; + vec2 param_4 = u_scale; + vec2 _245 = _f4(param, param_1, param_2, param_3, param_4); + vec2 _t8 = _245; + float _252 = u_seqTexSize.x / u_seqTexSize.y; + float _258 = u_ScreenParams.x / u_ScreenParams.y; + vec2 _t11 = _245; + if (u_cropType == 1) + { + if (_252 > _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (u_cropType == 2) + { + if (_252 < _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (u_cropType == 3) + { + _t11 -= vec2(0.5); + _t11.x *= (u_ScreenParams.x / u_seqTexSize.x); + _t11.y *= (u_ScreenParams.y / u_seqTexSize.y); + _t11 += vec2(0.5); + } + } + } + if (u_edgeType == 0) + { + vec2 param_5 = _t11; + _t11 = _f2(param_5); + } + else + { + if (u_edgeType == 1) + { + vec2 param_6 = _t11; + _t11 = _f1(param_6); + } + } + vec2 param_7 = _t11; + vec4 _389 = _f0(param_7); + vec4 _t16 = _389; + if (u_edgeType == 3) + { + vec2 param_8 = _t11; + _t16 *= _f3(param_8); + } + vec4 _401 = _t16; + vec4 _402 = _401 * u_opacity; + _t16 = _402; + gl_FragData[0] = _402; +} + diff --git a/scripts/7681599071768956161/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert b/scripts/7681599071768956161/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681599071768956161/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681599071768956161/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag b/scripts/7681599071768956161/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag new file mode 100644 index 0000000000000000000000000000000000000000..d21575c9d17e191328bff9c1ab15dd22db3dc969 --- /dev/null +++ b/scripts/7681599071768956161/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag @@ -0,0 +1,190 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + int u_yFlip; + int u_convertAlpha; + float4 u_ScreenParams; + float2 u_scale; + float u_rotation; + float2 u_position; + float2 u_pivot; + float2 u_seqTexSize; + int u_cropType; + int u_edgeType; + float u_opacity; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f4(thread float2& _p0, thread const float& _p1, thread const float2& _p2, thread const float2& _p3, thread const float2& _p4, constant float4& u_ScreenParams) +{ + _p0 -= _p2; + _p0 -= float2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _169 = sin(_p1); + float _172 = cos(_p1); + _p0 = float2x2(float2(_172, _169), float2(-_169, _172)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 /= _p4; + _p0 += float2(0.5); + _p0 += _p3; + return _p0; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float2& _p0) +{ + float2 _122 = mod(_p0, float2(1.0)); + return _122 + (float2(1.0) - step(float2(0.0), _122)); +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float4 _f0(thread float2& _p0, constant int& u_yFlip, constant int& u_convertAlpha, texture2d u_seqTexture, sampler u_seqTextureSmplr) +{ + if (u_yFlip == 1) + { + _p0 = float2(_p0.x, 1.0 - _p0.y); + } + if (u_convertAlpha == 0) + { + return u_seqTexture.sample(u_seqTextureSmplr, _p0); + } + float4 _t2; + _t2.w = u_seqTexture.sample(u_seqTextureSmplr, float2(_p0.x * 0.5, _p0.y)).x; + float3 _97 = u_seqTexture.sample(u_seqTextureSmplr, float2((_p0.x * 0.5) + 0.5, _p0.y)).xyz; + _t2.x = _97.x; + _t2.y = _97.y; + _t2.z = _97.z; + return _t2; +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0) +{ + float2 _t4 = step(float2(0.0), _p0) * step(_p0, float2(1.0)); + return _t4.x * _t4.y; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_seqTexture [[texture(0)]], sampler u_seqTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + bool _214 = abs(buffer.u_scale.x) < 9.9999997473787516355514526367188e-05; + bool _222; + if (!_214) + { + _222 = abs(buffer.u_scale.y) < 9.9999997473787516355514526367188e-05; + } + else + { + _222 = _214; + } + if (_222) + { + out.o_fragColor = float4(0.0); + return out; + } + float2 param = in.uv0; + float param_1 = buffer.u_rotation; + float2 param_2 = buffer.u_position; + float2 param_3 = buffer.u_pivot; + float2 param_4 = buffer.u_scale; + float2 _245 = _f4(param, param_1, param_2, param_3, param_4, buffer.u_ScreenParams); + float2 _t8 = _245; + float _252 = buffer.u_seqTexSize.x / buffer.u_seqTexSize.y; + float _258 = buffer.u_ScreenParams.x / buffer.u_ScreenParams.y; + float2 _t11 = _245; + if (buffer.u_cropType == 1) + { + if (_252 > _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (buffer.u_cropType == 2) + { + if (_252 < _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (buffer.u_cropType == 3) + { + _t11 -= float2(0.5); + _t11.x *= (buffer.u_ScreenParams.x / buffer.u_seqTexSize.x); + _t11.y *= (buffer.u_ScreenParams.y / buffer.u_seqTexSize.y); + _t11 += float2(0.5); + } + } + } + if (buffer.u_edgeType == 0) + { + float2 param_5 = _t11; + _t11 = _f2(param_5); + } + else + { + if (buffer.u_edgeType == 1) + { + float2 param_6 = _t11; + _t11 = _f1(param_6); + } + } + float2 param_7 = _t11; + float4 _389 = _f0(param_7, buffer.u_yFlip, buffer.u_convertAlpha, u_seqTexture, u_seqTextureSmplr); + float4 _t16 = _389; + if (buffer.u_edgeType == 3) + { + float2 param_8 = _t11; + _t16 *= _f3(param_8); + } + float4 _401 = _t16; + float4 _402 = _401 * buffer.u_opacity; + _t16 = _402; + out.o_fragColor = _402; + return out; +} + diff --git a/scripts/7681599071768956161/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert b/scripts/7681599071768956161/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681599071768956161/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681599071768956161/AmazingFeature/effects/LumiExtract/lua/LumiExtract.lua b/scripts/7681599071768956161/AmazingFeature/effects/LumiExtract/lua/LumiExtract.lua new file mode 100644 index 0000000000000000000000000000000000000000..215d94170f2539ab17b182835528a7c88026cfe1 --- /dev/null +++ b/scripts/7681599071768956161/AmazingFeature/effects/LumiExtract/lua/LumiExtract.lua @@ -0,0 +1,54 @@ + +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiExtract = LumiExtract or {} +LumiExtract.__index = LumiExtract +---@class LumiExtract : ScriptComponent +---@field InputTex Texture +---@field OutputTex Texture +---@field blackField double [UI(Range={0, 255}, Drag)] +---@field blackSoft double [UI(Range={0, 255}, Drag)] +---@field whiteField double [UI(Range={0, 255}, Drag)] +---@field whiteSoft double [UI(Range={0, 255}, Drag)] +---@field reverse Bool + +function LumiExtract.new(construct, ...) + local self = setmetatable({}, LumiExtract) + + if construct and LumiExtract.constructor then LumiExtract.constructor(self, ...) end + + self.InputTex = nil + self.OutputTex = nil + + self.blackField = 0.0 + self.blackSoft = 0.0 + self.whiteField = 1.0 + self.whiteSoft = 0.0 + self.reverse = false + + return self +end + +function LumiExtract:constructor() +end + +function LumiExtract:onStart(comp) + self.camera = comp.entity:searchEntity("BlitCamera"):getComponent("Camera") + self.material = comp.entity:searchEntity("BlitPass"):getComponent("MeshRenderer").material +end + +function LumiExtract:onUpdate(comp, deltaTime) + if self.OutputTex then + self.camera.renderTexture = self.OutputTex + end + self.material:setTex("u_InputTexture", self.InputTex) + + self.material:setFloat('u_BlackField', self.blackField/255.) + self.material:setFloat('u_BlackSoft', self.blackSoft/255.) + self.material:setFloat('u_WhiteField', self.whiteField/255.) + self.material:setFloat('u_WhiteSoft', self.whiteSoft/255.) + self.material:setFloat('u_Reverse', self.reverse and 1 or 0) +end + +exports.LumiExtract = LumiExtract +return exports diff --git a/scripts/7681599071768956161/AmazingFeature/effects/LumiExtract/xshader/shaderLib/shaderGLES/524ea16912ab8a9d389e60cecfbc0857.frag b/scripts/7681599071768956161/AmazingFeature/effects/LumiExtract/xshader/shaderLib/shaderGLES/524ea16912ab8a9d389e60cecfbc0857.frag new file mode 100644 index 0000000000000000000000000000000000000000..468ca423d47787cb955d6f17318c84bf4eda8f3f --- /dev/null +++ b/scripts/7681599071768956161/AmazingFeature/effects/LumiExtract/xshader/shaderLib/shaderGLES/524ea16912ab8a9d389e60cecfbc0857.frag @@ -0,0 +1,36 @@ +precision highp float; +precision highp int; + +uniform mediump sampler2D u_InputTexture; +uniform mediump float u_BlackField; +uniform mediump float u_BlackSoft; +uniform mediump float u_WhiteField; +uniform mediump float u_WhiteSoft; +uniform mediump float u_Reverse; + +varying vec2 v_uv; + +mediump float _f0(mediump float _p0, mediump float _p1, mediump float _p2) +{ + return clamp((_p2 - _p0) / ((_p1 - _p0) + 9.9999997473787516355514526367188e-06), 0.0, 1.0); +} + +void main() +{ + mediump vec4 _42 = texture2D(u_InputTexture, v_uv); + mediump vec4 _t1 = _42; + mediump float _49 = _t1.w; + vec3 _53 = _42.xyz / vec3(max(_49, 9.9999997473787516355514526367188e-05)); + _t1.x = _53.x; + _t1.y = _53.y; + _t1.z = _53.z; + float _70 = dot(_t1.xyz, vec3(0.300000011920928955078125, 0.588235318660736083984375, 0.111764706671237945556640625)); + mediump float param = u_BlackField - u_BlackSoft; + mediump float param_1 = u_BlackField; + mediump float param_2 = _70; + mediump float param_3 = u_WhiteField; + mediump float param_4 = u_WhiteField + u_WhiteSoft; + mediump float param_5 = _70; + gl_FragData[0] = _t1 * abs(u_Reverse - (_f0(param, param_1, param_2) * (1.0 - _f0(param_3, param_4, param_5)))); +} + diff --git a/scripts/7681599071768956161/AmazingFeature/effects/LumiExtract/xshader/shaderLib/shaderGLES/524ea16912ab8a9d389e60cecfbc0857.vert b/scripts/7681599071768956161/AmazingFeature/effects/LumiExtract/xshader/shaderLib/shaderGLES/524ea16912ab8a9d389e60cecfbc0857.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681599071768956161/AmazingFeature/effects/LumiExtract/xshader/shaderLib/shaderGLES/524ea16912ab8a9d389e60cecfbc0857.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681599071768956161/AmazingFeature/effects/LumiExtract/xshader/shaderLib/shaderMetal/524ea16912ab8a9d389e60cecfbc0857.frag b/scripts/7681599071768956161/AmazingFeature/effects/LumiExtract/xshader/shaderLib/shaderMetal/524ea16912ab8a9d389e60cecfbc0857.frag new file mode 100644 index 0000000000000000000000000000000000000000..c47ced8654dcd7971916ba52d63d02fadabdee28 --- /dev/null +++ b/scripts/7681599071768956161/AmazingFeature/effects/LumiExtract/xshader/shaderLib/shaderMetal/524ea16912ab8a9d389e60cecfbc0857.frag @@ -0,0 +1,53 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float u_BlackField; + float u_BlackSoft; + float u_WhiteField; + float u_WhiteSoft; + float u_Reverse; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f0(thread const float& _p0, thread const float& _p1, thread const float& _p2) +{ + return fast::clamp((_p2 - _p0) / ((_p1 - _p0) + 9.9999997473787516355514526367188e-06), 0.0, 1.0); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_InputTexture [[texture(0)]], sampler u_InputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _42 = u_InputTexture.sample(u_InputTextureSmplr, in.v_uv); + float4 _t1 = _42; + float _49 = _t1.w; + float3 _53 = _42.xyz / float3(fast::max(_49, 9.9999997473787516355514526367188e-05)); + _t1.x = _53.x; + _t1.y = _53.y; + _t1.z = _53.z; + float _70 = dot(_t1.xyz, float3(0.300000011920928955078125, 0.588235318660736083984375, 0.111764706671237945556640625)); + float param = buffer.u_BlackField - buffer.u_BlackSoft; + float param_1 = buffer.u_BlackField; + float param_2 = _70; + float param_3 = buffer.u_WhiteField; + float param_4 = buffer.u_WhiteField + buffer.u_WhiteSoft; + float param_5 = _70; + out.o_fragColor = _t1 * abs(buffer.u_Reverse - (_f0(param, param_1, param_2) * (1.0 - _f0(param_3, param_4, param_5)))); + return out; +} + diff --git a/scripts/7681599071768956161/AmazingFeature/effects/LumiExtract/xshader/shaderLib/shaderMetal/524ea16912ab8a9d389e60cecfbc0857.vert b/scripts/7681599071768956161/AmazingFeature/effects/LumiExtract/xshader/shaderLib/shaderMetal/524ea16912ab8a9d389e60cecfbc0857.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681599071768956161/AmazingFeature/effects/LumiExtract/xshader/shaderLib/shaderMetal/524ea16912ab8a9d389e60cecfbc0857.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681599071768956161/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua b/scripts/7681599071768956161/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua new file mode 100644 index 0000000000000000000000000000000000000000..438a547f7d5c96047e2f183309e2a7d7200347e7 --- /dev/null +++ b/scripts/7681599071768956161/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua @@ -0,0 +1,416 @@ +local exports = exports or {} +local LumiLayer = LumiLayer or {} +LumiLayer.__index = LumiLayer +---@class LumiLayer : ScriptComponent +---@field hasTransform boolean +---@field active_cam_fovx number +---@field compositeSize Vector2f +---@field layerSize Vector2f +---@field anchorPoint Vector3f +---@field orientation Vector3f +---@field position Vector3f +---@field scale Vector3f +---@field xRotation number [UI(Range={-360, 360}, Drag)] +---@field yRotation number [UI(Range={-360, 360}, Drag)] +---@field rotation number [UI(Range={-360, 360}, Drag)] +---@field opacity number [UI(Range={0, 100}, Drag)] +---@field mirrorEdge boolean +---@field hasMatte boolean +---@field matteMode string [UI(Option={"Alpha Matte", "Luma Matte", "Alpha Inverted Matte", "Luma Inverted Matte"})] +---@field maskTex Texture +---@field hasBlend boolean +---@field blendMode string [UI(Option={"Normal", "Add", "Multiply", "Difference", "Overlay", "Darken", "Lighten", "Soft Light", "Hard Light", "Hue", "Saturation", "Color", "Screen", "Color Burn", "Linear Burn", "Color Dodge", "Linear Dodge", "Vivid Light", "Linear Light", "Pin Light", "Hard Mix", "Exclusion", "Subtract", "Divide", "Luminosity", "Lighter Color", "Darker Color", "Dissolve"})] +---@field layerType string [UI(Option={"Adjustment", "Precomp", "Solid", "Image", "Video", "Sequence"})] +---@field baseTex Texture +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local MatteMode = { + "Alpha Matte", "Luma Matte", "Alpha Inverted Matte", "Luma Inverted Matte", +} +setmetatable(MatteMode, {__index = function(_, _) return MatteMode[1] end}) + +local MatteModeIndex = {} +for index, value in ipairs(MatteMode) do MatteModeIndex[value] = index - 1 end +setmetatable(MatteModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported matte mode: " .. key) + return 0 + end +}) + +local BlendMode = { + "Normal", "Add", "Multiply", "Difference", "Overlay", "Darken", "Lighten", "Soft Light", "Hard Light", "Hue", "Saturation", "Color", "Screen", "Color Burn", "Linear Burn", "Color Dodge", "Linear Dodge", "Vivid Light", "Linear Light", "Pin Light", "Hard Mix", "Exclusion", "Subtract", "Divide", "Luminosity", "Lighter Color", "Darker Color", "Dissolve", +} +setmetatable(BlendMode, {__index = function(_, _) return BlendMode[1] end}) + +local BlendModeIndex = {} +for index, value in ipairs(BlendMode) do BlendModeIndex[value] = index - 1 end +setmetatable(BlendModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported blend mode: " .. key) + return 0 + end +}) + +local LayerType = { + "Adjustment", "Precomp", "Solid", "Image", "Video", "Sequence", +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +function LumiLayer.new(construct, ...) + local self = setmetatable({}, LumiLayer) + + self.TAG = AE_EFFECT_TAG + + self.InputTex = nil + self.OutputTex = nil + self.aeTime = -1 + + -- TRS + self.hasTransform = false + self.active_cam_fovx = 39.6 + self.compositeSize = Amaz.Vector2f(1080, 1080) + self.layerSize = Amaz.Vector2f(1080, 1080) + + self.anchorPoint = Amaz.Vector3f(0, 0, 0) + self.position = Amaz.Vector3f(0, 0, 0) + self.scale = Amaz.Vector3f(100, 100, 100) + self.orientation = Amaz.Vector3f(0, 0, 0) + self.rotation = 0 + self.xRotation = 0 + self.yRotation = 0 + self.opacity = 100 + + self.p0_anchorPoint = Amaz.Vector3f(0, 0, 0) + self.p0_position = Amaz.Vector3f(0, 0, 0) + self.p0_scale = Amaz.Vector3f(100, 100, 100) + self.p0_orientation = Amaz.Vector3f(0, 0, 0) + self.p0_rotation = 0 + self.p0_xRotation = 0 + self.p0_yRotation = 0 + + self.p1_anchorPoint = Amaz.Vector3f(0, 0, 0) + self.p1_position = Amaz.Vector3f(0, 0, 0) + self.p1_scale = Amaz.Vector3f(100, 100, 100) + self.p1_orientation = Amaz.Vector3f(0, 0, 0) + self.p1_rotation = 0 + self.p1_xRotation = 0 + self.p1_yRotation = 0 + + self.expandRight = 0.0 + self.expandLeft = 0.0 + self.expandUp = 0.0 + self.expandDown = 0.0 + self.mirrorEdge = false + + -- Matte + self.hasMatte = false + self.matteMode = "Alpha" + self.matteDuration = {} + self.maskTex = nil + + -- Blend + self.hasBlend = true + self.blendMode = "Normal" + self.isVisible = true + self.layerType = 'Adjustment' + self.baseTex = nil + self.srcDuration = {} + self.baseDuration = {} + + -- for test + if false then + self.aeTime = 1 + self.srcDuration = {{0, 6}} + self.baseDuration = {{0, 6}} + end + + return self +end + +function LumiLayer:setVisible(visible) + self.isVisible = visible +end + +function LumiLayer:setEntityVisible(entity, visible) + local transforms = entity:getComponentsRecursive("Transform") + for i = 0, transforms:size() - 1 do + local transform = transforms:get(i) + if transform then + transform.entity.visible = visible + end + end + entity.visible = visible +end + +function LumiLayer:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.layerEntity = self.entity:searchEntity('LayerCamera'); + self.camera = self.layerEntity:getComponent('Camera') + self.expand_tile_trans = self.entity:searchEntity("expand_tile"):getComponent("Transform") + self.father_trans = self.entity:searchEntity("father_trans"):getComponent("Transform") + self.child_trans = self.entity:searchEntity("child_trans"):getComponent("Transform") + self.p0_father_trans = self.entity:searchEntity("p0_father_trans"):getComponent("Transform") + self.p0_child_trans = self.entity:searchEntity("p0_child_trans"):getComponent("Transform") + self.p1_father_trans = self.entity:searchEntity("p1_father_trans"):getComponent("Transform") + self.p1_child_trans = self.entity:searchEntity("p1_child_trans"):getComponent("Transform") + self.renderer = self.entity:searchEntity('expand_tile'):getComponent('MeshRenderer') + self.renderer.useFrustumCulling = false + self.material = self.renderer.material +end + +local PositionDict = { + xPosition = {'position', 'x'}, + yPosition = {'position', 'y'}, + zPosition = {'position', 'z'}, + p0_xPosition = {'p0_position', 'x'}, + p0_yPosition = {'p0_position', 'y'}, + p0_zPosition = {'p0_position', 'z'}, + p1_xPosition = {'p1_position', 'x'}, + p1_yPosition = {'p1_position', 'y'}, + p1_zPosition = {'p1_position', 'z'}, +} + +function LumiLayer:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value) + if self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if key == 'position' + or key == 'anchorPoint' + or key == 'scale' + or key == 'orientation' + or key == 'p0_position' + or key == 'p0_anchorPoint' + or key == 'p0_scale' + or key == 'p0_orientation' + or key == 'p1_position' + or key == 'p1_anchorPoint' + or key == 'p1_scale' + or key == 'p1_orientation' + then + if value.z ~= nil then + _setEffectAttr(key, value) + else + -- Vector2f to Vector3f + _setEffectAttr(key, Amaz.Vector3f(value.x, value.y, 0)) + end + elseif PositionDict[key] ~= nil then + local newKey = PositionDict[key][1] + local dimension = PositionDict[key][2] + self[newKey][dimension] = value + _setEffectAttr(newKey, self[newKey]) + elseif key == 'blendMode' then + _setEffectAttr(key, BlendMode[value + 1]) + elseif key == 'matteMode' then + _setEffectAttr(key, MatteMode[value + 1]) + elseif key == 'layerType' then + if type(value) == 'string' then + _setEffectAttr(key, value) + else + _setEffectAttr(key, LayerType[value + 1]) + end + else + _setEffectAttr(key, value) + end +end + +function LumiLayer:_rotateByAEAxis(_trans, _direction, _euler_angle) + -- ae xyz, editor yxz + local right = Amaz.Vector3f(1.0, 0.0, 0.0) + local up = Amaz.Vector3f(0.0, 1.0, 0.0) + local forward = Amaz.Vector3f(0.0, 0.0, 1.0) + + local cur_orientation = Amaz.Quaternionf.axisAngleToQuaternion(right, math.rad(_direction.x)) + * Amaz.Quaternionf.axisAngleToQuaternion(up, -math.rad(_direction.y)) + * Amaz.Quaternionf.axisAngleToQuaternion(forward, -math.rad(_direction.z)) + + up = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, up) + right = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, right) + forward = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, forward) + + cur_orientation = Amaz.Quaternionf.axisAngleToQuaternion(right, math.rad(_euler_angle.x)) + * Amaz.Quaternionf.axisAngleToQuaternion(up, -math.rad(_euler_angle.y)) + * Amaz.Quaternionf.axisAngleToQuaternion(forward, -math.rad(_euler_angle.z)) + * cur_orientation + + _trans.localOrientation = cur_orientation +end + +function LumiLayer:updateTRS(ratio) + self.expand_tile_trans.localScale = Amaz.Vector3f(1.0+self.expandRight+self.expandLeft, 1.0+self.expandUp+self.expandDown, 1.0) + self.expand_tile_trans.localPosition = Amaz.Vector3f( + self.expandRight-self.expandLeft, + self.expandUp-self.expandDown, + 0.0 + ) + + local ratio_c = self.compositeSize.x / self.compositeSize.y + local pos_z0 = ratio / math.tan(math.rad(self.active_cam_fovx * 0.5)) + local compositeSizeZ = self.compositeSize.y * ratio_c / ratio + -- Amaz.LOGE(self.TAG, "compositeSizeZ: "..compositeSizeZ) + self.camera.fovy = 2 * math.deg(math.atan(1 / pos_z0)) + + local rotate = Amaz.Vector3f(self.xRotation, self.yRotation, self.rotation) + self:_rotateByAEAxis(self.father_trans, self.orientation, rotate) + self.father_trans.localPosition = Amaz.Vector3f( + (self.position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.position.y / self.compositeSize.y - 0.5) * 2, + -self.position.z * 2 / compositeSizeZ + ) + self.child_trans.localPosition = Amaz.Vector3f( + -(self.anchorPoint.x / self.layerSize.x - 0.5) * 2 * ratio, + -(1.0 - self.anchorPoint.y / self.layerSize.y - 0.5) * 2, + self.anchorPoint.z * 2 / compositeSizeZ + ) + self.child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + -- parent 0 + rotate = Amaz.Vector3f(self.p0_xRotation, self.p0_yRotation, self.p0_rotation) + self:_rotateByAEAxis(self.p0_father_trans, self.p0_orientation, rotate) + self.p0_father_trans.localPosition = Amaz.Vector3f( + (self.p0_position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.p0_position.y / self.compositeSize.y - 0.5) * 2, + -self.p0_position.z * 2 / compositeSizeZ + ) + self.p0_child_trans.localPosition = Amaz.Vector3f( + -(self.p0_anchorPoint.x / self.compositeSize.x - 0.5) * 2 * ratio, + -(1.0 - self.p0_anchorPoint.y / self.compositeSize.y - 0.5) * 2, + self.p0_anchorPoint.z * 2 / compositeSizeZ + ) + self.p0_child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + -- parent 1 + rotate = Amaz.Vector3f(self.p1_xRotation, self.p1_yRotation, self.p1_rotation) + self:_rotateByAEAxis(self.p1_father_trans, self.p1_orientation, rotate) + self.p1_father_trans.localPosition = Amaz.Vector3f( + (self.p1_position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.p1_position.y / self.compositeSize.y - 0.5) * 2, + -pos_z0 - self.p1_position.z * 2 / compositeSizeZ + ) + self.p1_child_trans.localPosition = Amaz.Vector3f( + -(self.p1_anchorPoint.x / self.compositeSize.x - 0.5) * 2 * ratio, + -(1.0 - self.p1_anchorPoint.y / self.compositeSize.y - 0.5) * 2, + self.p1_anchorPoint.z * 2 / compositeSizeZ + ) + self.p1_child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + self.father_trans.localScale = Amaz.Vector3f( + self.scale.x / 100.0 * (self.layerSize.x / self.compositeSize.x), + self.scale.y / 100.0 * (self.layerSize.y / self.compositeSize.y), + self.scale.z / 100.0 + ) + self.child_trans.localScale = Amaz.Vector3f(ratio, 1, 1) + self.p0_father_trans.localScale = self.p0_scale / 100.0 + self.p1_father_trans.localScale = self.p1_scale / 100.0 + + local mMat = self.expand_tile_trans:getWorldMatrix() + local vMat = self.camera:getWorldToCameraMatrix() + local pMat = self.camera.projectionMatrix + + return {vMat * mMat, pMat:invert_Full()} +end + +function LumiLayer:onUpdate(comp, deltaTime) + self.opacity = clamp(self.opacity, 0, 100) + local trsOpacity = 1.0 + local blendOpacity = 1.0 + if self.layerType == 'Adjustment' then + blendOpacity = self.opacity / 100.0 + else + trsOpacity = self.opacity / 100.0 + end + + local hasSrcTexture = false + if self.isVisible then + for _, duration in ipairs(self.srcDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + hasSrcTexture = true + break + end + end + end + + local needTrs = self.hasTransform and hasSrcTexture + local visible = needTrs or self.hasMatte or self.hasBlend + if self.layerEntity.visible ~= visible then + self:setEntityVisible(self.layerEntity, visible) + end + if visible == false then + return + end + + self.camera.renderTexture = self.OutputTex + self.material:setTex('u_sourceTexture', self.InputTex) + self.material:setTex('u_baseTexure', self.baseTex) + self.material:setTex('u_maskTexture', self.maskTex) + self.material:setInt('u_layerType', self.layerType == 'Adjustment' and 1 or 0) + + if needTrs then + local ratio = self.OutputTex.width / self.OutputTex.height + local mvp = self:updateTRS(ratio) + self.material:setInt('u_hasTrs', 1) + self.material:setMat4('u_mvMat', mvp[1]) + self.material:setMat4('u_pMat', mvp[2]) + self.material:setFloat('u_alpha', trsOpacity) + self.material:setFloat('u_mirrorEdge', self.mirrorEdge and 1 or 0) + else + self.material:setInt('u_hasTrs', 0) + end + + if hasSrcTexture then + self.material:setInt("u_hasSourceTexture", 1) + else + self.material:setInt("u_hasSourceTexture", 0) + end + + local enableMatte = false + if self.hasMatte and self.maskTex then + for _, duration in ipairs(self.matteDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + enableMatte = true + break + end + end + end + + if self.hasBlend then + local hasBaseTexture = false + for _, duration in ipairs(self.baseDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + hasBaseTexture = true + break + end + end + self.material:setInt("u_hasBlend", 1) + self.material:setInt("u_hasBaseTexture", hasBaseTexture and 1 or 0) + self.material:setInt("u_blendMode", BlendModeIndex[self.blendMode]) + self.material:setFloat("u_layerOpacity", blendOpacity) + else + self.material:setInt("u_hasBlend", 0) + end + + if self.hasMatte then + self.material:setInt('u_hasMatte', 1) + self.material:setInt("u_enableMatte", enableMatte and 1 or 0) + self.material:setInt("u_matteMode", MatteModeIndex[self.matteMode]) + else + self.material:setInt('u_hasMatte', 0) + end +end + +exports.LumiLayer = LumiLayer +return exports diff --git a/scripts/7681599071768956161/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag b/scripts/7681599071768956161/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag new file mode 100644 index 0000000000000000000000000000000000000000..275c908db99546663d62a01cc2224a93a7bdd98e --- /dev/null +++ b/scripts/7681599071768956161/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag @@ -0,0 +1,1056 @@ +precision highp float; +precision highp int; + +uniform mediump int u_enableMatte; +uniform mediump sampler2D u_maskTexture; +uniform mediump int u_matteMode; +uniform mediump int u_blendMode; +uniform mediump int u_layerType; +uniform mediump int u_hasMatte; +uniform float u_layerOpacity; +uniform mediump int u_hasBlend; +uniform mediump int u_hasBaseTexture; +uniform mediump sampler2D u_baseTexure; +uniform mediump int u_hasSourceTexture; +uniform mediump int u_hasTrs; +uniform mat4 u_mvMat; +uniform mat4 u_pMat; +uniform float u_mirrorEdge; +uniform mediump sampler2D u_sourceTexture; +uniform float u_alpha; + +varying vec2 uv0; + +vec3 _2206; + +vec4 _f7(vec3 _p0, vec3 _p1, vec3 _p2, vec3 _p3, vec3 _p4) +{ + vec3 _404 = _p3 - _p2; + vec3 _408 = _p4 - _p2; + vec3 _412 = cross(_p1, _408); + float _416 = dot(_404, _412); + if (_416 <= 1.0000000116860974230803549289703e-07) + { + return vec4(-1.0); + } + vec3 _428 = _p0 - _p2; + float _434 = dot(_428, _412) / _416; + if ((_434 < 0.0) || (_434 > 1.0)) + { + return vec4(-1.0); + } + vec3 _446 = cross(_428, _404); + float _452 = dot(_p1, _446) / _416; + bool _454 = _452 < 0.0; + bool _462; + if (!_454) + { + _462 = (_434 + _452) > 1.0; + } + else + { + _462 = _454; + } + if (_462) + { + return vec4(-1.0); + } + return vec4(_434, _452, dot(_408, _446) / _416, 1.0); +} + +vec2 _f8(mat4 _p0, mat4 _p1, vec2 _p2) +{ + vec3 _501 = (_p0 * vec4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + vec3 _507 = (_p0 * vec4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _512 = (_p0 * vec4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _517 = (_p0 * vec4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + vec4 _527 = _p1 * vec4((_p2 * 2.0) - vec2(1.0), 0.0, 1.0); + vec4 _t20 = _527; + vec3 _543 = normalize((_527.xyz / vec3(_t20.w)) - vec3(0.0)); + vec3 param = vec3(0.0); + vec3 param_1 = _543; + vec3 _551 = (_p0 * vec4(-10.0, -10.0, 0.0, 1.0)).xyz; + vec3 param_2 = _551; + vec3 param_3 = _501; + vec3 param_4 = _512; + vec4 _t24 = _f7(param, param_1, param_2, param_3, param_4); + vec3 param_5 = vec3(0.0); + vec3 param_6 = _543; + vec3 param_7 = _517; + vec3 param_8 = _507; + vec3 _568 = (_p0 * vec4(10.0, 10.0, 0.0, 1.0)).xyz; + vec3 param_9 = _568; + vec4 _t25 = _f7(param_5, param_6, param_7, param_8, param_9); + vec3 param_10 = vec3(0.0); + vec3 param_11 = _543; + vec3 param_12 = _551; + vec3 param_13 = _512; + vec3 param_14 = _501; + vec4 _t26 = _f7(param_10, param_11, param_12, param_13, param_14); + vec3 param_15 = vec3(0.0); + vec3 param_16 = _543; + vec3 param_17 = _517; + vec3 param_18 = _568; + vec3 param_19 = _507; + vec4 _t27 = _f7(param_15, param_16, param_17, param_18, param_19); + vec2 _732 = (((((((vec2(-4.5) * ((1.0 - _t24.x) - _t24.y)) + (vec2(5.5, -4.5) * _t24.x)) + (vec2(-4.5, 5.5) * _t24.y)) * step(0.0, _t24.w)) + ((((vec2(-4.5, 5.5) * ((1.0 - _t25.x) - _t25.y)) + (vec2(5.5, -4.5) * _t25.x)) + (vec2(5.5) * _t25.y)) * (step(_t24.w, 0.0) * step(0.0, _t25.w)))) + ((((vec2(-4.5) * ((1.0 - _t26.x) - _t26.y)) + (vec2(-4.5, 5.5) * _t26.x)) + (vec2(5.5, -4.5) * _t26.y)) * ((step(_t24.w, 0.0) * step(_t25.w, 0.0)) * step(0.0, _t26.w)))) + ((((vec2(-4.5, 5.5) * ((1.0 - _t27.x) - _t27.y)) + (vec2(5.5) * _t27.x)) + (vec2(5.5, -4.5) * _t27.y)) * (((step(_t24.w, 0.0) * step(_t25.w, 0.0)) * step(_t26.w, 0.0)) * step(0.0, _t27.w)))) + (vec2(-10000.0) * (((step(_t24.w, 0.0) * step(_t25.w, 0.0)) * step(_t26.w, 0.0)) * step(_t27.w, 0.0))); + return _732; +} + +vec2 _f10(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +float _f9(vec2 _p0) +{ + vec2 _t33 = step(vec2(0.0), _p0) * step(_p0, vec2(1.0)); + return _t33.x * _t33.y; +} + +float _f5(vec3 _p0) +{ + return dot(_p0, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +vec4 _f11(vec4 _p0) +{ + vec4 _t34 = vec4(0.0); + if (u_enableMatte == 1) + { + _t34 = texture2D(u_maskTexture, uv0); + } + float _t35 = _t34.w; + if (u_matteMode == 1) + { + vec3 param = _t34.xyz; + _t35 = _f5(param); + } + else + { + if (u_matteMode == 2) + { + _t35 = 1.0 - _t34.w; + } + else + { + if (u_matteMode == 3) + { + vec3 param_1 = _t34.xyz; + _t35 = 1.0 - _f5(param_1); + } + } + } + return _p0 * _t35; +} + +float _f1(float _p0, float _p1) +{ + float _199; + if (_p0 < 0.5) + { + _199 = _p1 - (((1.0 - (2.0 * _p0)) * _p1) * (1.0 - _p1)); + } + else + { + float _218; + if (_p1 < 0.25) + { + _218 = _p1 + ((((2.0 * _p0) - 1.0) * _p1) * ((((16.0 * _p1) - 12.0) * _p1) + 3.0)); + } + else + { + _218 = _p1 + (((2.0 * _p0) - 1.0) * (sqrt(_p1) - _p1)); + } + _199 = _218; + } + return _199; +} + +vec3 _f2(vec3 _p0, vec3 _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return vec3(_f1(param, param_1), _f1(param_2, param_3), _f1(param_4, param_5)); +} + +float _f3(float _p0, float _p1) +{ + float _283; + if (_p0 < 0.5) + { + _283 = (2.0 * _p0) * _p1; + } + else + { + _283 = 1.0 - ((2.0 * (1.0 - _p0)) * (1.0 - _p1)); + } + return _283; +} + +vec3 _f4(vec3 _p0, vec3 _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return vec3(_f3(param, param_1), _f3(param_2, param_3), _f3(param_4, param_5)); +} + +float _f13(vec3 _p0) +{ + return max(_p0.x, max(_p0.y, _p0.z)) - min(_p0.x, min(_p0.y, _p0.z)); +} + +vec3 _f12(inout vec3 _p0, float _p1) +{ + if (_p0.z > _p0.x) + { + _p0.y = ((_p0.y - _p0.x) * _p1) / (_p0.z - _p0.x); + _p0.z = _p1; + } + else + { + _p0.y = 0.0; + _p0.z = 0.0; + } + _p0.x = 0.0; + return _p0; +} + +vec3 _f14(inout vec3 _p0, float _p1) +{ + bool _870 = _p0.x <= _p0.y; + bool _878; + if (_870) + { + _878 = _p0.x <= _p0.z; + } + else + { + _878 = _870; + } + if (_878) + { + if (_p0.y <= _p0.z) + { + vec3 param = _p0; + float param_1 = _p1; + vec3 _892 = _f12(param, param_1); + _p0 = _892; + } + else + { + vec3 param_2 = _p0.xzy; + float param_3 = _p1; + vec3 _899 = _f12(param_2, param_3); + _p0 = vec3(_899.x, _899.z, _899.y); + } + } + else + { + bool _907 = _p0.y <= _p0.x; + bool _915; + if (_907) + { + _915 = _p0.y <= _p0.z; + } + else + { + _915 = _907; + } + if (_915) + { + if (_p0.x <= _p0.z) + { + vec3 param_4 = _p0.yxz; + float param_5 = _p1; + vec3 _930 = _f12(param_4, param_5); + _p0 = vec3(_930.y, _930.x, _930.z); + } + else + { + vec3 param_6 = _p0.yzx; + float param_7 = _p1; + vec3 _939 = _f12(param_6, param_7); + _p0 = vec3(_939.z, _939.x, _939.y); + } + } + else + { + if (_p0.x <= _p0.y) + { + vec3 param_8 = _p0.zxy; + float param_9 = _p1; + vec3 _955 = _f12(param_8, param_9); + _p0 = vec3(_955.y, _955.z, _955.x); + } + else + { + vec3 param_10 = _p0.zyx; + float param_11 = _p1; + vec3 _964 = _f12(param_10, param_11); + _p0 = vec3(_964.z, _964.y, _964.x); + } + } + } + return _p0; +} + +vec3 _f6(inout vec3 _p0, inout float _p1) +{ + vec3 param = _p0; + _p0 += vec3(_p1 - _f5(param)); + vec3 param_1 = _p0; + _p1 = _f5(param_1); + float _354 = min(_p0.x, min(_p0.y, _p0.z)); + float _357 = _p0.x; + float _359 = _p0.y; + float _361 = _p0.z; + float _363 = max(_357, max(_359, _361)); + if (_354 < 0.0) + { + _p0 = mix(vec3(_p1, _p1, _p1), _p0, vec3(_p1 / (_p1 - _354))); + } + if (_363 > 1.0) + { + _p0 = mix(vec3(_p1, _p1, _p1), _p0, vec3((1.0 - _p1) / (_363 - _p1))); + } + return _p0; +} + +vec3 _f15(vec3 _p0, vec3 _p1) +{ + vec3 param = _p1; + vec3 param_1 = _p0; + float param_2 = _f13(param); + vec3 _976 = _f14(param_1, param_2); + vec3 param_3 = _p1; + vec3 param_4 = _976; + float param_5 = _f5(param_3); + vec3 _982 = _f6(param_4, param_5); + return _982; +} + +vec3 _f16(vec3 _p0, vec3 _p1) +{ + vec3 param = _p0; + vec3 param_1 = _p1; + float param_2 = _f13(param); + vec3 _991 = _f14(param_1, param_2); + vec3 param_3 = _p1; + vec3 param_4 = _991; + float param_5 = _f5(param_3); + vec3 _997 = _f6(param_4, param_5); + return _997; +} + +vec3 _f17(vec3 _p0, vec3 _p1) +{ + vec3 param = _p1; + vec3 param_1 = _p0; + float param_2 = _f5(param); + vec3 _1006 = _f6(param_1, param_2); + return _1006; +} + +float _f21(float _p0, float _p1) +{ + if (_p1 >= 1.0) + { + return 1.0; + } + else + { + if (_p0 <= 0.0) + { + return 0.0; + } + else + { + return 1.0 - min(1.0, (1.0 - _p1) / _p0); + } + } +} + +vec3 _f22(vec3 _p0, vec3 _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return vec3(_f21(param, param_1), _f21(param_2, param_3), _f21(param_4, param_5)); +} + +float _f23(float _p0, float _p1) +{ + return max(0.0, (_p1 + _p0) - 1.0); +} + +vec3 _f24(vec3 _p0, vec3 _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return vec3(_f23(param, param_1), _f23(param_2, param_3), _f23(param_4, param_5)); +} + +float _f25(float _p0, float _p1) +{ + if (_p1 <= 0.0) + { + return 0.0; + } + if (_p0 >= 1.0) + { + return 1.0; + } + else + { + return min(1.0, _p1 / (1.0 - _p0)); + } +} + +vec3 _f26(vec3 _p0, vec3 _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return vec3(_f25(param, param_1), _f25(param_2, param_3), _f25(param_4, param_5)); +} + +float _f27(float _p0, float _p1) +{ + return min(1.0, _p1 + _p0); +} + +vec3 _f28(vec3 _p0, vec3 _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return vec3(_f27(param, param_1), _f27(param_2, param_3), _f27(param_4, param_5)); +} + +float _f29(float _p0, float _p1) +{ + float _1194; + if (_p0 <= 0.5) + { + float param = _p1; + float param_1 = 2.0 * _p0; + _1194 = _f21(param, param_1); + } + else + { + float param_2 = _p1; + float param_3 = 2.0 * (_p0 - 0.5); + _1194 = _f25(param_2, param_3); + } + return _1194; +} + +vec3 _f30(vec3 _p0, vec3 _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return vec3(_f29(param, param_1), _f29(param_2, param_3), _f29(param_4, param_5)); +} + +float _f31(float _p0, float _p1) +{ + float _1240; + if (_p0 <= 0.5) + { + float param = _p1; + float param_1 = 2.0 * _p0; + _1240 = _f23(param, param_1); + } + else + { + float param_2 = _p1; + float param_3 = 2.0 * (_p0 - 0.5); + _1240 = _f27(param_2, param_3); + } + return _1240; +} + +vec3 _f32(vec3 _p0, vec3 _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return vec3(_f31(param, param_1), _f31(param_2, param_3), _f31(param_4, param_5)); +} + +float _f33(float _p0, float _p1) +{ + float _1286; + if (_p0 <= 0.5) + { + _1286 = min(_p1, 2.0 * _p0); + } + else + { + _1286 = max(_p1, 2.0 * (_p0 - 0.5)); + } + return _1286; +} + +vec3 _f34(vec3 _p0, vec3 _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return vec3(_f33(param, param_1), _f33(param_2, param_3), _f33(param_4, param_5)); +} + +float _f35(float _p0, float _p1) +{ + return float((_p1 + _p0) >= 1.0); +} + +vec3 _f36(vec3 _p0, vec3 _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return vec3(_f35(param, param_1), _f35(param_2, param_3), _f35(param_4, param_5)); +} + +float _f37(float _p0, float _p1) +{ + float _1359; + if (_p0 > 0.0) + { + _1359 = min(1.0, _p1 / _p0); + } + else + { + _1359 = 1.0; + } + return _1359; +} + +vec3 _f38(vec3 _p0, vec3 _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return vec3(_f37(param, param_1), _f37(param_2, param_3), _f37(param_4, param_5)); +} + +vec3 _f20(vec3 _p0, vec3 _p1) +{ + vec3 param = _p0; + vec3 param_1 = _p1; + float param_2 = _f5(param); + vec3 _1042 = _f6(param_1, param_2); + return _1042; +} + +vec3 _f19(vec3 _p0, vec3 _p1) +{ + vec3 param = _p1; + vec3 param_1 = _p0; + bvec3 _1032 = bvec3(_f5(param) > _f5(param_1)); + return vec3(_1032.x ? _p1.x : _p0.x, _1032.y ? _p1.y : _p0.y, _1032.z ? _p1.z : _p0.z); +} + +vec3 _f18(vec3 _p0, vec3 _p1) +{ + vec3 param = _p1; + vec3 param_1 = _p0; + bvec3 _1019 = bvec3(_f5(param) <= _f5(param_1)); + return vec3(_1019.x ? _p1.x : _p0.x, _1019.y ? _p1.y : _p0.y, _1019.z ? _p1.z : _p0.z); +} + +float _f0(vec2 _p0) +{ + return fract(sin(dot(_p0, vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875); +} + +vec4 _f39(inout vec4 _p0, inout vec4 _p1) +{ + float _1395 = _p0.w; + vec4 _1398 = _p0; + vec3 _1401 = _1398.xyz / vec3(max(_1395, 9.9999997473787516355514526367188e-06)); + _p0.x = _1401.x; + _p0.y = _1401.y; + _p0.z = _1401.z; + float _1409 = _p1.w; + vec4 _1411 = _p1; + vec3 _1414 = _1411.xyz / vec3(max(_1409, 9.9999997473787516355514526367188e-06)); + _p1.x = _1414.x; + _p1.y = _1414.y; + _p1.z = _1414.z; + vec4 _t36 = _p1; + if (u_blendMode == 1) + { + vec3 _1432 = _p0.xyz + _p1.xyz; + _t36.x = _1432.x; + _t36.y = _1432.y; + _t36.z = _1432.z; + } + else + { + if (u_blendMode == 2) + { + vec3 _1448 = _p0.xyz * _p1.xyz; + _t36.x = _1448.x; + _t36.y = _1448.y; + _t36.z = _1448.z; + } + else + { + if (u_blendMode == 3) + { + vec3 _1465 = abs(_p0.xyz - _p1.xyz); + _t36.x = _1465.x; + _t36.y = _1465.y; + _t36.z = _1465.z; + } + else + { + if (u_blendMode == 4) + { + float _1481; + if (_p1.x < 0.5) + { + _1481 = (2.0 * _p1.x) * _p0.x; + } + else + { + _1481 = 1.0 - ((2.0 * (1.0 - _p1.x)) * (1.0 - _p0.x)); + } + float _1504; + if (_p1.y < 0.5) + { + _1504 = (2.0 * _p1.y) * _p0.y; + } + else + { + _1504 = 1.0 - ((2.0 * (1.0 - _p1.y)) * (1.0 - _p0.y)); + } + float _1527; + if (_p1.z < 0.5) + { + _1527 = (2.0 * _p1.z) * _p0.z; + } + else + { + _1527 = 1.0 - ((2.0 * (1.0 - _p1.z)) * (1.0 - _p0.z)); + } + vec3 _1547 = vec3(_1481, _1504, _1527); + _t36.x = _1547.x; + _t36.y = _1547.y; + _t36.z = _1547.z; + } + else + { + if (u_blendMode == 5) + { + vec3 _1564 = min(_p0.xyz, _p1.xyz); + _t36.x = _1564.x; + _t36.y = _1564.y; + _t36.z = _1564.z; + } + else + { + if (u_blendMode == 6) + { + vec3 _1581 = max(_p0.xyz, _p1.xyz); + _t36.x = _1581.x; + _t36.y = _1581.y; + _t36.z = _1581.z; + } + else + { + if (u_blendMode == 7) + { + vec3 param = _p0.xyz; + vec3 param_1 = _p1.xyz; + vec3 _1600 = _f2(param, param_1); + _t36.x = _1600.x; + _t36.y = _1600.y; + _t36.z = _1600.z; + } + else + { + if (u_blendMode == 8) + { + vec3 param_2 = _p0.xyz; + vec3 param_3 = _p1.xyz; + vec3 _1619 = _f4(param_2, param_3); + _t36.x = _1619.x; + _t36.y = _1619.y; + _t36.z = _1619.z; + } + else + { + if (u_blendMode == 9) + { + vec3 param_4 = _p0.xyz; + vec3 param_5 = _p1.xyz; + vec3 _1638 = _f15(param_4, param_5); + _t36.x = _1638.x; + _t36.y = _1638.y; + _t36.z = _1638.z; + } + else + { + if (u_blendMode == 10) + { + vec3 param_6 = _p0.xyz; + vec3 param_7 = _p1.xyz; + vec3 _1657 = _f16(param_6, param_7); + _t36.x = _1657.x; + _t36.y = _1657.y; + _t36.z = _1657.z; + } + else + { + if (u_blendMode == 11) + { + vec3 param_8 = _p0.xyz; + vec3 param_9 = _p1.xyz; + vec3 _1676 = _f17(param_8, param_9); + _t36.x = _1676.x; + _t36.y = _1676.y; + _t36.z = _1676.z; + } + else + { + if (u_blendMode == 12) + { + vec3 _1699 = (_p0.xyz + _p1.xyz) - (_p0.xyz * _p1.xyz); + _t36.x = _1699.x; + _t36.y = _1699.y; + _t36.z = _1699.z; + } + else + { + if (u_blendMode == 13) + { + vec3 param_10 = _p0.xyz; + vec3 param_11 = _p1.xyz; + vec3 _1718 = _f22(param_10, param_11); + _t36.x = _1718.x; + _t36.y = _1718.y; + _t36.z = _1718.z; + } + else + { + if (u_blendMode == 14) + { + vec3 param_12 = _p0.xyz; + vec3 param_13 = _p1.xyz; + vec3 _1737 = _f24(param_12, param_13); + _t36.x = _1737.x; + _t36.y = _1737.y; + _t36.z = _1737.z; + } + else + { + if (u_blendMode == 15) + { + vec3 param_14 = _p0.xyz; + vec3 param_15 = _p1.xyz; + vec3 _1756 = _f26(param_14, param_15); + _t36.x = _1756.x; + _t36.y = _1756.y; + _t36.z = _1756.z; + } + else + { + if (u_blendMode == 16) + { + vec3 param_16 = _p0.xyz; + vec3 param_17 = _p1.xyz; + vec3 _1775 = _f28(param_16, param_17); + _t36.x = _1775.x; + _t36.y = _1775.y; + _t36.z = _1775.z; + } + else + { + if (u_blendMode == 17) + { + vec3 param_18 = _p0.xyz; + vec3 param_19 = _p1.xyz; + vec3 _1794 = _f30(param_18, param_19); + _t36.x = _1794.x; + _t36.y = _1794.y; + _t36.z = _1794.z; + } + else + { + if (u_blendMode == 18) + { + vec3 param_20 = _p0.xyz; + vec3 param_21 = _p1.xyz; + vec3 _1813 = _f32(param_20, param_21); + _t36.x = _1813.x; + _t36.y = _1813.y; + _t36.z = _1813.z; + } + else + { + if (u_blendMode == 19) + { + vec3 param_22 = _p0.xyz; + vec3 param_23 = _p1.xyz; + vec3 _1832 = _f34(param_22, param_23); + _t36.x = _1832.x; + _t36.y = _1832.y; + _t36.z = _1832.z; + } + else + { + if (u_blendMode == 20) + { + vec3 param_24 = _p0.xyz; + vec3 param_25 = _p1.xyz; + vec3 _1851 = _f36(param_24, param_25); + _t36.x = _1851.x; + _t36.y = _1851.y; + _t36.z = _1851.z; + } + else + { + if (u_blendMode == 21) + { + vec3 _1875 = (_p1.xyz + _p0.xyz) - ((_p1.xyz * 2.0) * _p0.xyz); + _t36.x = _1875.x; + _t36.y = _1875.y; + _t36.z = _1875.z; + } + else + { + if (u_blendMode == 22) + { + vec3 _1893 = max(vec3(0.0), _p1.xyz - _p0.xyz); + _t36.x = _1893.x; + _t36.y = _1893.y; + _t36.z = _1893.z; + } + else + { + if (u_blendMode == 23) + { + vec3 param_26 = _p0.xyz; + vec3 param_27 = _p1.xyz; + vec3 _1912 = _f38(param_26, param_27); + _t36.x = _1912.x; + _t36.y = _1912.y; + _t36.z = _1912.z; + } + else + { + if (u_blendMode == 24) + { + vec3 param_28 = _p0.xyz; + vec3 param_29 = _p1.xyz; + vec3 _1931 = _f20(param_28, param_29); + _t36.x = _1931.x; + _t36.y = _1931.y; + _t36.z = _1931.z; + } + else + { + if (u_blendMode == 25) + { + vec3 param_30 = _p0.xyz; + vec3 param_31 = _p1.xyz; + vec3 _1950 = _f19(param_30, param_31); + _t36.x = _1950.x; + _t36.y = _1950.y; + _t36.z = _1950.z; + } + else + { + if (u_blendMode == 26) + { + vec3 param_32 = _p0.xyz; + vec3 param_33 = _p1.xyz; + vec3 _1969 = _f18(param_32, param_33); + _t36.x = _1969.x; + _t36.y = _1969.y; + _t36.z = _1969.z; + } + else + { + if (u_blendMode == 27) + { + bool _1984 = _p0.w == 1.0; + bool _2000; + if (!_1984) + { + bool _1990 = _p0.w > 0.0; + bool _1999; + if (_1990) + { + vec2 param_34 = uv0; + _1999 = _p0.w > _f0(param_34); + } + else + { + _1999 = _1990; + } + _2000 = _1999; + } + else + { + _2000 = _1984; + } + if (_2000) + { + _t36.x = _p0.xyz.x; + _t36.y = _p0.xyz.y; + _t36.z = _p0.xyz.z; + } + } + else + { + _t36.x = _p0.xyz.x; + _t36.y = _p0.xyz.y; + _t36.z = _p0.xyz.z; + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + vec4 _t37 = vec4(0.0); + if (u_layerType == 1) + { + float _t38 = 1.0; + if (u_hasMatte == 1) + { + vec4 param_35 = vec4(1.0); + _t38 = _f11(param_35).w; + } + vec4 _2051 = mix(_p1, vec4(_t36.xyz, _p0.w), vec4(u_layerOpacity * _t38)); + _t37 = _2051; + float _2053 = _t37.w; + vec3 _2056 = _2051.xyz * _2053; + _t37.x = _2056.x; + _t37.y = _2056.y; + _t37.z = _2056.z; + } + else + { + vec3 _2091 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t36.xyz * (_p0.w * _p1.w)); + _t37.x = _2091.x; + _t37.y = _2091.y; + _t37.z = _2091.z; + _t37.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t37; +} + +void main() +{ + vec4 _t39 = vec4(0.0); + bool _2114 = u_hasBlend == 1; + if (_2114) + { + if (u_hasBaseTexture == 1) + { + _t39 = texture2D(u_baseTexure, uv0); + } + if (u_hasSourceTexture == 0) + { + gl_FragData[0] = _t39; + return; + } + } + vec4 _t40 = vec4(0.0); + if (u_hasTrs == 1) + { + mat4 param = u_mvMat; + mat4 param_1 = u_pMat; + vec2 param_2 = uv0; + vec2 _2152 = _f8(param, param_1, param_2); + float _2155 = step(u_mirrorEdge, 0.5); + vec2 param_3 = _2152; + vec2 _2165 = (_2152 * _2155) + (_f10(param_3) * (1.0 - _2155)); + vec2 param_4 = _2165; + _t40 = (texture2D(u_sourceTexture, _2165) * u_alpha) * _f9(param_4); + } + else + { + if (u_hasSourceTexture == 1) + { + _t40 = texture2D(u_sourceTexture, uv0); + } + } + if ((u_layerType != 1) && (u_hasMatte == 1)) + { + vec4 param_5 = _t40; + _t40 = _f11(param_5); + } + if (_2114) + { + vec4 param_6 = _t40; + vec4 param_7 = _t39; + vec4 _2203 = _f39(param_6, param_7); + _t40 = _2203; + } + gl_FragData[0] = _t40; +} + diff --git a/scripts/7681599071768956161/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681599071768956161/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681599071768956161/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681599071768956161/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag b/scripts/7681599071768956161/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag new file mode 100644 index 0000000000000000000000000000000000000000..e59ee50f36103b1aa81808ae4b640d17f376012e --- /dev/null +++ b/scripts/7681599071768956161/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag @@ -0,0 +1,1115 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + int u_enableMatte; + int u_matteMode; + int u_blendMode; + int u_layerType; + int u_hasMatte; + float u_layerOpacity; + int u_hasBlend; + int u_hasBaseTexture; + int u_hasSourceTexture; + int u_hasTrs; + float4x4 u_mvMat; + float4x4 u_pMat; + float u_mirrorEdge; + float u_alpha; +}; + +constant float3 _2206 = {}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f7(thread const float3& _p0, thread const float3& _p1, thread const float3& _p2, thread const float3& _p3, thread const float3& _p4) +{ + float3 _404 = _p3 - _p2; + float3 _408 = _p4 - _p2; + float3 _412 = cross(_p1, _408); + float _416 = dot(_404, _412); + if (_416 <= 1.0000000116860974230803549289703e-07) + { + return float4(-1.0); + } + float3 _428 = _p0 - _p2; + float _434 = dot(_428, _412) / _416; + if ((_434 < 0.0) || (_434 > 1.0)) + { + return float4(-1.0); + } + float3 _446 = cross(_428, _404); + float _452 = dot(_p1, _446) / _416; + bool _454 = _452 < 0.0; + bool _462; + if (!_454) + { + _462 = (_434 + _452) > 1.0; + } + else + { + _462 = _454; + } + if (_462) + { + return float4(-1.0); + } + return float4(_434, _452, dot(_408, _446) / _416, 1.0); +} + +static inline __attribute__((always_inline)) +float2 _f8(thread const float4x4& _p0, thread const float4x4& _p1, thread const float2& _p2) +{ + float3 _501 = (_p0 * float4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + float3 _507 = (_p0 * float4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _512 = (_p0 * float4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _517 = (_p0 * float4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + float4 _527 = _p1 * float4((_p2 * 2.0) - float2(1.0), 0.0, 1.0); + float4 _t20 = _527; + float3 _543 = fast::normalize((_527.xyz / float3(_t20.w)) - float3(0.0)); + float3 param = float3(0.0); + float3 param_1 = _543; + float3 _551 = (_p0 * float4(-10.0, -10.0, 0.0, 1.0)).xyz; + float3 param_2 = _551; + float3 param_3 = _501; + float3 param_4 = _512; + float4 _t24 = _f7(param, param_1, param_2, param_3, param_4); + float3 param_5 = float3(0.0); + float3 param_6 = _543; + float3 param_7 = _517; + float3 param_8 = _507; + float3 _568 = (_p0 * float4(10.0, 10.0, 0.0, 1.0)).xyz; + float3 param_9 = _568; + float4 _t25 = _f7(param_5, param_6, param_7, param_8, param_9); + float3 param_10 = float3(0.0); + float3 param_11 = _543; + float3 param_12 = _551; + float3 param_13 = _512; + float3 param_14 = _501; + float4 _t26 = _f7(param_10, param_11, param_12, param_13, param_14); + float3 param_15 = float3(0.0); + float3 param_16 = _543; + float3 param_17 = _517; + float3 param_18 = _568; + float3 param_19 = _507; + float4 _t27 = _f7(param_15, param_16, param_17, param_18, param_19); + float2 _732 = (((((((float2(-4.5) * ((1.0 - _t24.x) - _t24.y)) + (float2(5.5, -4.5) * _t24.x)) + (float2(-4.5, 5.5) * _t24.y)) * step(0.0, _t24.w)) + ((((float2(-4.5, 5.5) * ((1.0 - _t25.x) - _t25.y)) + (float2(5.5, -4.5) * _t25.x)) + (float2(5.5) * _t25.y)) * (step(_t24.w, 0.0) * step(0.0, _t25.w)))) + ((((float2(-4.5) * ((1.0 - _t26.x) - _t26.y)) + (float2(-4.5, 5.5) * _t26.x)) + (float2(5.5, -4.5) * _t26.y)) * ((step(_t24.w, 0.0) * step(_t25.w, 0.0)) * step(0.0, _t26.w)))) + ((((float2(-4.5, 5.5) * ((1.0 - _t27.x) - _t27.y)) + (float2(5.5) * _t27.x)) + (float2(5.5, -4.5) * _t27.y)) * (((step(_t24.w, 0.0) * step(_t25.w, 0.0)) * step(_t26.w, 0.0)) * step(0.0, _t27.w)))) + (float2(-10000.0) * (((step(_t24.w, 0.0) * step(_t25.w, 0.0)) * step(_t26.w, 0.0)) * step(_t27.w, 0.0))); + return _732; +} + +static inline __attribute__((always_inline)) +float2 _f10(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float _f9(thread const float2& _p0) +{ + float2 _t33 = step(float2(0.0), _p0) * step(_p0, float2(1.0)); + return _t33.x * _t33.y; +} + +static inline __attribute__((always_inline)) +float _f5(thread const float3& _p0) +{ + return dot(_p0, float3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +static inline __attribute__((always_inline)) +float4 _f11(thread const float4& _p0, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode) +{ + float4 _t34 = float4(0.0); + if (u_enableMatte == 1) + { + _t34 = u_maskTexture.sample(u_maskTextureSmplr, uv0); + } + float _t35 = _t34.w; + if (u_matteMode == 1) + { + float3 param = _t34.xyz; + _t35 = _f5(param); + } + else + { + if (u_matteMode == 2) + { + _t35 = 1.0 - _t34.w; + } + else + { + if (u_matteMode == 3) + { + float3 param_1 = _t34.xyz; + _t35 = 1.0 - _f5(param_1); + } + } + } + return _p0 * _t35; +} + +static inline __attribute__((always_inline)) +float _f1(thread const float& _p0, thread const float& _p1) +{ + float _199; + if (_p0 < 0.5) + { + _199 = _p1 - (((1.0 - (2.0 * _p0)) * _p1) * (1.0 - _p1)); + } + else + { + float _218; + if (_p1 < 0.25) + { + _218 = _p1 + ((((2.0 * _p0) - 1.0) * _p1) * ((((16.0 * _p1) - 12.0) * _p1) + 3.0)); + } + else + { + _218 = _p1 + (((2.0 * _p0) - 1.0) * (sqrt(_p1) - _p1)); + } + _199 = _218; + } + return _199; +} + +static inline __attribute__((always_inline)) +float3 _f2(thread const float3& _p0, thread const float3& _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return float3(_f1(param, param_1), _f1(param_2, param_3), _f1(param_4, param_5)); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float& _p0, thread const float& _p1) +{ + float _283; + if (_p0 < 0.5) + { + _283 = (2.0 * _p0) * _p1; + } + else + { + _283 = 1.0 - ((2.0 * (1.0 - _p0)) * (1.0 - _p1)); + } + return _283; +} + +static inline __attribute__((always_inline)) +float3 _f4(thread const float3& _p0, thread const float3& _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return float3(_f3(param, param_1), _f3(param_2, param_3), _f3(param_4, param_5)); +} + +static inline __attribute__((always_inline)) +float _f13(thread const float3& _p0) +{ + return fast::max(_p0.x, fast::max(_p0.y, _p0.z)) - fast::min(_p0.x, fast::min(_p0.y, _p0.z)); +} + +static inline __attribute__((always_inline)) +float3 _f12(thread float3& _p0, thread const float& _p1) +{ + if (_p0.z > _p0.x) + { + _p0.y = ((_p0.y - _p0.x) * _p1) / (_p0.z - _p0.x); + _p0.z = _p1; + } + else + { + _p0.y = 0.0; + _p0.z = 0.0; + } + _p0.x = 0.0; + return _p0; +} + +static inline __attribute__((always_inline)) +float3 _f14(thread float3& _p0, thread const float& _p1) +{ + bool _870 = _p0.x <= _p0.y; + bool _878; + if (_870) + { + _878 = _p0.x <= _p0.z; + } + else + { + _878 = _870; + } + if (_878) + { + if (_p0.y <= _p0.z) + { + float3 param = _p0; + float param_1 = _p1; + float3 _892 = _f12(param, param_1); + _p0 = _892; + } + else + { + float3 param_2 = _p0.xzy; + float param_3 = _p1; + float3 _899 = _f12(param_2, param_3); + _p0 = float3(_899.x, _899.z, _899.y); + } + } + else + { + bool _907 = _p0.y <= _p0.x; + bool _915; + if (_907) + { + _915 = _p0.y <= _p0.z; + } + else + { + _915 = _907; + } + if (_915) + { + if (_p0.x <= _p0.z) + { + float3 param_4 = _p0.yxz; + float param_5 = _p1; + float3 _930 = _f12(param_4, param_5); + _p0 = float3(_930.y, _930.x, _930.z); + } + else + { + float3 param_6 = _p0.yzx; + float param_7 = _p1; + float3 _939 = _f12(param_6, param_7); + _p0 = float3(_939.z, _939.x, _939.y); + } + } + else + { + if (_p0.x <= _p0.y) + { + float3 param_8 = _p0.zxy; + float param_9 = _p1; + float3 _955 = _f12(param_8, param_9); + _p0 = float3(_955.y, _955.z, _955.x); + } + else + { + float3 param_10 = _p0.zyx; + float param_11 = _p1; + float3 _964 = _f12(param_10, param_11); + _p0 = float3(_964.z, _964.y, _964.x); + } + } + } + return _p0; +} + +static inline __attribute__((always_inline)) +float3 _f6(thread float3& _p0, thread float& _p1) +{ + float3 param = _p0; + _p0 += float3(_p1 - _f5(param)); + float3 param_1 = _p0; + _p1 = _f5(param_1); + float _354 = fast::min(_p0.x, fast::min(_p0.y, _p0.z)); + float _357 = _p0.x; + float _359 = _p0.y; + float _361 = _p0.z; + float _363 = fast::max(_357, fast::max(_359, _361)); + if (_354 < 0.0) + { + _p0 = mix(float3(_p1, _p1, _p1), _p0, float3(_p1 / (_p1 - _354))); + } + if (_363 > 1.0) + { + _p0 = mix(float3(_p1, _p1, _p1), _p0, float3((1.0 - _p1) / (_363 - _p1))); + } + return _p0; +} + +static inline __attribute__((always_inline)) +float3 _f15(thread const float3& _p0, thread const float3& _p1) +{ + float3 param = _p1; + float3 param_1 = _p0; + float param_2 = _f13(param); + float3 _976 = _f14(param_1, param_2); + float3 param_3 = _p1; + float3 param_4 = _976; + float param_5 = _f5(param_3); + float3 _982 = _f6(param_4, param_5); + return _982; +} + +static inline __attribute__((always_inline)) +float3 _f16(thread const float3& _p0, thread const float3& _p1) +{ + float3 param = _p0; + float3 param_1 = _p1; + float param_2 = _f13(param); + float3 _991 = _f14(param_1, param_2); + float3 param_3 = _p1; + float3 param_4 = _991; + float param_5 = _f5(param_3); + float3 _997 = _f6(param_4, param_5); + return _997; +} + +static inline __attribute__((always_inline)) +float3 _f17(thread const float3& _p0, thread const float3& _p1) +{ + float3 param = _p1; + float3 param_1 = _p0; + float param_2 = _f5(param); + float3 _1006 = _f6(param_1, param_2); + return _1006; +} + +static inline __attribute__((always_inline)) +float _f21(thread const float& _p0, thread const float& _p1) +{ + if (_p1 >= 1.0) + { + return 1.0; + } + else + { + if (_p0 <= 0.0) + { + return 0.0; + } + else + { + return 1.0 - fast::min(1.0, (1.0 - _p1) / _p0); + } + } +} + +static inline __attribute__((always_inline)) +float3 _f22(thread const float3& _p0, thread const float3& _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return float3(_f21(param, param_1), _f21(param_2, param_3), _f21(param_4, param_5)); +} + +static inline __attribute__((always_inline)) +float _f23(thread const float& _p0, thread const float& _p1) +{ + return fast::max(0.0, (_p1 + _p0) - 1.0); +} + +static inline __attribute__((always_inline)) +float3 _f24(thread const float3& _p0, thread const float3& _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return float3(_f23(param, param_1), _f23(param_2, param_3), _f23(param_4, param_5)); +} + +static inline __attribute__((always_inline)) +float _f25(thread const float& _p0, thread const float& _p1) +{ + if (_p1 <= 0.0) + { + return 0.0; + } + if (_p0 >= 1.0) + { + return 1.0; + } + else + { + return fast::min(1.0, _p1 / (1.0 - _p0)); + } +} + +static inline __attribute__((always_inline)) +float3 _f26(thread const float3& _p0, thread const float3& _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return float3(_f25(param, param_1), _f25(param_2, param_3), _f25(param_4, param_5)); +} + +static inline __attribute__((always_inline)) +float _f27(thread const float& _p0, thread const float& _p1) +{ + return fast::min(1.0, _p1 + _p0); +} + +static inline __attribute__((always_inline)) +float3 _f28(thread const float3& _p0, thread const float3& _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return float3(_f27(param, param_1), _f27(param_2, param_3), _f27(param_4, param_5)); +} + +static inline __attribute__((always_inline)) +float _f29(thread const float& _p0, thread const float& _p1) +{ + float _1194; + if (_p0 <= 0.5) + { + float param = _p1; + float param_1 = 2.0 * _p0; + _1194 = _f21(param, param_1); + } + else + { + float param_2 = _p1; + float param_3 = 2.0 * (_p0 - 0.5); + _1194 = _f25(param_2, param_3); + } + return _1194; +} + +static inline __attribute__((always_inline)) +float3 _f30(thread const float3& _p0, thread const float3& _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return float3(_f29(param, param_1), _f29(param_2, param_3), _f29(param_4, param_5)); +} + +static inline __attribute__((always_inline)) +float _f31(thread const float& _p0, thread const float& _p1) +{ + float _1240; + if (_p0 <= 0.5) + { + float param = _p1; + float param_1 = 2.0 * _p0; + _1240 = _f23(param, param_1); + } + else + { + float param_2 = _p1; + float param_3 = 2.0 * (_p0 - 0.5); + _1240 = _f27(param_2, param_3); + } + return _1240; +} + +static inline __attribute__((always_inline)) +float3 _f32(thread const float3& _p0, thread const float3& _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return float3(_f31(param, param_1), _f31(param_2, param_3), _f31(param_4, param_5)); +} + +static inline __attribute__((always_inline)) +float _f33(thread const float& _p0, thread const float& _p1) +{ + float _1286; + if (_p0 <= 0.5) + { + _1286 = fast::min(_p1, 2.0 * _p0); + } + else + { + _1286 = fast::max(_p1, 2.0 * (_p0 - 0.5)); + } + return _1286; +} + +static inline __attribute__((always_inline)) +float3 _f34(thread const float3& _p0, thread const float3& _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return float3(_f33(param, param_1), _f33(param_2, param_3), _f33(param_4, param_5)); +} + +static inline __attribute__((always_inline)) +float _f35(thread const float& _p0, thread const float& _p1) +{ + return float((_p1 + _p0) >= 1.0); +} + +static inline __attribute__((always_inline)) +float3 _f36(thread const float3& _p0, thread const float3& _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return float3(_f35(param, param_1), _f35(param_2, param_3), _f35(param_4, param_5)); +} + +static inline __attribute__((always_inline)) +float _f37(thread const float& _p0, thread const float& _p1) +{ + float _1359; + if (_p0 > 0.0) + { + _1359 = fast::min(1.0, _p1 / _p0); + } + else + { + _1359 = 1.0; + } + return _1359; +} + +static inline __attribute__((always_inline)) +float3 _f38(thread const float3& _p0, thread const float3& _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return float3(_f37(param, param_1), _f37(param_2, param_3), _f37(param_4, param_5)); +} + +static inline __attribute__((always_inline)) +float3 _f20(thread const float3& _p0, thread const float3& _p1) +{ + float3 param = _p0; + float3 param_1 = _p1; + float param_2 = _f5(param); + float3 _1042 = _f6(param_1, param_2); + return _1042; +} + +static inline __attribute__((always_inline)) +float3 _f19(thread const float3& _p0, thread const float3& _p1) +{ + float3 param = _p1; + float3 param_1 = _p0; + return select(_p0, _p1, bool3(_f5(param) > _f5(param_1))); +} + +static inline __attribute__((always_inline)) +float3 _f18(thread const float3& _p0, thread const float3& _p1) +{ + float3 param = _p1; + float3 param_1 = _p0; + return select(_p0, _p1, bool3(_f5(param) <= _f5(param_1))); +} + +static inline __attribute__((always_inline)) +float _f0(thread const float2& _p0) +{ + return fract(sin(dot(_p0, float2(12.98980045318603515625, 78.233001708984375))) * 43758.546875); +} + +static inline __attribute__((always_inline)) +float4 _f39(thread float4& _p0, thread float4& _p1, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode, constant int& u_blendMode, constant int& u_layerType, constant int& u_hasMatte, constant float& u_layerOpacity) +{ + float _1395 = _p0.w; + float4 _1398 = _p0; + float3 _1401 = _1398.xyz / float3(fast::max(_1395, 9.9999997473787516355514526367188e-06)); + _p0.x = _1401.x; + _p0.y = _1401.y; + _p0.z = _1401.z; + float _1409 = _p1.w; + float4 _1411 = _p1; + float3 _1414 = _1411.xyz / float3(fast::max(_1409, 9.9999997473787516355514526367188e-06)); + _p1.x = _1414.x; + _p1.y = _1414.y; + _p1.z = _1414.z; + float4 _t36 = _p1; + if (u_blendMode == 1) + { + float3 _1432 = _p0.xyz + _p1.xyz; + _t36.x = _1432.x; + _t36.y = _1432.y; + _t36.z = _1432.z; + } + else + { + if (u_blendMode == 2) + { + float3 _1448 = _p0.xyz * _p1.xyz; + _t36.x = _1448.x; + _t36.y = _1448.y; + _t36.z = _1448.z; + } + else + { + if (u_blendMode == 3) + { + float3 _1465 = abs(_p0.xyz - _p1.xyz); + _t36.x = _1465.x; + _t36.y = _1465.y; + _t36.z = _1465.z; + } + else + { + if (u_blendMode == 4) + { + float _1481; + if (_p1.x < 0.5) + { + _1481 = (2.0 * _p1.x) * _p0.x; + } + else + { + _1481 = 1.0 - ((2.0 * (1.0 - _p1.x)) * (1.0 - _p0.x)); + } + float _1504; + if (_p1.y < 0.5) + { + _1504 = (2.0 * _p1.y) * _p0.y; + } + else + { + _1504 = 1.0 - ((2.0 * (1.0 - _p1.y)) * (1.0 - _p0.y)); + } + float _1527; + if (_p1.z < 0.5) + { + _1527 = (2.0 * _p1.z) * _p0.z; + } + else + { + _1527 = 1.0 - ((2.0 * (1.0 - _p1.z)) * (1.0 - _p0.z)); + } + float3 _1547 = float3(_1481, _1504, _1527); + _t36.x = _1547.x; + _t36.y = _1547.y; + _t36.z = _1547.z; + } + else + { + if (u_blendMode == 5) + { + float3 _1564 = fast::min(_p0.xyz, _p1.xyz); + _t36.x = _1564.x; + _t36.y = _1564.y; + _t36.z = _1564.z; + } + else + { + if (u_blendMode == 6) + { + float3 _1581 = fast::max(_p0.xyz, _p1.xyz); + _t36.x = _1581.x; + _t36.y = _1581.y; + _t36.z = _1581.z; + } + else + { + if (u_blendMode == 7) + { + float3 param = _p0.xyz; + float3 param_1 = _p1.xyz; + float3 _1600 = _f2(param, param_1); + _t36.x = _1600.x; + _t36.y = _1600.y; + _t36.z = _1600.z; + } + else + { + if (u_blendMode == 8) + { + float3 param_2 = _p0.xyz; + float3 param_3 = _p1.xyz; + float3 _1619 = _f4(param_2, param_3); + _t36.x = _1619.x; + _t36.y = _1619.y; + _t36.z = _1619.z; + } + else + { + if (u_blendMode == 9) + { + float3 param_4 = _p0.xyz; + float3 param_5 = _p1.xyz; + float3 _1638 = _f15(param_4, param_5); + _t36.x = _1638.x; + _t36.y = _1638.y; + _t36.z = _1638.z; + } + else + { + if (u_blendMode == 10) + { + float3 param_6 = _p0.xyz; + float3 param_7 = _p1.xyz; + float3 _1657 = _f16(param_6, param_7); + _t36.x = _1657.x; + _t36.y = _1657.y; + _t36.z = _1657.z; + } + else + { + if (u_blendMode == 11) + { + float3 param_8 = _p0.xyz; + float3 param_9 = _p1.xyz; + float3 _1676 = _f17(param_8, param_9); + _t36.x = _1676.x; + _t36.y = _1676.y; + _t36.z = _1676.z; + } + else + { + if (u_blendMode == 12) + { + float3 _1699 = (_p0.xyz + _p1.xyz) - (_p0.xyz * _p1.xyz); + _t36.x = _1699.x; + _t36.y = _1699.y; + _t36.z = _1699.z; + } + else + { + if (u_blendMode == 13) + { + float3 param_10 = _p0.xyz; + float3 param_11 = _p1.xyz; + float3 _1718 = _f22(param_10, param_11); + _t36.x = _1718.x; + _t36.y = _1718.y; + _t36.z = _1718.z; + } + else + { + if (u_blendMode == 14) + { + float3 param_12 = _p0.xyz; + float3 param_13 = _p1.xyz; + float3 _1737 = _f24(param_12, param_13); + _t36.x = _1737.x; + _t36.y = _1737.y; + _t36.z = _1737.z; + } + else + { + if (u_blendMode == 15) + { + float3 param_14 = _p0.xyz; + float3 param_15 = _p1.xyz; + float3 _1756 = _f26(param_14, param_15); + _t36.x = _1756.x; + _t36.y = _1756.y; + _t36.z = _1756.z; + } + else + { + if (u_blendMode == 16) + { + float3 param_16 = _p0.xyz; + float3 param_17 = _p1.xyz; + float3 _1775 = _f28(param_16, param_17); + _t36.x = _1775.x; + _t36.y = _1775.y; + _t36.z = _1775.z; + } + else + { + if (u_blendMode == 17) + { + float3 param_18 = _p0.xyz; + float3 param_19 = _p1.xyz; + float3 _1794 = _f30(param_18, param_19); + _t36.x = _1794.x; + _t36.y = _1794.y; + _t36.z = _1794.z; + } + else + { + if (u_blendMode == 18) + { + float3 param_20 = _p0.xyz; + float3 param_21 = _p1.xyz; + float3 _1813 = _f32(param_20, param_21); + _t36.x = _1813.x; + _t36.y = _1813.y; + _t36.z = _1813.z; + } + else + { + if (u_blendMode == 19) + { + float3 param_22 = _p0.xyz; + float3 param_23 = _p1.xyz; + float3 _1832 = _f34(param_22, param_23); + _t36.x = _1832.x; + _t36.y = _1832.y; + _t36.z = _1832.z; + } + else + { + if (u_blendMode == 20) + { + float3 param_24 = _p0.xyz; + float3 param_25 = _p1.xyz; + float3 _1851 = _f36(param_24, param_25); + _t36.x = _1851.x; + _t36.y = _1851.y; + _t36.z = _1851.z; + } + else + { + if (u_blendMode == 21) + { + float3 _1875 = (_p1.xyz + _p0.xyz) - ((_p1.xyz * 2.0) * _p0.xyz); + _t36.x = _1875.x; + _t36.y = _1875.y; + _t36.z = _1875.z; + } + else + { + if (u_blendMode == 22) + { + float3 _1893 = fast::max(float3(0.0), _p1.xyz - _p0.xyz); + _t36.x = _1893.x; + _t36.y = _1893.y; + _t36.z = _1893.z; + } + else + { + if (u_blendMode == 23) + { + float3 param_26 = _p0.xyz; + float3 param_27 = _p1.xyz; + float3 _1912 = _f38(param_26, param_27); + _t36.x = _1912.x; + _t36.y = _1912.y; + _t36.z = _1912.z; + } + else + { + if (u_blendMode == 24) + { + float3 param_28 = _p0.xyz; + float3 param_29 = _p1.xyz; + float3 _1931 = _f20(param_28, param_29); + _t36.x = _1931.x; + _t36.y = _1931.y; + _t36.z = _1931.z; + } + else + { + if (u_blendMode == 25) + { + float3 param_30 = _p0.xyz; + float3 param_31 = _p1.xyz; + float3 _1950 = _f19(param_30, param_31); + _t36.x = _1950.x; + _t36.y = _1950.y; + _t36.z = _1950.z; + } + else + { + if (u_blendMode == 26) + { + float3 param_32 = _p0.xyz; + float3 param_33 = _p1.xyz; + float3 _1969 = _f18(param_32, param_33); + _t36.x = _1969.x; + _t36.y = _1969.y; + _t36.z = _1969.z; + } + else + { + if (u_blendMode == 27) + { + bool _1984 = _p0.w == 1.0; + bool _2000; + if (!_1984) + { + bool _1990 = _p0.w > 0.0; + bool _1999; + if (_1990) + { + float2 param_34 = uv0; + _1999 = _p0.w > _f0(param_34); + } + else + { + _1999 = _1990; + } + _2000 = _1999; + } + else + { + _2000 = _1984; + } + if (_2000) + { + _t36.x = _p0.xyz.x; + _t36.y = _p0.xyz.y; + _t36.z = _p0.xyz.z; + } + } + else + { + _t36.x = _p0.xyz.x; + _t36.y = _p0.xyz.y; + _t36.z = _p0.xyz.z; + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + float4 _t37 = float4(0.0); + if (u_layerType == 1) + { + float _t38 = 1.0; + if (u_hasMatte == 1) + { + float4 param_35 = float4(1.0); + _t38 = _f11(param_35, u_enableMatte, u_maskTexture, u_maskTextureSmplr, uv0, u_matteMode).w; + } + float4 _2051 = mix(_p1, float4(_t36.xyz, _p0.w), float4(u_layerOpacity * _t38)); + _t37 = _2051; + float _2053 = _t37.w; + float3 _2056 = _2051.xyz * _2053; + _t37.x = _2056.x; + _t37.y = _2056.y; + _t37.z = _2056.z; + } + else + { + float3 _2091 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t36.xyz * (_p0.w * _p1.w)); + _t37.x = _2091.x; + _t37.y = _2091.y; + _t37.z = _2091.z; + _t37.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t37; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_maskTexture [[texture(0)]], texture2d u_baseTexure [[texture(1)]], texture2d u_sourceTexture [[texture(2)]], sampler u_maskTextureSmplr [[sampler(0)]], sampler u_baseTexureSmplr [[sampler(1)]], sampler u_sourceTextureSmplr [[sampler(2)]]) +{ + main0_out out = {}; + float4 _t39 = float4(0.0); + bool _2114 = buffer.u_hasBlend == 1; + if (_2114) + { + if (buffer.u_hasBaseTexture == 1) + { + _t39 = u_baseTexure.sample(u_baseTexureSmplr, in.uv0); + } + if (buffer.u_hasSourceTexture == 0) + { + out.o_fragColor = _t39; + return out; + } + } + float4 _t40 = float4(0.0); + if (buffer.u_hasTrs == 1) + { + float4x4 param = buffer.u_mvMat; + float4x4 param_1 = buffer.u_pMat; + float2 param_2 = in.uv0; + float2 _2152 = _f8(param, param_1, param_2); + float _2155 = step(buffer.u_mirrorEdge, 0.5); + float2 param_3 = _2152; + float2 _2165 = (_2152 * _2155) + (_f10(param_3) * (1.0 - _2155)); + float2 param_4 = _2165; + _t40 = (u_sourceTexture.sample(u_sourceTextureSmplr, _2165) * buffer.u_alpha) * _f9(param_4); + } + else + { + if (buffer.u_hasSourceTexture == 1) + { + _t40 = u_sourceTexture.sample(u_sourceTextureSmplr, in.uv0); + } + } + if ((buffer.u_layerType != 1) && (buffer.u_hasMatte == 1)) + { + float4 param_5 = _t40; + _t40 = _f11(param_5, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode); + } + if (_2114) + { + float4 param_6 = _t40; + float4 param_7 = _t39; + float4 _2203 = _f39(param_6, param_7, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode, buffer.u_blendMode, buffer.u_layerType, buffer.u_hasMatte, buffer.u_layerOpacity); + _t40 = _2203; + } + out.o_fragColor = _t40; + return out; +} + diff --git a/scripts/7681599071768956161/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681599071768956161/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681599071768956161/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681599071768956161/AmazingFeature/lua/LumiFamily/AETools.lua b/scripts/7681599071768956161/AmazingFeature/lua/LumiFamily/AETools.lua new file mode 100644 index 0000000000000000000000000000000000000000..07ad317cd97ebb4ef6a4b329cdda5e775c5c2b2c --- /dev/null +++ b/scripts/7681599071768956161/AmazingFeature/lua/LumiFamily/AETools.lua @@ -0,0 +1,273 @@ +local AETools = AETools or {} +AETools.__index = AETools + +-- AE PropertyValueType +local ThreeD_SPATIAL = 6413 +local ThreeD = 6414 +local TwoD_SPATIAL = 6415 +local TwoD = 6416 +local OneD = 6417 + +local function deepcopy(orig) + local copy + if type(orig) == "table" then + copy = {} + for orig_key, orig_value in next, orig, nil do + copy[deepcopy(orig_key)] = deepcopy(orig_value) + end + -- setmetatable(copy, deepcopy(getmetatable(orig))) + else + copy = orig + end + return copy +end + +function AETools.new(attrs) + if attrs == nil then return nil end + + local self = setmetatable({}, AETools) + self.attrs = attrs + + local max_frame = 0 + local min_frame = 100000 + for _,v in pairs(attrs) do + for i = 1, #v do + local content = v[i] + local cur_frame_min = content[2][1] + local cur_frame_max = content[2][2] + max_frame = math.max(cur_frame_max, max_frame) + min_frame = math.min(cur_frame_min, min_frame) + + if content[4] ~= nil + and content[5] ~= nil + and (content[4][1] == ThreeD_SPATIAL or content[4][1] == TwoD_SPATIAL) + and content[5][1] == 0 + then + local p0 = content[3][1] + local totalLen = 0 + local lenInfo = {} + lenInfo[0] = 0 + for test=1,200,1 do + local coord = self._cubicBezier3D(content[3][1], content[3][3], content[3][4], content[3][2], test/200) + local length = 0 + if #p0 >= 3 then + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])+(coord[3]-p0[3])*(coord[3]-p0[3])) + else + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])) + end + p0 = coord + totalLen = totalLen + length + lenInfo[test] = totalLen + -- print(test/200 .. " coord: "..coord[1].." - "..coord[2]) + end + for test=1,200,1 do + lenInfo[test] = lenInfo[test]/(lenInfo[200]+0.000001) + -- print(test/200 .. " "..lenInfo[test]) + end + content['lenInfo'] = lenInfo + end + end + end + + self.all_frame = max_frame - min_frame + self.min_frame = min_frame + + return self +end + +function AETools:CurFrame(_p) + local frame = math.floor(_p*self.all_frame) + return frame + self.min_frame +end + +function AETools:AllFrame(_p) + return self.all_frame +end + +function AETools._remap01(a,b,x) + if x < a then return 0 end + if x > b then return 1 end + return (x-a)/(b-a) +end + +function AETools._cubicBezier(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + return { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + } +end + +function AETools._cubicBezier3D(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + local value = { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + 0, + } + if #p1 >= 3 then + value[3] = p1[3] * _t3 + 3 * p2[3] * _t2 * t + 3 * p3[3] * _t * t2 + p4[3] * t3 + end + return value +end + +function AETools:_cubicBezierSpatial(lenInfo, p1, p2, p3, p4, t) + local p = 0 + if t <= 0 then + p = 0 + elseif t >= 1 then + p = 1 + else + local ts = 199 + local te = 200 + for i=1,200,1 do + if lenInfo[i] >= t then + te = i + ts = i-1 + break + end + end + p = ts/200. + 0.005*(t-lenInfo[ts])/(lenInfo[te]-lenInfo[ts]+0.000001) + end + return self._cubicBezier3D(p1, p2, p3, p4, p) +end + +function AETools:_cubicBezier01(_bezier_val, p, y_len) + local x = self:_getBezier01X(_bezier_val, p, y_len) + return self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + x + )[2] +end + +function AETools:AllFrame() + return self.all_frame +end + +function AETools:_getBezier01X(_bezier_val, x, y_len) + local ts = 0 + local te = 1 + -- divide and conque + local times = 1 + repeat + local tm = (ts+te)*0.5 + local value = self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + tm) + if(value[1]>x) then + te = tm + else + ts = tm + end + times = times +1 + until(te-ts < 0.001 and times < 50) + + return (te+ts)*0.5 +end + +function AETools._mix(a, b, x, type) + if type == 1 then + return a * (1-x) + b * x + end + return a + x +end + +function AETools:GetVal(_name, _progress) + local content = self.attrs[_name] + if content == nil then + return nil + end + + -- local cur_frame = _progress * self.all_frame + self.min_frame + local cur_frame = _progress + + for i = 1, #content do + local info = content[i] + local start_frame = info[2][1] + local end_frame = info[2][2] + if cur_frame >= start_frame and cur_frame < end_frame then + local cur_progress = self._remap01(start_frame, end_frame, cur_frame) + local bezier = info[1] + local value_range = info[3] + local y_len = 1 + if (value_range[2][1] == value_range[1][1] and info[5] and info[5][1]==0 and #(value_range[1])==1) then + y_len = 0 + end + + if info[5] and info[5][1] == 2 then + return deepcopy(info[3][1]) + end + + if #bezier > 4 then + -- currently scale attrs contains more than 4 bezier values + local res = {} + for k = 1, 3 do + local cur_bezier = {bezier[k], bezier[k+3], bezier[k+3*2], bezier[k+3*3]} + local p = self:_cubicBezier01(cur_bezier, cur_progress, y_len) + res[k] = self._mix(value_range[1][k], value_range[2][k], p, y_len) + end + return res + + else + local p = self:_cubicBezier01(bezier, cur_progress, y_len) + if info[4] ~= nil + and info[5] ~= nil + and (info[4][1] == ThreeD_SPATIAL or info[4][1] == TwoD_SPATIAL) + and info[5][1] == 0 + then + local coord = self:_cubicBezierSpatial( + info['lenInfo'], + value_range[1], + value_range[3], + value_range[4], + value_range[2], + p + ) + if info[4][1] == TwoD_SPATIAL then + return {coord[1], coord[2]} + end + return coord + end + + if type(value_range[1]) == "table" then + local res = {} + for j = 1, #value_range[1] do + res[j] = self._mix(value_range[1][j], value_range[2][j], p, y_len) + end + return res + end + return self._mix(value_range[1], value_range[2], p, y_len) + end + end + end + + local first_info = content[1] + local start_frame = first_info[2][1] + if cur_frame=end_frame then + return deepcopy(last_info[3][2]) + end + + return nil +end + +return AETools diff --git a/scripts/7681599071768956161/AmazingFeature/lua/LumiFamily/LumiEffect.lua b/scripts/7681599071768956161/AmazingFeature/lua/LumiFamily/LumiEffect.lua new file mode 100644 index 0000000000000000000000000000000000000000..bee4c14190a8231d06c80826ceaa131067ca8ad2 --- /dev/null +++ b/scripts/7681599071768956161/AmazingFeature/lua/LumiFamily/LumiEffect.lua @@ -0,0 +1,32 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiEffect = LumiEffect or {} +LumiEffect.__index = LumiEffect +---@class LumiEffect : ScriptComponent + +function LumiEffect.new(construct, ...) + local self = setmetatable({}, LumiEffect) + + self.__lumi_type = "lumi_effect" + self.__lumi_rt_pingpong_type = "custom" + + return self +end + +function LumiEffect:constructor() +end + +function LumiEffect:onStart(comp) +end + +function LumiEffect:onDestroy(comp) +end + +function LumiEffect:updateMaterials(comp, deltaTime) +end + +function LumiEffect:onUpdate(comp, deltaTime) +end + +exports.LumiEffect = LumiEffect +return exports diff --git a/scripts/7681599071768956161/AmazingFeature/lua/LumiFamily/LumiExportData.lua b/scripts/7681599071768956161/AmazingFeature/lua/LumiFamily/LumiExportData.lua new file mode 100644 index 0000000000000000000000000000000000000000..2b063db74c146138aac937468aca542fc12e05f5 --- /dev/null +++ b/scripts/7681599071768956161/AmazingFeature/lua/LumiFamily/LumiExportData.lua @@ -0,0 +1,415 @@ +local data = {} + +local ae_compDurations = {0, 2} +data.ae_compDurations = ae_compDurations + +local ae_effectType = 'transition' +data.ae_effectType = ae_effectType + +local ae_transitionInputIndex = { + {'LumiLayer_45-matte-blend', 'InputTex', 1}, + {'LumiLayer_45-matte-blend', 'baseTex', 0}, +} +data.ae_transitionInputIndex = ae_transitionInputIndex + +local ae_durations = { + ['LumiAnimSeqLoadAndCrop_759-effect0'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['seqTex_1_1'] = {{0.06666666666667, 2}, }, + }, + }, + ['LumiExtract_910-effect0'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + }, + }, + ['LumiLayer_45-matte-blend'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{1, 2}, }, + ['baseTex'] = {{0, 2}, }, + ['maskTex'] = {{0, 2}, }, + }, + }, + ['LumiAnimSeqLoadAndCrop_914-effect0'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['seqTex_1_1'] = {{0, 2}, }, + }, + }, + ['LumiExtract_925-effect0'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + }, + }, + ['LumiLayer_925-blend'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['baseTex'] = {{0, 2}, }, + }, + }, +} +data.ae_durations = ae_durations + +local ae_attribute = { + ['LumiAnimSeqLoadAndCrop_759-effect0'] = { + ['specify_1_1'] = true, + ['animSeqType_1_1'] = 0, + ['cropType_1_1'] = 1, + ['edgeType_1_1'] = 0, + ['enableVideoAlphaBlend_1_1'] = false, + ['pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1_1'] = 0, + ['scale_1_1'] = 1, + ['opacity_1_1'] = 1, + ['speed_1_1'] = 1, + ['playMode_1_1'] = 0, + ['specify_9_16'] = false, + ['animSeqType_9_16'] = 2, + ['cropType_9_16'] = 1, + ['edgeType_9_16'] = 0, + ['enableVideoAlphaBlend_9_16'] = false, + ['pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_9_16'] = 0, + ['scale_9_16'] = 1, + ['opacity_9_16'] = 1, + ['speed_9_16'] = 1, + ['playMode_9_16'] = 0, + ['specify_16_9'] = false, + ['animSeqType_16_9'] = 2, + ['cropType_16_9'] = 1, + ['edgeType_16_9'] = 0, + ['enableVideoAlphaBlend_16_9'] = false, + ['pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_16_9'] = 0, + ['scale_16_9'] = 1, + ['opacity_16_9'] = 1, + ['speed_16_9'] = 1, + ['playMode_16_9'] = 0, + ['specify_5.8'] = false, + ['animSeqType_5.8'] = 2, + ['cropType_5.8'] = 1, + ['edgeType_5.8'] = 0, + ['enableVideoAlphaBlend_5.8'] = false, + ['pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_5.8'] = 0, + ['scale_5.8'] = 1, + ['opacity_5.8'] = 1, + ['speed_5.8'] = 1, + ['playMode_5.8'] = 0, + ['specify_2_1'] = false, + ['animSeqType_2_1'] = 2, + ['cropType_2_1'] = 1, + ['edgeType_2_1'] = 0, + ['enableVideoAlphaBlend_2_1'] = false, + ['pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2_1'] = 0, + ['scale_2_1'] = 1, + ['opacity_2_1'] = 1, + ['speed_2_1'] = 1, + ['playMode_2_1'] = 0, + ['specify_3_4'] = false, + ['animSeqType_3_4'] = 2, + ['cropType_3_4'] = 1, + ['edgeType_3_4'] = 0, + ['enableVideoAlphaBlend_3_4'] = false, + ['pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_3_4'] = 0, + ['scale_3_4'] = 1, + ['opacity_3_4'] = 1, + ['speed_3_4'] = 1, + ['playMode_3_4'] = 0, + ['specify_4_3'] = false, + ['animSeqType_4_3'] = 2, + ['cropType_4_3'] = 1, + ['edgeType_4_3'] = 0, + ['enableVideoAlphaBlend_4_3'] = false, + ['pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_4_3'] = 0, + ['scale_4_3'] = 1, + ['opacity_4_3'] = 1, + ['speed_4_3'] = 1, + ['playMode_4_3'] = 0, + ['specify_1.85_1'] = false, + ['animSeqType_1.85_1'] = 2, + ['cropType_1.85_1'] = 1, + ['edgeType_1.85_1'] = 0, + ['enableVideoAlphaBlend_1.85_1'] = false, + ['pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1.85_1'] = 0, + ['scale_1.85_1'] = 1, + ['opacity_1.85_1'] = 1, + ['speed_1.85_1'] = 1, + ['playMode_1.85_1'] = 0, + ['specify_2.35_1'] = false, + ['animSeqType_2.35_1'] = 2, + ['cropType_2.35_1'] = 1, + ['edgeType_2.35_1'] = 0, + ['enableVideoAlphaBlend_2.35_1'] = false, + ['pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2.35_1'] = 0, + ['scale_2.35_1'] = 1, + ['opacity_2.35_1'] = 1, + ['speed_2.35_1'] = 1, + ['playMode_2.35_1'] = 0, + ['globalRotation'] = 0, + ['globalScale'] = 1, + ['globalOpacity'] = 1, + ['globalSpeed'] = 1, + ['lite_mode'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiExtract_910-effect0'] = { + ['blackField'] = 30, + ['blackSoft'] = 0, + ['whiteField'] = 255, + ['whiteSoft'] = 0, + ['reverse'] = false, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiLayer_45-matte-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = true, + ['hasTransform'] = false, + ['layerType'] = 'Precomp', + ['matteMode'] = 2, + ['blendMode'] = 0, + }, + ['LumiAnimSeqLoadAndCrop_914-effect0'] = { + ['specify_1_1'] = true, + ['animSeqType_1_1'] = 0, + ['cropType_1_1'] = 1, + ['edgeType_1_1'] = 0, + ['enableVideoAlphaBlend_1_1'] = false, + ['pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1_1'] = 0, + ['scale_1_1'] = 1, + ['opacity_1_1'] = 1, + ['speed_1_1'] = 1, + ['playMode_1_1'] = 0, + ['specify_9_16'] = false, + ['animSeqType_9_16'] = 2, + ['cropType_9_16'] = 1, + ['edgeType_9_16'] = 0, + ['enableVideoAlphaBlend_9_16'] = false, + ['pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_9_16'] = 0, + ['scale_9_16'] = 1, + ['opacity_9_16'] = 1, + ['speed_9_16'] = 1, + ['playMode_9_16'] = 0, + ['specify_16_9'] = false, + ['animSeqType_16_9'] = 2, + ['cropType_16_9'] = 1, + ['edgeType_16_9'] = 0, + ['enableVideoAlphaBlend_16_9'] = false, + ['pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_16_9'] = 0, + ['scale_16_9'] = 1, + ['opacity_16_9'] = 1, + ['speed_16_9'] = 1, + ['playMode_16_9'] = 0, + ['specify_5.8'] = false, + ['animSeqType_5.8'] = 2, + ['cropType_5.8'] = 1, + ['edgeType_5.8'] = 0, + ['enableVideoAlphaBlend_5.8'] = false, + ['pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_5.8'] = 0, + ['scale_5.8'] = 1, + ['opacity_5.8'] = 1, + ['speed_5.8'] = 1, + ['playMode_5.8'] = 0, + ['specify_2_1'] = false, + ['animSeqType_2_1'] = 2, + ['cropType_2_1'] = 1, + ['edgeType_2_1'] = 0, + ['enableVideoAlphaBlend_2_1'] = false, + ['pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2_1'] = 0, + ['scale_2_1'] = 1, + ['opacity_2_1'] = 1, + ['speed_2_1'] = 1, + ['playMode_2_1'] = 0, + ['specify_3_4'] = false, + ['animSeqType_3_4'] = 2, + ['cropType_3_4'] = 1, + ['edgeType_3_4'] = 0, + ['enableVideoAlphaBlend_3_4'] = false, + ['pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_3_4'] = 0, + ['scale_3_4'] = 1, + ['opacity_3_4'] = 1, + ['speed_3_4'] = 1, + ['playMode_3_4'] = 0, + ['specify_4_3'] = false, + ['animSeqType_4_3'] = 2, + ['cropType_4_3'] = 1, + ['edgeType_4_3'] = 0, + ['enableVideoAlphaBlend_4_3'] = false, + ['pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_4_3'] = 0, + ['scale_4_3'] = 1, + ['opacity_4_3'] = 1, + ['speed_4_3'] = 1, + ['playMode_4_3'] = 0, + ['specify_1.85_1'] = false, + ['animSeqType_1.85_1'] = 2, + ['cropType_1.85_1'] = 1, + ['edgeType_1.85_1'] = 0, + ['enableVideoAlphaBlend_1.85_1'] = false, + ['pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1.85_1'] = 0, + ['scale_1.85_1'] = 1, + ['opacity_1.85_1'] = 1, + ['speed_1.85_1'] = 1, + ['playMode_1.85_1'] = 0, + ['specify_2.35_1'] = false, + ['animSeqType_2.35_1'] = 2, + ['cropType_2.35_1'] = 1, + ['edgeType_2.35_1'] = 0, + ['enableVideoAlphaBlend_2.35_1'] = false, + ['pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2.35_1'] = 0, + ['scale_2.35_1'] = 1, + ['opacity_2.35_1'] = 1, + ['speed_2.35_1'] = 1, + ['playMode_2.35_1'] = 0, + ['globalRotation'] = 0, + ['globalScale'] = 1, + ['globalOpacity'] = 1, + ['globalSpeed'] = 1, + ['lite_mode'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiExtract_925-effect0'] = { + ['blackField'] = 30, + ['blackSoft'] = 0, + ['whiteField'] = 255, + ['whiteSoft'] = 0, + ['reverse'] = false, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiLayer_925-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = false, + ['layerType'] = 'Precomp', + ['blendMode'] = 0, + }, +} +data.ae_attribute = ae_attribute + +local ae_keyframes = { + ['LumiAnimSeqLoadAndCrop_759-effect0#seqTime#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 2, }, + {{0, }, {2, }, }, + {6417, }, + {1, }, + }, +}, + ['LumiAnimSeqLoadAndCrop_914-effect0#seqTime#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 2, }, + {{0, }, {2, }, }, + {6417, }, + {1, }, + }, +}, +} +data.ae_keyframes = ae_keyframes + +local ae_reverseKeyframes = false +data.ae_reverseKeyframes = ae_reverseKeyframes + +local ae_sliderInfos = { +} +data.ae_sliderInfos = ae_sliderInfos + +local ae_fadeinInfos = { + time = 0, + infos = { + } +} +data.ae_fadeinInfos = ae_fadeinInfos + +local ae_fadeoutInfos = { + time = 0, + infos = { + } +} +data.ae_fadeoutInfos = ae_fadeoutInfos + +local ae_animationInfos = { + animationMode = 0, + loopStart = 0, + speedInfo = {1, 0, 1, }, +} +data.ae_animationInfos = ae_animationInfos + +return data diff --git a/scripts/7681599071768956161/AmazingFeature/lua/LumiFamily/LumiManager.lua b/scripts/7681599071768956161/AmazingFeature/lua/LumiFamily/LumiManager.lua new file mode 100644 index 0000000000000000000000000000000000000000..7a07ee24e9b82500e89114ce8cb3a85474915e38 --- /dev/null +++ b/scripts/7681599071768956161/AmazingFeature/lua/LumiFamily/LumiManager.lua @@ -0,0 +1,554 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiManager = LumiManager or {} +LumiManager.__index = LumiManager +---@class LumiManager : ScriptComponent +---@field debugTime number [UI(Range={0, 6}, Drag)] +---@field autoPlay boolean +---@field lumiEffectRoot Transform +---@field start_render_layer int +---@field start_render_order int + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local EffectType = { + Effect = 'effect', + Transition = 'transition', + VideoAnimation = 'videoAnimation', + EffectXT = 'xtEffect', + FilterXT = 'xtFilter', +} + +local AnimationMode = { + Once = 0, + Loop = 1, + StretchOnce = 2, + StretchLoop = 3, +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +local function remap(value, srcMin, srcMax, dstMin, dstMax) + return dstMin + (value - srcMin) * (dstMax - dstMin) / (srcMax - srcMin) +end + +local function handleAllEntityBySingleParent(_trans, func, ...) + if _trans.children:size() > 0 then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i - 1) + handleAllEntityBySingleParent(child, func, ...) + end + end + func(_trans, ...) +end + +local function intervalIntersection(intervals1, intervals2) + local result = {} + local i = 1 + local j = 1 + + while i <= #intervals1 and j <= #intervals2 do + local start1 = intervals1[i][1] + local end1 = intervals1[i][2] + local start2 = intervals2[j][1] + local end2 = intervals2[j][2] + + local start = math.max(start1, start2) + local end_ = math.min(end1, end2) + + if start <= end_ then + table.insert(result, {start, end_}) + end + if end1 < end2 then + i = i + 1 + else + j = j + 1 + end + end + return result +end + +function LumiManager.new(construct, ...) + local self = setmetatable({}, LumiManager) + + self.lumiEffectRoot = nil + self.start_render_layer = 1 + self.start_render_order = 1 + + self.InputTex = nil + self.OutputTex = nil + self.PingPongTex = nil + + self.startTime = 0.0 + self.endTime = 6.0 + self.curTime = 0.0 + + self.speed = 1.0 + self.animationMode = AnimationMode.Once + self.autoPlay = true + self.debugTime = 0.0 + + -- for XT + self.cameraStartTime = 0 + self.lastCycle = -1 + + return self +end + +function LumiManager:getKeyframeAeTime(aeTime) + if self.isReverseKeyframes ~= true then + return aeTime + end + return self.compDurations[1] + self.compDurations[2] - aeTime +end + +function LumiManager:onStart(comp) + self.entity = comp.entity + + self.lumi_obj_extension = includeRelativePath("LumiObjectExtension") + self.lumi_obj = nil + + self.keyframes = nil + self.durations = nil + self.params = nil + self.compDurations = {0, 6} + self.animationInfos = 0 + self.sliderInfos = {} + self.fadeinInfos = {} + self.fadeoutInfos = {} + self.effectType = "effect" + self.transitionInputIndex = {} + + self.LumiParamsSetter = includeRelativePath("LumiParamsSetter") + local ae_export_data = includeRelativePath("LumiExportData") + if ae_export_data then + if ae_export_data.ae_keyframes then + local ae_tools = includeRelativePath("AETools") + if ae_tools then + self.keyframes = ae_tools.new(ae_export_data.ae_keyframes) + end + end + if ae_export_data.ae_reverseKeyframes ~= nil then + self.isReverseKeyframes = ae_export_data.ae_reverseKeyframes + end + if ae_export_data.ae_durations ~= nil then + self.durations = ae_export_data.ae_durations + end + if ae_export_data.ae_attribute ~= nil then + self.params = ae_export_data.ae_attribute + end + if ae_export_data.ae_compDurations ~= nil then + self.compDurations = ae_export_data.ae_compDurations + self.compDurations[2] = self.compDurations[2] + end + if ae_export_data.ae_animationInfos ~= nil then + self.animationInfos = ae_export_data.ae_animationInfos + self.animationMode = self.animationInfos.animationMode + self.loopStart = self.animationInfos.loopStart + self.speed = self.animationInfos.speedInfo[1] + end + if ae_export_data.ae_sliderInfos ~= nil then + self.sliderInfos = ae_export_data.ae_sliderInfos + end + if ae_export_data.ae_fadeinInfos ~= nil then + self.fadeinInfos = ae_export_data.ae_fadeinInfos + end + if ae_export_data.ae_fadeoutInfos ~= nil then + self.fadeoutInfos = ae_export_data.ae_fadeoutInfos + end + if ae_export_data.ae_effectType ~= nil then + self.effectType = ae_export_data.ae_effectType + end + if ae_export_data.ae_cameraMode ~= nil then + self.cameraMode = ae_export_data.ae_cameraMode + end + if ae_export_data.ae_transitionInputIndex ~= nil then + self.transitionInputIndex = ae_export_data.ae_transitionInputIndex + end + end + if self.LumiParamsSetter then + self.lumi_params_setter = self.LumiParamsSetter.new( + self, + self.params, + self.keyframes, + self.effectType, + self.sliderInfos, + self.fadeinInfos, + self.fadeoutInfos + ) + end + + if self.effectType == EffectType.VideoAnimation then + local baseEntity = self.entity:searchEntity('base') + local videoCamera = baseEntity:searchEntity('videoCamera'):getComponent('Camera') + local videoRenderer = baseEntity:searchEntity('video'):getComponent('MeshRenderer') + local modelCamera = baseEntity:searchEntity('modelCamera'):getComponent('Camera') + local modelRenderer = baseEntity:searchEntity('model'):searchEntity('quad'):getComponent('MeshRenderer') + local fxaaCamera = baseEntity:searchEntity('fxaaCamera'):getComponent('Camera') + local fxaaRenderer = baseEntity:searchEntity('fxaa'):getComponent('MeshRenderer') + local bgCamera = baseEntity:searchEntity('bgCamera'):getComponent('Camera') + local bgRenderer = baseEntity:searchEntity('bg'):getComponent('MeshRenderer') + local blendCamera = baseEntity:searchEntity('blendCamera'):getComponent('Camera') + local blendRenderer = baseEntity:searchEntity('blend'):getComponent('MeshRenderer') + self.videoAnimationCameraAndRenderer = { + { camera = videoCamera, renderer = videoRenderer }, + { camera = modelCamera, renderer = modelRenderer }, + { camera = fxaaCamera, renderer = fxaaRenderer }, + { camera = bgCamera, renderer = bgRenderer }, + { camera = blendCamera, renderer = blendRenderer }, + } + end +end + +function LumiManager:onDestroy(comp) + if self.lumiEffectRoot and self.lumi_obj_extension then + self.lumi_obj_extension.deregister(self.lumiEffectRoot.entity) + end + self.lumi_obj = nil + self.LumiParamsSetter = nil +end + +function LumiManager:getCameraCount() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return 0 + end + + self.lumi_obj = nil + self:ReRender() + + local cam_count = 0 + if self.lumi_obj then + cam_count = self.lumi_obj:getCameraCount() + Amaz.LOGI(AE_EFFECT_TAG, self.lumi_obj.entity.name .. " camera_count: " .. tostring(cam_count)) + end + return cam_count +end + +function LumiManager:ReRender() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + -- re register + self.lumi_obj = nil + self:registerLumiObj(self.lumiEffectRoot, 1) + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'No lumi_obj register') + return + end + + -- change layer & order + self:updateCameraLayerAndOrder() + + -- change rt pingpong + self:updateRtPingpong() +end + +function LumiManager:registerLumiObj(_trans, _idx) + if _trans == nil then return end + local script_comp = _trans.entity:getComponent("ScriptComponent") + if script_comp then + local lua_obj = Amaz.ScriptUtils.getLuaObj(script_comp:getScript()) + if lua_obj then + self.lumi_obj_extension.deregister(_trans.entity) + self.lumi_obj = self.lumi_obj_extension.register(_trans.entity) + end + end +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str .. "0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiManager:updateCameraLayerAndOrder() + if self.lumi_obj then + local cur_start_layer, cur_start_order = self.lumi_obj:updateCameraLayerAndOrder(self.start_render_layer, self.start_render_order) + + if self.effectType == EffectType.VideoAnimation then + cur_start_layer = cur_start_layer + 10 + cur_start_order = cur_start_order + 10 + + for i = 1, #self.videoAnimationCameraAndRenderer do + local cameraAndRenderer = self.videoAnimationCameraAndRenderer[i] + local camera = cameraAndRenderer.camera + local renderer = cameraAndRenderer.renderer + camera.renderOrder = cur_start_order + _setLayer(camera, cur_start_layer) + renderer.entity.layer = cur_start_layer + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end +end + +function LumiManager:updateRtPingpong() + if self.lumi_obj then + self.lumi_obj:updateRt(self.InputTex, self.OutputTex, self.PingPongTex) + end +end + +function LumiManager:updateOutputRtSize() + if self.lumi_obj then + self.lumi_obj:updateOutputRtSize(self.width, self.height) + end +end + +function LumiManager:initVideoAnimationLua(comp) + local modelEntity = comp.entity:searchEntity("model") + if modelEntity then + local scriptComp = modelEntity:getComponent("ScriptComponent") + if scriptComp then + self.videoAnimationLua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + end + end +end + +function LumiManager:onUpdate(comp, deltaTime) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.durations and not self.isSetDuration then + for entityName, durationMap in pairs(self.durations) do + local isLumiLayer = string.sub(entityName, 1, string.len('LumiLayer')) == 'LumiLayer' + if isLumiLayer then + local texDuration = durationMap['texDuration'] + local srcDuration = texDuration['InputTex'] + local baseDuration = texDuration['baseTex'] + local maskDuration = texDuration['maskTex'] + if srcDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'srcDuration', srcDuration) + end + if baseDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'baseDuration', baseDuration) + end + if maskDuration then + local matteDuration = intervalIntersection(maskDuration, srcDuration) + self.lumi_obj:setSubEffectAttr(entityName, 'matteDuration', matteDuration) + end + end + end + self.isSetDuration = true + end + + local w = Amaz.BuiltinObject.getInputTextureWidth() + local h = Amaz.BuiltinObject.getInputTextureHeight() + if self.InputTex then + w = self.InputTex.width + h = self.InputTex.height + end + if self.OutputTex and (self.OutputTex.width ~= w or self.OutputTex.height ~= h) then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid rt size, input: ' .. w .. 'x' .. h .. ', output: ' .. self.OutputTex.width .. 'x' .. self.OutputTex.height) + end + if self.width == nil or self.width ~= w or self.height == nil or self.height ~= h then + self.width = w + self.height = h + self:updateOutputRtSize() + end + + self.curTime = self.curTime + deltaTime + if isEditor then + self.curTime = self.curTime % self.endTime + end + local curTime = (self.curTime - self.startTime) * self.speed + self.startTime + local startTime = self.startTime + local endTime = (self.endTime - self.startTime) * self.speed + self.startTime + + if self.cameraMode then + if self.animationMode ~= AnimationMode.Loop then + Amaz.LOGE(AE_EFFECT_TAG, 'Camera mode is not support animationMode: ' .. tostring(self.animationMode)) + return + end + curTime = self.curTime - self.cameraStartTime + endTime = math.huge + elseif self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT then -- deprecated after 1810 in XT + startTime = 0 + if self.isVideo == 1 then + endTime = self.videoTime + else + curTime = 0 + endTime = 3 + end + end + + local aeTime = curTime; + local aeDuration = math.max(0.001, self.compDurations[2] - self.compDurations[1]) + if endTime < curTime then + aeTime = math.max(self.compDurations[1], self.compDurations[2] - (self.endTime - self.curTime)) + else + local lvDuration = math.max(0.001, endTime - startTime) + if self.animationMode == AnimationMode.Once then + aeTime = self.compDurations[1] + curTime - startTime + aeTime = math.min(aeTime, self.compDurations[2]) + elseif self.animationMode == AnimationMode.Loop then + if self.cameraMode then + local cycle = math.floor((curTime - startTime) / aeDuration) + if self.lastCycle ~= cycle then + self.lastCycle = cycle + comp.entity.scene:sendMessage(4999, 1, 0, '') + end + end + if math.floor((curTime - startTime) / aeDuration) < 1 then + aeTime = self.compDurations[1] + (curTime - startTime) % aeDuration + else + local curLoopStart = (self.loopStart - self.compDurations[1]) * self.speed + self.compDurations[1] + aeTime = self.loopStart + (curTime - startTime - curLoopStart) % (aeDuration - self.loopStart) + end + elseif self.animationMode == AnimationMode.StretchOnce then + aeTime = remap(curTime, startTime, self.endTime, self.compDurations[1], self.compDurations[2]) + aeTime = clamp(aeTime, self.compDurations[1], self.compDurations[2]) + elseif self.animationMode == AnimationMode.StretchLoop then + local newCurTime = startTime + (curTime - startTime) * self.speed % lvDuration + aeTime = remap(newCurTime, startTime, endTime, self.compDurations[1], self.compDurations[2]) + + if math.floor((curTime - startTime) * self.speed / lvDuration) >= 1 then + aeTime = self.compDurations[1] + (aeTime - self.compDurations[1]) % (self.compDurations[2] - self.loopStart) + self.loopStart + end + end + end + + if self.effectType == EffectType.Transition then + local input1 = Amaz.BuiltinObject.getUserTexture("#TransitionInput0") + local input2 = Amaz.BuiltinObject.getUserTexture("#TransitionInput1") + if input1 and input2 then + for index, transitionInputInfo in ipairs(self.transitionInputIndex) do + local entityName = transitionInputInfo[1] + local texName = transitionInputInfo[2] + local inputIndex = transitionInputInfo[3] + if inputIndex == 0 then + self.lumi_obj:setSubEffectAttr(entityName, texName, input1) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 0) + else + self.lumi_obj:setSubEffectAttr(entityName, texName, input2) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 1) + end + end + aeTime = Amaz.Input.frameTimestamp * (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + end + elseif self.effectType == EffectType.VideoAnimation then + if self.videoAnimationLua == nil then + self:initVideoAnimationLua(comp) + end + if self.videoAnimationLua ~= nil then + aeTime = remap(self.videoAnimationLua.curTime, 0, self.videoAnimationLua.duration, self.compDurations[1], self.compDurations[2]) + end + end + + if isEditor then + if self.autoPlay then + self.debugTime = curTime % (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + aeTime = self.debugTime + else + aeTime = self.debugTime + end + elseif self.effectType == EffectType.VideoAnimation or self.effectType == EffectType.Transition then + self.curTime = aeTime + end + + if self.lumi_obj then + self.lumi_obj:setEffectAttrRecursively("startTime", self.startTime) + self.lumi_obj:setEffectAttrRecursively("endTime", self.endTime) + self.lumi_obj:setEffectAttrRecursively("curTime", self.curTime) + self.lumi_obj:setEffectAttrRecursively("aeTime", aeTime) + self.lumi_obj:setEffectAttrRecursively("aeDuration", aeDuration) + end + + if self.lumi_params_setter and self.lumi_params_setter.initParams then + self.lumi_params_setter:initParams(self.lumi_obj) + end + if self.lumi_params_setter and self.lumi_params_setter.updateKeyFrameData then + self.lumi_params_setter:updateKeyFrameData(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateSlider then + self.lumi_params_setter:updateSlider(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateFade then + if self.effectType == EffectType.Effect then + self.lumi_params_setter:updateFade(self.lumi_obj, self.startTime, self.endTime, self.curTime, self.compDurations, aeTime) + end + end + + if self.lumi_obj and self.durations ~= nil then + aeTime = math.min(math.max(aeTime, self.compDurations[1]), self.compDurations[2]) + for entityName, durationMap in pairs(self.durations) do + local nodeDuration = durationMap['nodeDuration'] + local visible = false + for j = 1, #nodeDuration do + if nodeDuration[j][1] <= aeTime and aeTime < nodeDuration[j][2] then + visible = true + break + end + end + self.lumi_obj:setVisible(entityName, visible) + end + end + if self.lumi_obj and self.lumi_obj.updateMaterials then + self.lumi_obj:updateMaterials(deltaTime) + end +end + +-- function LumiManager:onLateUpdate(comp, deltaTime) +-- collectgarbage("collect") +-- end + +function LumiManager:onEvent(comp, event) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Failed to find lumi_obj') + return + end + + if self.effectType == EffectType.Effect then + if event.args:get(0) == 'effects_adjust_speed' then + local value = event.args:get(1) + if self.animationInfos then + if value < 0 or value > 1 then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid effects_adjust_speed value: ' .. value) + end + self.speed = remap(clamp(value, 0, 1), 0, 1, self.animationInfos.speedInfo[2], self.animationInfos.speedInfo[3]) + else + self.speed = value + end + end + elseif event.args:get(0) == 'start_time' and self.cameraMode then + self.cameraStartTime = event.args:get(2) + elseif event.args:get(0) == 'is_video' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.isVideo = event.args:get(2) + elseif event.args:get(0) == 'video_time' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.videoTime = event.args:get(2) + end + + if self.lumi_params_setter and self.lumi_params_setter.onEvent then + self.lumi_params_setter:onEvent(self.lumi_obj, event) + end +end + +exports.LumiManager = LumiManager +return exports diff --git a/scripts/7681599071768956161/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua b/scripts/7681599071768956161/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua new file mode 100644 index 0000000000000000000000000000000000000000..c1e528b6007352c9831b71df7a92892be83703dc --- /dev/null +++ b/scripts/7681599071768956161/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua @@ -0,0 +1,436 @@ + +local LumiObjectExtension = {} +LumiObjectExtension.__index = LumiObjectExtension + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag-LumiObjectExtension' + +local function handleAllEntityBySingleParent(_trans, func, func2, ...) + if _trans.children:size() > 0 and func2(_trans, ...) then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i-1) + handleAllEntityBySingleParent(child, func, func2, ...) + end + end + func(_trans, ...) +end + +local function CreateRenderTexture(width, height) + local rt = Amaz.RenderTexture() + rt.width = width + rt.height = height + rt.depth = 1 + rt.filterMag = Amaz.FilterMode.LINEAR + rt.filterMin = Amaz.FilterMode.LINEAR + rt.filterMipmap = Amaz.FilterMipmapMode.NONE + rt.attachment = Amaz.RenderTextureAttachment.NONE + return rt +end + +function LumiObjectExtension.register(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + + local self = setmetatable({}, LumiObjectExtension) + self.entity = _ent + self.scriptComp = scriptComp + self.trans = _ent:getComponent("Transform") + self.effect_lua = effect_lua + if effect_lua.__lumi_type~= nil then + self.__lumi_type = effect_lua.__lumi_type + else + self.__lumi_type = "lumi_obj" + end + if effect_lua.__lumi_rt_pingpong_type~= nil then + self.__lumi_rt_pingpong_type = effect_lua.__lumi_rt_pingpong_type + else + self.__lumi_rt_pingpong_type = "custom" + end + + if self.entity:getComponents("Camera"):size() > 0 then + Amaz.LOGE(AE_EFFECT_TAG, "Error: root entity has camera attached") + return nil + end + self.subLumiObjExt = {} + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local objExt = LumiObjectExtension.register(child.entity) + if objExt and child.entity.name ~= '' then + self.subLumiObjExt[child.entity.name] = objExt + end + end + end + effect_lua.__lumi_obj_ext = self + return self +end + +function LumiObjectExtension.deregister(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + local lumi_obj = effect_lua.__lumi_obj_ext + if lumi_obj == nil then return nil end + + if lumi_obj.__lumi_type == "lumi_effect" then + for i = 1, lumi_obj.trans.children:size() do + local child = lumi_obj.trans.children:get(i-1) + LumiObjectExtension.deregister(child.entity) + end + end + lumi_obj.entity = nil + lumi_obj.trans = nil + lumi_obj.effect_lua = nil + lumi_obj.scriptComp = nil + lumi_obj.subLumiObjExt = nil + lumi_obj.__lumi_type = nil + lumi_obj.__lumi_rt_pingpong_type = nil + effect_lua.__lumi_obj_ext = nil +end + +function LumiObjectExtension.getLumiObjExt(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + return effect_lua.__lumi_obj_ext +end + +function LumiObjectExtension:searchSubLumiObjExt(name) + if self.trans.entity.name == name then + return self + end + if name and self.subLumiObjExt[name] then + return self.subLumiObjExt[name] + end + for _, subObj in pairs(self.subLumiObjExt) do + local obj = subObj:searchSubLumiObjExt(name) + if obj then + return obj + end + end + return nil +end + +function LumiObjectExtension:setInputTex(_tex) + if self.effect_lua then + self.effect_lua.InputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('InputTex', _tex) + end + end +end + +function LumiObjectExtension:setOutputTex(_tex) + if self.effect_lua then + self.effect_lua.OutputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('OutputTex', _tex) + end + end +end + +function LumiObjectExtension:getInputTex() + if self.effect_lua then + return self.effect_lua.InputTex + end + return nil +end + +function LumiObjectExtension:getOutputTex() + if self.effect_lua then + return self.effect_lua.OutputTex + end + return nil +end + +function LumiObjectExtension:setInputTexSizes(inputSize, originalSize) + assert(type(inputSize)=="table", "inputSize should be table") + if self.effect_lua and self.effect_lua.setInputTexSize then + self.effect_lua:setInputTexSize(inputSize) + end + if self.effect_lua and self.effect_lua.setInputOriginalTexSize then + self.effect_lua:setInputOriginalTexSize(originalSize) + end + self._inputTexSize, self._originalTexSize = inputSize, originalSize +end + +function LumiObjectExtension:getOutputTexSizes() + local inputSize = (self.effect_lua and self.effect_lua.getOutputTexSize) and self.effect_lua:getOutputTexSize() or self._inputTexSize + local originalSize = (self.effect_lua and self.effect_lua.getOutputOriginalTexSize) and self.effect_lua:getOutputOriginalTexSize() or self._originalTexSize + return inputSize, originalSize +end + +function LumiObjectExtension:needChangeOutputTexSize() + if self.effect_lua and self.effect_lua.__lumi_will_change_out_size then + return self.effect_lua.__lumi_will_change_out_size + end + if self._inputTexSize~=nil and self.effect_lua and self.effect_lua.getOutputTexSize then + local outSize = self.effect_lua:getOutputTexSize() + return (outSize[1] ~= self._inputTexSize[1] or outSize[2] ~= self._inputTexSize[2]) + end + return false +end + +function LumiObjectExtension:updateRt(_input_tex, _output_tex, _pingpong_tex) + self:setInputTex(_input_tex) + self:setOutputTex(_output_tex) + if self.effect_lua and self.effect_lua.updateRenderTexture ~= nil then + self.effect_lua:updateRenderTexture() + end + if self.__lumi_type == "lumi_effect" and self.__lumi_rt_pingpong_type == "auto" then + local lumi_obj_list = {} + local function collect_lumi_obj(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and (lumi_obj_ext.__lumi_type == "lumi_obj" or lumi_obj_ext.__lumi_rt_pingpong_type == "custom") then + table.insert(lumi_obj_list, lumi_obj_ext) + end + end + local function collect_lumi_obj_flag(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and lumi_obj_ext.__lumi_type == "lumi_effect" and lumi_obj_ext.__lumi_rt_pingpong_type == "auto" then + return true + end + return false + end + handleAllEntityBySingleParent(self.trans, collect_lumi_obj, collect_lumi_obj_flag) + + if _pingpong_tex then + self._pingpong_tex = _pingpong_tex + elseif #lumi_obj_list > 1 then + self._pingpong_tex = CreateRenderTexture(_output_tex.width, _output_tex.height) + end + local pingpong = { _output_tex, self._pingpong_tex } + if #lumi_obj_list%2 == 0 then + pingpong = { self._pingpong_tex, _output_tex } + end + for i = 1, #lumi_obj_list do + local lumi_obj = lumi_obj_list[i] + if lumi_obj then + local idx1 = (i-1)%2+1 + local idx2 = (i)%2+1 + if i == 1 then + lumi_obj:setInputTex(_input_tex) + lumi_obj:setOutputTex(pingpong[idx1]) + else + lumi_obj:setInputTex(pingpong[idx2]) + lumi_obj:setOutputTex(pingpong[idx1]) + end + if lumi_obj.effect_lua and lumi_obj.effect_lua.updateRenderTexture ~= nil then + lumi_obj.effect_lua:updateRenderTexture() + end + end + end + end +end + +function LumiObjectExtension:updateOutputRtSize(width, height) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i - 1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateOutputRtSize(width, height) + end + end + end + local tex = self:getOutputTex() + if tex then + tex.width = width + tex.height = height + end +end + +function LumiObjectExtension:getCameraCount() + local cam_count = 0 + + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + cam_count = cam_count + lumi_obj_ext:getCameraCount() + else + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + elseif self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + + return cam_count +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str.."0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiObjectExtension:updateCameraLayerAndOrder(_start_layer, _start_order) + function updateRendererEntityLayer(trans, layer) + local renderers = trans.entity:getComponentsRecursive("Renderer") + for i = 0, renderers:size() - 1 do + local renderer = renderers:get(i) + if renderer then + renderer.entity.layer = layer + end + end + end + + local lastCamera = nil + + local cur_start_layer = _start_layer + local cur_start_order = _start_order + + if self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local curTrans = self.trans.children:get(i-1) + local cam = curTrans.entity:getComponent("Camera") + if cam then + if lastCamera then + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + lastCamera = cam + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, curTrans.children:size() do + local rendererTrans = curTrans.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + elseif lastCamera then + updateRendererEntityLayer(curTrans, cur_start_layer) + end + end + + elseif self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateCameraLayerAndOrder(cur_start_layer, cur_start_order) + local cam_count = lumi_obj_ext:getCameraCount() + cur_start_layer = cur_start_layer + cam_count + cur_start_order = cur_start_order + cam_count + else + local cam = child.entity:getComponent("Camera") + if cam then + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, child.children:size() do + local rendererTrans = child.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end + end + + return cur_start_layer, cur_start_order +end + +function LumiObjectExtension:setEffectAttr(key, value) + if self.effect_lua and self.effect_lua.setEffectAttr ~= nil then + self.effect_lua:setEffectAttr(key, value, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + self.effect_lua[key] = value + if self.scriptComp and self.scriptComp.properties ~= nil then + self.scriptComp.properties:set(key, value) + end + end + end +end + +function LumiObjectExtension:getEffectAttr(key) + if self.effect_lua and self.effect_lua.getEffectAttr ~= nil then + return self.effect_lua:getEffectAttr(key, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + return self.effect_lua[key] + end + end + return nil +end + +function LumiObjectExtension:setSubEffectAttr(subName, key, value) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + subObj:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:getSubEffectAttr(subName, key) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + return subObj:getEffectAttr(key) + end + return nil +end + +function LumiObjectExtension:setEffectAttrRecursively(key, value) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:setEffectAttrRecursively(key, value) + end + end + self:setEffectAttr(key, value) + elseif self.__lumi_type == "lumi_obj" then + self:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:updateMaterials(time) + if self.effect_lua and self.scriptComp and self.entity and self.entity.visible then + if self.effect_lua.updateMaterial ~= nil then + self.effect_lua:updateMaterial(self.scriptComp, time) + elseif self.effect_lua.onUpdate ~= nil then + self.effect_lua:onUpdate(self.scriptComp, time) + end + + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateMaterials(time) + end + end + end +end + +function LumiObjectExtension:setVisible(subName, visible) + local subObj = self:searchSubLumiObjExt(subName) + if subObj and subObj.effect_lua then + if subObj.effect_lua.setVisible then + subObj.effect_lua:setVisible(visible) + else + subObj.entity.visible = visible + end + end +end + +return LumiObjectExtension diff --git a/scripts/7681599071768956161/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua b/scripts/7681599071768956161/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua new file mode 100644 index 0000000000000000000000000000000000000000..91587ae17803e82e95608198114893dfe226a5c9 --- /dev/null +++ b/scripts/7681599071768956161/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua @@ -0,0 +1,388 @@ +local LumiParamsSetter = {} +LumiParamsSetter.__index = LumiParamsSetter + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +function LumiParamsSetter.new(lumiManager, params, keyframes, effectType, sliderInfos, fadeinInfos, fadeoutInfos) + local self = setmetatable({}, LumiParamsSetter) + self.lumiManager = lumiManager + self.params = params + self.keyframes = keyframes + self.sliderInfos = sliderInfos + self.sliderParams = {} + self.XTEvent = (effectType == 'xtFilter' or effectType == 'xtEffect') + self.fadeinInfos = fadeinInfos + self.fadeoutInfos = fadeoutInfos + self.afterSliderParams = {} + + return self +end + +local function clamp(val, min, max) + return math.max(math.min(val, max), min) +end + +local function mix(a, b, t) + return a * (1 - t) + b * t +end + +local function cvtTable2Amaz(attrType, v) + local value = nil + if attrType == "number" then + if #v == 1 then + value = v[1] + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "vector" then + if #v == 2 then + value = Amaz.Vector2f(v[1], v[2]) + elseif #v == 3 then + value = Amaz.Vector3f(v[1], v[2], v[3]) + elseif #v == 4 then + value = Amaz.Vector4f(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "color" then + if #v == 3 then + value = Amaz.Color(v[1], v[2], v[3], 1.0) + elseif #v == 4 then + value = Amaz.Color(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. "unsupported type: " .. attrType) + end + return value +end + +local function getValueType(value) + local valueType = type(value) + if valueType == 'userdata' then + local str = tostring(value) + if string.sub(str, 1, 6) == 'Vector' then + valueType = 'vector' + elseif string.sub(str, 1, 5) == 'Color' then + valueType = 'color' + end + end + + return valueType +end + +local function add(value, number) + local type = getValueType(value) + if type == 'number' then + return value + number + elseif type == 'vector' then + local ret = value:copy() + ret.x = ret.x + number + ret.y = ret.y + number + if ret.z then ret.z = ret.z + number end + if ret.w then ret.w = ret.w + number end + return ret + elseif type == 'color' then + return Amaz.Color( + value.r + number, + value.g + number, + value.b + number, + value.a + number + ) + end + return nil +end + +local function mul(value, number) + local type = getValueType(value) + if type == 'color' then + return Amaz.Color( + value.r * number, + value.g * number, + value.b * number, + value.a * number + ) + end + return value * number +end + +function LumiParamsSetter:getCurrentDefaultParam(entityName, key, aeTime) + local keyframeName = nil + local keyframeType = 'number' + if self.keyframes ~= nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'number' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'vector' + keyframeType = 'vector' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'color' + keyframeType = 'color' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = nil + end + end + end + + if keyframeName == nil then + if entityName:sub(1, #'LumiLayer') == 'LumiLayer' and key:sub(-#'position') == 'position' then + local entity = self.params[entityName] + if entity ~= nil then + local position = entity[key] + if position ~= nil then + local hasSeparated = false + local newPosition = position:copy() + + local newKey = string.gsub(key, 'position', 'xPosition') + local newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.x = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'yPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.y = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'zPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.z = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + if hasSeparated then + return newPosition + end + end + end + end + end + end + + local value = nil + if keyframeName ~= nil then + value = cvtTable2Amaz(keyframeType, self.keyframes:GetVal(keyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + else + local entity = self.params[entityName] + if entity ~= nil then + value = entity[key] + end + end + return value +end + +function LumiParamsSetter:updateSlider(lumi_obj, aeTime) + -- local sliderIntensity = self.sliderParams['effects_adjust_blur'] + -- local gaussianIntensity = self:getCurrentDefaultParam("Gaussian_Blur_Root_353-effect2", 'intensity', aeTime) + -- if sliderIntensity and gaussianIntensity then + -- lumi_obj:setSubEffectAttr("Gaussian_Blur_Root_353-effect2", 'intensity', gaussianIntensity*sliderIntensity) + -- end + + local function fsub(value, slider, valueA, valueB) + -- (param - sliderValue) * valueA + valueB + return (value - slider) * valueA + valueB + end + + local function fmul(value, slider, valueA, valueB) + -- (param - valueA) * sliderValue + valueB + return (value - valueA) * slider + valueB + end + + local function fadd(value, slider, valueA, valueB) + -- (param - valueA) * valueB + sliderValue + return (value - valueA) * valueB + slider + end + + self.afterSliderParams = {} + for sliderKey, paramsInfos in pairs(self.sliderInfos) do + if self.sliderParams[sliderKey] ~= nil then + for index, value in ipairs(paramsInfos) do + local sliderIntensity = self.sliderParams[sliderKey] + local entityName = value[1] + local paramKey = value[2] + local paramType = value[3] + local paramDimensionFlag = value[4] + local calcType = value[5] + local maxValue = value[6] + local minValue = value[7] + local defaultValue = value[8] + local valueA = value[9] + local valueB = value[10] + sliderIntensity = sliderIntensity * (maxValue - minValue) + minValue + local oriValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + oriValue = self.afterSliderParams[entityName .. '#' .. paramKey] + end + local newValue = oriValue + local calcFunc = nil + if calcType == 0 then + calcFunc = fsub + elseif calcType == 1 then + calcFunc = fmul + elseif calcType == 2 then + calcFunc = fadd + else + Amaz.LOGE(AE_EFFECT_TAG, 'Unknown calcType: ' .. calcType) + return + end + if paramType == 'number' then + if paramDimensionFlag[1] then newValue = calcFunc(oriValue, sliderIntensity, valueA[1], valueB[1]) end + elseif paramType == 'color' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.r = calcFunc(oriValue.r, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.g = calcFunc(oriValue.g, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.b = calcFunc(oriValue.b, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.a = calcFunc(oriValue.a, sliderIntensity, valueA[4], valueB[4]) end + elseif paramType == 'vector' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.x = calcFunc(oriValue.x, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.y = calcFunc(oriValue.y, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.z = calcFunc(oriValue.z, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.w = calcFunc(oriValue.w, sliderIntensity, valueA[4], valueB[4]) end + end + lumi_obj:setSubEffectAttr(entityName, paramKey, newValue) + self.afterSliderParams[entityName .. '#' .. paramKey] = newValue + end + end + end +end + +function LumiParamsSetter:updateFadeParams(lumi_obj, fadeInfos, factor, aeTime) + for i = 1, #fadeInfos.infos do + local entityName = fadeInfos.infos[i][1] + local paramKey = fadeInfos.infos[i][2] + local valueType = fadeInfos.infos[i][3] + local value = fadeInfos.infos[i][4] + + local curValue = nil + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + curValue = self.afterSliderParams[entityName .. '#' .. paramKey] + else + curValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + end + + if curValue ~= nil then + local needRenew = true + if valueType == 'number' then + curValue = mix(value[1], curValue, factor) + elseif valueType == 'color' then + curValue.r = mix(value[1], curValue.r, factor) + curValue.g = mix(value[2], curValue.g, factor) + curValue.b = mix(value[3], curValue.b, factor) + curValue.a = mix(value[4], curValue.a, factor) + elseif valueType == 'vector' then + if #value <= 1 or #value >= 5 then + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid value size: ' .. #value) + else + if #value >= 2 then + curValue.x = mix(value[1], curValue.x, factor) + curValue.y = mix(value[2], curValue.y, factor) + end + if #value >= 3 then + curValue.z = mix(value[3], curValue.z, factor) + end + if #value >= 4 then + curValue.w = mix(value[4], curValue.w, factor) + end + end + else + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid valye type: ' .. valueType) + end + if needRenew then + lumi_obj:setSubEffectAttr(entityName, paramKey, curValue) + end + end + end +end + +function LumiParamsSetter:updateFade(lumi_obj, startTime, endTime, curTime, compDurations, aeTime) + local scale = (endTime - startTime) / (compDurations[2] - compDurations[1]) + scale = clamp(scale, 0, 1) + local runningTime = curTime - startTime + local remainingTime = endTime - curTime + + local isInFadein = false + if self.fadeinInfos + and self.fadeinInfos.time and self.fadeinInfos.time > 0 + and self.fadeinInfos.infos and #self.fadeinInfos.infos > 0 + then + local fadeinTime = self.fadeinInfos.time * scale + if runningTime <= fadeinTime then + isInFadein = true + local factor = runningTime / fadeinTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeinInfos, factor, aeTime) + end + end + + if self.fadeoutInfos + and self.fadeoutInfos.time and self.fadeoutInfos.time > 0 + and self.fadeoutInfos.infos and #self.fadeoutInfos.infos > 0 + then + local fadeoutTime = self.fadeoutInfos.time * scale + if remainingTime <= fadeoutTime or not isInFadein then + local factor = remainingTime / fadeoutTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeoutInfos, factor, aeTime) + end + end +end + +function LumiParamsSetter:onEvent(lumi_obj, event) + if lumi_obj == nil or event == nil then return end + local key = event.args:get(0) + if self.sliderInfos[key] ~= nil then + if self.XTEvent then + self.sliderParams[key] = event.args:get(2); + else + self.sliderParams[key] = event.args:get(1); + end + end +end + +function LumiParamsSetter:initParams(lumi_obj) + if lumi_obj == nil then return end + if self.params == nil then return end + if self.init then return end + + for entityName, params in pairs(self.params) do + for key, value in pairs(params) do + lumi_obj:setSubEffectAttr(entityName, key, value) + end + end + + self.init = true +end + +function LumiParamsSetter:updateKeyFrameData(lumi_obj, aeTime) + if lumi_obj == nil then return end + if self.keyframes == nil then return end + + local p = aeTime + for key, _ in pairs(self.keyframes.attrs) do + local keys = {} + for substr in string.gmatch(key, "[^#]+") do + table.insert(keys, substr) + end + if #keys == 3 then + local entityName = keys[1] + local attrName = keys[2] + local attrType = keys[3] + local v = self.keyframes:GetVal(key, self.lumiManager:getKeyframeAeTime(p)) + local value = cvtTable2Amaz(attrType, v) + if value then + lumi_obj:setSubEffectAttr(entityName, attrName, value) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key) + end + end +end + +return LumiParamsSetter diff --git a/scripts/7681599071768956161/config.json b/scripts/7681599071768956161/config.json new file mode 100644 index 0000000000000000000000000000000000000000..a7fc5f03841da3b151670f6f83d2135f35130e42 --- /dev/null +++ b/scripts/7681599071768956161/config.json @@ -0,0 +1,16 @@ +{ + "ae_tool": "AEExporter:1.5.5", + "bALG_BACH_CONFIG": false, + "effect": { + "Link": [ + { + "path": "AmazingFeature/", + "type": "AmazingFeature", + "zorder": 8029 + } + ] + }, + "name": "AE2Effect_20260904161438937", + "version": "14.8.0", + "item_source": "user_post_pc_le" +} \ No newline at end of file diff --git a/scripts/7681599071768956161/extra.json b/scripts/7681599071768956161/extra.json new file mode 100644 index 0000000000000000000000000000000000000000..ec38cac1dc913e65be2cf75cf5df6f7f59324f36 --- /dev/null +++ b/scripts/7681599071768956161/extra.json @@ -0,0 +1 @@ +{ "transition": { "defaultDura": 2.000001, "isOverlap": true } } \ No newline at end of file diff --git a/scripts/7681605099352870164/AmazingFeature/content.json b/scripts/7681605099352870164/AmazingFeature/content.json new file mode 100644 index 0000000000000000000000000000000000000000..df43720515b1b6981b24c4268c902195fa613d43 --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/content.json @@ -0,0 +1,7 @@ +{ + "ae_tool" : "AmazingEditor", + "content" : {}, + "needblend" : false, + "tag" : "AMG_1515088281693380358513659446614427937212", + "version" : "1.0" +} \ No newline at end of file diff --git a/scripts/7681605099352870164/AmazingFeature/js/JSSys.js b/scripts/7681605099352870164/AmazingFeature/js/JSSys.js new file mode 100644 index 0000000000000000000000000000000000000000..bbcbf36f0f75c1beebe88c33dd0464bb4477158e --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/js/JSSys.js @@ -0,0 +1,89 @@ +const effect_api = "undefined" != typeof effect ? effect : "undefined" != typeof tt ? tt : "undefined" != typeof lynx ? lynx : {}; +const Amaz = effect_api.getAmaz(); + +const { ScriptScene } = require('./ThreeJS/scriptScene'); +const THREE = require('./ThreeJS/three-amg-wrapper').THREE; + +class JSSys { + constructor() { + this.name = "JSSys"; + this.comps = {} + this.compsdirty = true + } + + onComponentAdded(comp) { + // console.log("running:JSSys:onComponentAdded"); + } + onComponentRemoved(comp) { + // console.log("running:JSSys:onComponentRemoved"); + } + + onStart() { + console.log("running:JSSys:onStart"); + + this.renderTexture = this.scene.assetMgr.SyncLoad('rt/outputTex.rt'); + + // 添加光源到场景 + console.log('JSSys: 创建ScriptScene实例'); + this.scriptScene = new ScriptScene(this.scene); + + this.input = Amaz.AmazingManager.getSingleton("Input"); + const builtinObject = Amaz.AmazingManager.getSingleton("BuiltinObject"); + + if (builtinObject.getUserTexture("#TransitionInput0") && builtinObject.getUserTexture("#TransitionInput1")) { + this.scriptScene.texture1 = new THREE.Texture(); + this.scriptScene.texture1.setImage(builtinObject.getUserTexture("#TransitionInput0")); + this.scriptScene.texture2 = new THREE.Texture(); + this.scriptScene.texture2.setImage(builtinObject.getUserTexture("#TransitionInput1")); + console.log("JSSys: 获取到纹理"); + } + else + { + this.scriptScene.texture1 = new THREE.Texture(); + this.scriptScene.texture1.setImage(this.scene.assetMgr.SyncLoad('image/Sample1.jpg')); + this.scriptScene.texture2 = new THREE.Texture(); + this.scriptScene.texture2.setImage(this.scene.assetMgr.SyncLoad('image/Sample2.jpg')); + console.log("JSSys: 未获取到纹理,使用默认纹理"); + } + + this.scriptScene.setupScene(); + // 初始化后处理效果 + if (this.scriptScene.initPostProcessing != null) { + this.scriptScene.initPostProcessing(); + } + } + + onUpdate(deltaTime) { + this.time = this.input.getFrameTimestamp(); + // this.time = this.time % 2; + // this.time = this.time / 2.0; + this.scriptScene.seekToTime(this.time * this.scriptScene.Duration); + // this.scriptScene.updateScene(); + } + onLateUpdate(deltaTime) { + // console.log("running:JSSys:onLateUpdate"); + this.scriptScene.scene.seekToTime(this.time * this.scriptScene.Duration); + } + + onEvent(event) { + console.log("running:JSSys:onEvent"); + if (event.type == Amaz.EventType.VIEWER) { + // console.log("JSSys: 窗口大小改变"); + console.log("renderTexture.width",this.renderTexture.width); + console.log("renderTexture.height",this.renderTexture.height); + + window.innerWidth = this.renderTexture.width; + window.innerHeight = this.renderTexture.height; + // console.log("JSSys: 窗口大小改变"); + this.scriptScene.handleResize(); + } + } + + onDestroy() { + // console.log("running:JSSys:onDestroy"); + this.scriptScene.destroy(); + } +} + +exports.JSSys = JSSys; + diff --git a/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/EffectComposer.js b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/EffectComposer.js new file mode 100644 index 0000000000000000000000000000000000000000..e7d8fd7a3f3978d9da1a9bf29af1854806f60014 --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/EffectComposer.js @@ -0,0 +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{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-6*k)*Math.cos(12*k)};const springStiff=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(18*k)};const dampedOscillation=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(10*k)};const Physics=Object.freeze({SpringSoft:springSoft,SpringStiff:springStiff,DampedOscillation:dampedOscillation});const anticipate=k=>{if(k<=0)return 0;if(k>=1)return 1;const pullback=.1;if(k<.3){const p=k/.3;return-pullback*p*(2-p)}const p=(k-.3)/.7;return-pullback+(1+pullback)*p*p*(3-2*p)};const overshootFactory=peak=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return peak*p*(2-p)}const p=(k-.6)/.4;return peak+(1-peak)*(1-Math.pow(1-p,3))};const overshoot110=overshootFactory(1.1);const overshoot125=overshootFactory(1.25);const snapBack=k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return 1.05*(1-Math.pow(1-p,3))}const p=(k-.6)/.4;return 1.05-.05*p*p*(3-2*p)};const swing=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.cos(1.5*Math.PI*k)*Math.exp(-2.5*k)};const Motion=Object.freeze({Anticipate:anticipate,Overshoot110:overshoot110,Overshoot125:overshoot125,SnapBack:snapBack,Swing:swing});const makeStep=(n,jumpTerm="end")=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(jumpTerm==="start")return Math.ceil(k*n)/n;return Math.floor(k*n)/n};const Step=Object.freeze({Steps4End:makeStep(4,"end"),Steps8End:makeStep(8,"end"),Steps12End:makeStep(12,"end")});function buildCubicBezier(x1,y1,x2,y2){const cx=3*x1,bx=3*(x2-x1)-cx,ax=1-cx-bx;const cy=3*y1,by=3*(y2-y1)-cy,ay=1-cy-by;const sampleX=s=>((ax*s+bx)*s+cx)*s;const sampleY=s=>((ay*s+by)*s+cy)*s;const sampleDX=s=>(3*ax*s+2*bx)*s+cx;const solveS=x=>{let s=x;for(let i=0;i<8;i++){const cur=sampleX(s)-x;if(Math.abs(cur)<1e-6)return s;const d=sampleDX(s);if(Math.abs(d)<1e-6)break;s-=cur/d;if(s<0)s=0;if(s>1)s=1}let lo=0,hi=1;for(let i=0;i<32&&hi-lo>1e-6;i++){const mid=(lo+hi)/2;if(sampleX(mid){if(k<=0)return 0;if(k>=1)return 1;return sampleY(solveS(k))}}const BEZIER_PRESETS=Object.freeze({"Material.Standard":[.4,0,.2,1],"Material.Accelerate":[.4,0,1,1],"Material.Decelerate":[0,0,.2,1],"CSS.Ease":[.25,.1,.25,1]});const _bezierCache=new Map;function _cachedBezier(x1,y1,x2,y2){const key=x1+","+y1+","+x2+","+y2;let fn=_bezierCache.get(key);if(!fn){fn=buildCubicBezier(x1,y1,x2,y2);_bezierCache.set(key,fn)}return fn}function cubicBezier(a,b,c,d){if(typeof a==="string"){let preset=BEZIER_PRESETS[a];if(!preset){console.warn("[customEasings.cubicBezier] unknown preset, falling back to Material.Standard:",a);preset=BEZIER_PRESETS["Material.Standard"]}return _cachedBezier(preset[0],preset[1],preset[2],preset[3])}const clamp=(v,lo,hi)=>Math.max(lo,Math.min(hi,v));const x1=clamp(a,0,1);const y1=clamp(b,-.5,1.5);const x2=clamp(c,0,1);const y2=clamp(d,-.5,1.5);return _cachedBezier(x1,y1,x2,y2)}const libSpring=({stiffness=180,damping=12,mass=1}={})=>{const DT=1/240;const T=1.5;let x=0,v=0;const samples=[];for(let t=0;t<=T;t+=DT){const force=-stiffness*(x-1)-damping*v;v+=force/mass*DT;x+=v*DT;samples.push({t:t,x:x})}let T_end=T;for(let i=samples.length-1;i>=0;i--){if(Math.abs(samples[i].x-1)>.01){T_end=samples[i].t;break}}return k=>{if(k<=0)return 0;if(k>=1)return 1;const t=k*T_end;const idx=Math.min(samples.length-1,Math.floor(t/DT));return samples[idx].x}};const libHeartBeat=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c)=>Math.exp(-((t-c)**2)/(2*.07*.07));return peak*(bell(k,.2)+bell(k,.5))};const libSteps=(n=6)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return Math.floor(k*n)/n};const attentionPing=(peak=.35,decay=2)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(Math.PI*k)*Math.exp(-decay*k)};const attentionWiggle=(count=4,amplitude=.25)=>k=>{if(k<=0||k>=1)return 0;const env=1-k;return amplitude*env*Math.sin(k*Math.PI*2*count)};const attentionStrum=(notes=4,peak=.4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*.05*.05))}return peak*sum}};const Attention=Object.freeze({Ping:attentionPing(),Wiggle:attentionWiggle(),Strum:attentionStrum()});const breathNormal=(cycles=2,peak=.15)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(k*Math.PI*2*cycles)*Math.sin(k*Math.PI)};const breathDeep=(peak=.3,riseRatio=.35,holdRatio=.15)=>{const holdEnd=riseRatio+holdRatio;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const envelope=Math.sin(k*Math.PI);const wave=.5+.5*Math.sin(k*Math.PI*2*cycles-Math.PI/2);return peak*envelope*wave};const breathSigh=(peak=.25,riseRatio=.2)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return peak*Math.exp(-((k-center)**2)/(2*width*width))};const heartExcited=(beats=4,peak=.3,width=.04)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*width*width))}return peak*sum}};const heartLubDub=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return peak*(bell(k,.25,.045)+.6*bell(k,.42,.03))};const Heart=Object.freeze({Calm:heartCalm(),Excited:heartExcited(),LubDub:heartLubDub()});const mathJumpArc=()=>k=>{if(k<=0||k>=1)return 0;return 4*k*(1-k)};const mathPendulum=(damping=3,freq=2.5)=>k=>{if(k<=0||k>=1)return 0;return Math.sin(k*Math.PI)*Math.exp(-damping*k)*Math.cos(freq*Math.PI*k)};const mathTremor=(amplitude=.04,freq=22)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return k+amplitude*Math.sin(k*Math.PI*2*freq)};const mathBoomerang=fn=>k=>{if(k<=0||k>=1)return 0;return k<.5?fn(k*2):fn(2-k*2)};const MathExt=Object.freeze({JumpArc:mathJumpArc(),Pendulum:mathPendulum(),Tremor:mathTremor()});const explosionImpulse=(sharpness=6)=>{const tail=sharpness*Math.exp(1-sharpness);return k=>{if(k<=0||k>=1)return 0;const h=sharpness*k;return h*Math.exp(1-h)-tail*k}};const explosionFlash=(rise=.05,decay=5)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return-Math.exp(-decay*k)*Math.cos(freq*Math.PI*k)};const explosionImplosion=(charge=.3,depth=.4,burstPeak=1.2)=>{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const w=Math.sin(k*Math.PI*2*cycles)+.5*Math.sin(k*Math.PI*2*cycles*1.5+1.2)+.25*Math.sin(k*Math.PI*2*cycles*3+2.4);return amplitude*env*w*.6};const natureFlicker=(rate=15,intensity=.2,seed=7)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=rate+1;i++)samples.push(rand());return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*rate;const idx=Math.floor(pos);const t=pos-idx;const a=samples[idx];const b=samples[idx+1];const interp=a+(b-a)*t;return intensity*env*(interp-.5)*2}};const natureGust=(gusts=3,peak=.25)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*.08*.08))}return peak*sum/gusts*1.8}};const Nature=Object.freeze({Wave:natureWave(),Flicker:natureFlicker(),Gust:natureGust()});const impactRain=(impactAt=.7,rippleAmp=.08)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const liftEnd=.35,strikeEnd=.6;return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return t*t}const t=(k-.4)/.6;const env=Math.exp(-2.5*t);const wave=Math.abs(Math.sin(t*Math.PI*bounces));return 1-env*wave*rebound};const impactSlap=(contactAt=.3,holdRatio=.1)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return.4*Math.pow(t,2.5)}if(k<.48){const t=(k-.4)/.08;return.4-.2*t}if(k<.52){const t=(k-.48)/.04;return.2+.8*t}const t=(k-.52)/.48;return 1-.04*Math.sin(t*Math.PI*8)*(1-t)};const rhythmPunchCombo=(peak=.4)=>{const pattern=[{c:.15,w:.04,a:.75},{c:.35,w:.04,a:.75},{c:.7,w:.055,a:1}];return k=>{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of pattern){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return peak*sum}};const rhythmStaccato=(beats=4,duty=.3)=>k=>{if(k<=0||k>=1)return 0;const beatLen=1/beats;const phase=k/beatLen-Math.floor(k/beatLen);if(phase>duty)return 0;const t=phase/duty;return Math.sin(t*Math.PI)};const rhythmKick=(peak=1.2)=>k=>{if(k<=0||k>=1)return 0;if(k<.05)return peak*k/.05;const t=(k-.05)/.95;return peak*Math.exp(-4*t)};const rhythmCrescendo=(beats=4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return sum}};const rhythmDunDunDun=()=>{const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return k=>{if(k<=0||k>=1)return 0;return.3*bell(k,.15,.025)+.6*bell(k,.35,.03)+1*bell(k,.68,.09)}};const rhythmBellToll=(decay=3,freq=8)=>{const strike=.05;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.2){const t=k/.2;return-pressDepth*Math.sin(t*Math.PI/2)}if(k<.5){const t=(k-.2)/.3;return-pressDepth+(pressDepth+reboundPeak)*(1-Math.pow(1-t,3))}const t=(k-.5)/.5;return reboundPeak*Math.exp(-4*t)*Math.cos(t*Math.PI*3)};const uiHoverBloom=(riseRatio=.2,fallRatio=.3)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=1-k;const raw=Math.sin(k*Math.PI*2*count);const clipped=Math.sign(raw)*Math.min(1,Math.abs(raw)*1.8);return amplitude*env*clipped};const uiSuccessPop=(overshoot=.2)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return(1+overshoot)*(1-Math.pow(1-t,2))}const t=(k-.4)/.6;return 1+overshoot*Math.exp(-5*t)*Math.cos(t*Math.PI*3)};const uiRippleOut=()=>k=>{if(k<=0||k>=1)return 0;return 6.75*k*Math.pow(1-k,2)};const UI=Object.freeze({ClickSnap:uiClickSnap(),HoverBloom:uiHoverBloom(),ErrorShake:uiErrorShake(),SuccessPop:uiSuccessPop(),RippleOut:uiRippleOut()});const magicManaCharge=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;const base=(Math.exp(3*k)-1)/(Math.exp(3)-1);const pulse=.04*Math.sin(k*Math.PI*8)*k;return base+pulse};const magicSpellCast=(chargeEnd=.4)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.45){const t=k/.45;return t*t*t}if(k<.55)return 1;const t=(k-.55)/.45;return Math.pow(1-t,3)};const magicShield=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.3){const t=k/.3;return 1.2*(1-Math.pow(1-t,2))}if(k<.6){const t=(k-.3)/.3;return 1.2-.2*t}const t=(k-.6)/.4;return 1+.03*Math.sin(t*Math.PI*3)};const magicAura=(peak=.15)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const fundamental=.6*Math.sin(k*Math.PI*2);const harmonic=.3*Math.sin(k*Math.PI*4+1);const overtone=.1*Math.sin(k*Math.PI*6+2);return peak*env*(fundamental+harmonic+overtone)};const Magic=Object.freeze({ManaCharge:magicManaCharge(),SpellCast:magicSpellCast(),Teleport:magicTeleport(),Shield:magicShield(),MagicAura:magicAura()});const animalCatPounce=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.2){const t=k/.2;return-.2*Math.sin(t*Math.PI)}if(k<.3){const t=(k-.2)/.1;return.5*t*t}if(k<.8){const t=(k-.3)/.5;return.5+.5*t+.2*Math.sin(t*Math.PI)}const t=(k-.8)/.2;return 1+.05*Math.sin(t*Math.PI)};const animalBirdFlap=(flaps=4)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const phase=k*Math.PI*2*flaps;const wave=Math.sin(phase)-.3*Math.sin(phase*2);return.2*env*wave};const animalSnakeSlither=(waves=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const wave=Math.sin(k*Math.PI*2*waves);return.2*env*wave};const animalButterflyFlit=(seed=13)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=26;i++)samples.push(rand()-.5);return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*25;const idx=Math.floor(pos);const t=pos-idx;const smooth=t*t*(3-2*t);const interp=samples[idx]+(samples[idx+1]-samples[idx])*smooth;return.3*env*interp}};const animalHorseGallop=(cycles=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const cyclePos=k*cycles-Math.floor(k*cycles);const bell=(c,w=.04)=>Math.exp(-((cyclePos-c)**2)/(2*w*w));return.25*env*(bell(0)+bell(.18)+bell(.36)+bell(.54))};const Animal=Object.freeze({CatPounce:animalCatPounce(),BirdFlap:animalBirdFlap(),SnakeSlither:animalSnakeSlither(),ButterflyFlit:animalButterflyFlit(),HorseGallop:animalHorseGallop()});const Progress=Object.freeze({Physics:Object.freeze({...Physics,Spring:libSpring()}),Motion:Motion,Step:Object.freeze({...Step,Steps6:libSteps()}),Math:Object.freeze({Tremor:MathExt.Tremor}),Impact:Object.freeze({Rain:Impact.Rain,Hammer:Impact.Hammer,BounceDrop:Impact.BounceDrop,ArrowHit:Impact.ArrowHit,Shatter:Impact.Shatter}),Rhythm:Object.freeze({BassDrop:Rhythm.BassDrop}),UI:Object.freeze({SuccessPop:UI.SuccessPop}),Magic:Object.freeze({ManaCharge:Magic.ManaCharge,Shield:Magic.Shield}),Animal:Object.freeze({CatPounce:Animal.CatPounce})});const Pulse=Object.freeze({Attention:Object.freeze({Ping:Attention.Ping}),Breath:Object.freeze({Deep:Breath.Deep,Sigh:Breath.Sigh}),Heart:Object.freeze({Calm:Heart.Calm}),Math:Object.freeze({JumpArc:MathExt.JumpArc,BoomerangSharp:mathBoomerang(E.Cubic.In),BoomerangSoft:mathBoomerang(E.Cubic.Out)}),Explosion:Object.freeze({Impulse:Explosion.Impulse,Flash:Explosion.Flash,Recoil:Explosion.Recoil,Implosion:Explosion.Implosion}),Impact:Object.freeze({Slap:Impact.Slap}),Rhythm:Object.freeze({Kick:Rhythm.Kick}),UI:Object.freeze({ClickSnap:UI.ClickSnap,HoverBloom:UI.HoverBloom,RippleOut:UI.RippleOut}),Magic:Object.freeze({SpellCast:Magic.SpellCast,Teleport:Magic.Teleport})});const Wave=Object.freeze({Attention:Object.freeze({Wiggle:Attention.Wiggle,Strum:Attention.Strum}),Breath:Object.freeze({Normal:Breath.Normal,Panting:Breath.Panting}),Heart:Object.freeze({Excited:Heart.Excited,LubDub:Heart.LubDub,Beat:libHeartBeat()}),Math:Object.freeze({Pendulum:MathExt.Pendulum}),Nature:Nature,Rhythm:Object.freeze({PunchCombo:Rhythm.PunchCombo,Staccato:Rhythm.Staccato,Crescendo:Rhythm.Crescendo,DunDunDun:Rhythm.DunDunDun,BellToll:Rhythm.BellToll}),UI:Object.freeze({ErrorShake:UI.ErrorShake}),Magic:Object.freeze({MagicAura:Magic.MagicAura}),Animal:Object.freeze({BirdFlap:Animal.BirdFlap,SnakeSlither:Animal.SnakeSlither,ButterflyFlit:Animal.ButterflyFlit,HorseGallop:Animal.HorseGallop})});const customEasings=Object.freeze({makeOutIn:makeOutIn,OutIn:OutIn,Progress:Progress,Pulse:Pulse,Wave:Wave,cubicBezier:cubicBezier});exports.customEasings=customEasings;exports.default=customEasings; \ No newline at end of file diff --git a/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/scriptScene.js b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/scriptScene.js new file mode 100644 index 0000000000000000000000000000000000000000..5d5f0a8bde54f7efa0912b77bb0a8298e3fb04e9 --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/scriptScene.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/three-amg-wrapper.js b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/three-amg-wrapper.js new file mode 100644 index 0000000000000000000000000000000000000000..c2037e314e032c4d36912923d4cc1258cba3ab19 --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/three-amg-wrapper.js @@ -0,0 +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;iobj.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; \ No newline at end of file diff --git a/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/tween.js b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/tween.js new file mode 100644 index 0000000000000000000000000000000000000000..690fb9e4284728629129deed5a5a3f4bcec291ed --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/tween.js @@ -0,0 +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=power1e4?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;_i0){this._tweensAddedDuringUpdate={};for(var i=0;i1){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[m1;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;itotalTime){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;ithis.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;ithis.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.xthis.max.x||box.max.ythis.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; \ No newline at end of file diff --git a/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Box3.js b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Box3.js new file mode 100644 index 0000000000000000000000000000000000000000..4100dc7442d3a622827c8a415e24557f68c491f1 --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Box3.js @@ -0,0 +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=3?array[offset+2]:0;if(xthis.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=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.xthis.max.x||box.max.ythis.max.y||box.max.zthis.max.z)}}exports.Box3=Box3; \ No newline at end of file diff --git a/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..be3b8b1334a62f5e88c45feee098063a199fca55 --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js @@ -0,0 +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=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; \ No newline at end of file diff --git a/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..af9a8a13a46500e78f082a35e18d0b5932061234 --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js @@ -0,0 +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;iObject.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;i1?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; \ No newline at end of file diff --git a/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Constants.js b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Constants.js new file mode 100644 index 0000000000000000000000000000000000000000..6b8adda19a4d67236719804f5170889b39fd4582 --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Constants.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js new file mode 100644 index 0000000000000000000000000000000000000000..29b0aad5599401be17f967ba1d48851acb70c2ac --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js @@ -0,0 +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;i0||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;i0?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;imaxX)maxX=p.x;if(p.ymaxY)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; \ No newline at end of file diff --git a/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..f3dee08bf1c089e040fcfef228902ab9a39c93cb --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Earcut.js b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Earcut.js new file mode 100644 index 0000000000000000000000000000000000000000..953abffdf38c2def26df73fed180eff8c7644ced --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Earcut.js @@ -0,0 +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;imaxX)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=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=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.x&&p.x>=mx&&hx!==p.x&&pointInTriangle(hym.x||p.x===m.x&§orContainsSector(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.xb.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;i0||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=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;i0){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;imaxX)maxX=contour[i].x;if(contour[i].ymaxY)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;layerIdx0?-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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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; \ No newline at end of file diff --git a/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Group.js b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Group.js new file mode 100644 index 0000000000000000000000000000000000000000..90c4dbef65aa04d7a3bb6b6d76ec3317ea65a228 --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Group.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");class Group extends Object3D{constructor(name="Group_w"){super(name)}dispose(){super.dispose()}}exports.Group=Group; \ No newline at end of file diff --git a/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Material.js b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Material.js new file mode 100644 index 0000000000000000000000000000000000000000..81b97053ad9d1e4b1ef05d5ac6ed992487b2ca8e --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Material.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..dcf34d4cffb9de0869382a24690f78f60dda6049 --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js new file mode 100644 index 0000000000000000000000000000000000000000..41e6cd0a0eee7dd7bc497be5deac584806b68dc3 --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Mesh.js b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Mesh.js new file mode 100644 index 0000000000000000000000000000000000000000..254d69b074e797dd34c16d7dad723bbcc3b4895d --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Mesh.js @@ -0,0 +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;imaterial,set:value=>{material=value;if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;im.dispose&&m.dispose());else if(this.material.dispose)this.material.dispose()}}}exports.MeshWrapper=MeshWrapper; \ No newline at end of file diff --git a/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..ac394f66efc4e113a7127ee0f50ec672e4c5e9eb --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Object3D.js b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Object3D.js new file mode 100644 index 0000000000000000000000000000000000000000..8532c6122f839460aab34fe88957802ff523318b --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Object3D.js @@ -0,0 +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{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&¤tScene._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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js new file mode 100644 index 0000000000000000000000000000000000000000..ba39801de50d38ec04424f3c2ebfa2ff5d28fded --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js @@ -0,0 +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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..bc595fb80ad9e7c2f4d8360c67dbef556f3d6cbe --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js @@ -0,0 +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;iy0){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; \ No newline at end of file diff --git a/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..02dc1be955bc766de744222a7e75c65bf147bb61 --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js @@ -0,0 +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&¶meters.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{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=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=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=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; \ No newline at end of file diff --git a/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Shape.js b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Shape.js new file mode 100644 index 0000000000000000000000000000000000000000..ecde48b5ceb30812c922aa5c7cfe2aa7b50cabe4 --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Shape.js @@ -0,0 +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;i0){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;i0||(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;imaxX)maxX=p.x;if(p.ymaxY)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;i0?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;ipoints.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;itwoPi)deltaAngle-=twoPi;if(deltaAngle>4;uuid[i]=chars[i===19?r&3|8:r]}}return uuid.join("")}exports.Shape=Shape; \ No newline at end of file diff --git a/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..3786abc7d64ed80b56101c4ac9d30ce9fcb8f941 --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js @@ -0,0 +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;i0){const bounds=calculateBounds(flatVertices);const vertexOffset=vertices.length/3;for(let j=0;j0){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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}function calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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; \ No newline at end of file diff --git a/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..1ea27a55fbce9fc3771c66840c068e5ff6347092 --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Texture.js b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Texture.js new file mode 100644 index 0000000000000000000000000000000000000000..35bff49d732c9884e07bfcb5682f18a860485e1f --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Texture.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Vector2.js b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Vector2.js new file mode 100644 index 0000000000000000000000000000000000000000..a30a2431264ee62cec937714dfa9e50932ddedeb --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/js/ThreeJS/wrapper/Vector2.js @@ -0,0 +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)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)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)= 1.0) return texel2; + + float p = clamp(progress, 0.0, 1.0); + + // 时间分段(按2秒总时长归一化) + float flashT = smoothstep(0.10, 0.14, p) * (1.0 - smoothstep(0.14, 0.20, p)); + float swapT = cubicInOut(clamp((p - 0.20) / 0.55, 0.0, 1.0)); // 0.4s~1.5s + float zoomT = cubicInOut(clamp((p - 0.75) / 0.25, 0.0, 1.0)); // 1.5s~2.0s + + // 场景坐标(考虑宽高比) + vec2 sceneUv = vUv - 0.5; + sceneUv.x *= ratio; + + // 卡片尺寸(近似10x10视觉比例) + vec2 halfSize = vec2(0.22 * ratio, 0.22); + + // A卡:从中心向右推出,顺时针轻微旋转 + vec2 posA = vec2(mix(0.0, 1.25 * ratio, swapT), 0.0); + float angA = -tiltAngle * swapT; + + // B卡:从右侧反向进入到中心,路径反向 + vec2 posB = vec2(mix(1.25 * ratio, 0.0, swapT), 0.0); + float angB = -tiltAngle * (1.0 - swapT); + + // B卡后段放大并去白边 + float scaleB = mix(1.0, 3.4, zoomT); + float frameVisB = 1.0 - zoomT; + + // 背景平滑过渡 + vec4 bg = mix(texel1, texel2, smoothstep(0.25, 0.85, p)); + + vec4 cardA = drawPolaroid( + tDiffuse, + sceneUv, + posA, + angA, + halfSize, + 1.0, + 1.0, + flashT * flashStrength + ); + + vec4 cardB = drawPolaroid( + tDiffuse1, + sceneUv, + posB, + angB, + halfSize, + scaleB, + frameVisB, + 0.0 + ); + + // A卡在后段淡出,避免遮挡最终放大画面 + float aFade = 1.0 - smoothstep(0.70, 0.90, p); + cardA.a *= aFade; + + // 层叠合成:背景 -> A -> B + vec3 rgb = bg.rgb; + rgb = mix(rgb, cardA.rgb, clamp(cardA.a, 0.0, 1.0)); + rgb = mix(rgb, cardB.rgb, clamp(cardB.a, 0.0, 1.0)); + + // 最终向目标纹理收敛,确保末帧稳定 + rgb = mix(rgb, texel2.rgb, smoothstep(0.92, 1.0, p)); + + return vec4(clamp(rgb, 0.0, 1.0), 1.0); +} + +void main() { + // Get the pixel color from both textures + vec4 texel1 = texture2D(tDiffuse, vUv); + vec4 texel2 = texture2D(tDiffuse1, vUv); + + // --- Transition Configuration --- + const float fadeInEnd = 0.1; + const float fadeOutStart = 0.9; + + // 1. Calculate the transition's own progress. + float transitionProgress = clamp((progress - fadeInEnd) / (fadeOutStart - fadeInEnd), 0.0, 1.0); + vec4 transitionColor = transition(texel1, texel2, transitionProgress); + + // 2. Calculate smooth blending factors for the start and end zones. + float blendInFactor = smoothstep(0.0, fadeInEnd, progress); + float blendOutFactor = smoothstep(fadeOutStart, 1.0, progress); + + // 3. Apply the blending. + vec4 finalColor = mix(texel1, transitionColor, blendInFactor); + finalColor = mix(finalColor, texel2, blendOutFactor); + + gl_FragColor = finalColor; +} +//===end_frag_code=== +`; \ No newline at end of file diff --git a/scripts/7681605099352870164/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js b/scripts/7681605099352870164/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js new file mode 100644 index 0000000000000000000000000000000000000000..2c87ab8ca97aecc86f650141dcf51ecc1ee7f46e --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js @@ -0,0 +1,8 @@ +exports.source=` +varying vec2 vUv; + +void main() { + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); +} +`; \ No newline at end of file diff --git a/scripts/7681605099352870164/AmazingFeature/xshader/Unlit.frag b/scripts/7681605099352870164/AmazingFeature/xshader/Unlit.frag new file mode 100644 index 0000000000000000000000000000000000000000..2b8ef6c235afd5362d14d87961e5b7fa2fe044b1 --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/xshader/Unlit.frag @@ -0,0 +1,25 @@ +precision highp float; +uniform sampler2D u_AlbedoTexture; +uniform vec4 u_AlbedoColor; +uniform vec2 u_Repeat; +uniform vec2 u_Offset; +uniform float u_Translucency; +uniform float u_Opacity; +varying vec2 g_vary_uv0; +void main () +{ + vec2 uv_1; + uv_1.x = g_vary_uv0.x; + uv_1.y = (g_vary_uv0.y); + lowp vec4 tmpvar_2; + tmpvar_2 = texture2D (u_AlbedoTexture, (uv_1 * u_Repeat + u_Offset)); + lowp vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2.xyz * u_AlbedoColor.xyz); + lowp float tmpvar_4; + tmpvar_4 = (tmpvar_2.w * u_Translucency); + mediump vec4 tmpvar_5; + tmpvar_5.xyz = tmpvar_3; + tmpvar_5.w = tmpvar_4; + gl_FragColor = vec4(tmpvar_5.xyz * u_Opacity, tmpvar_5.w * u_Opacity); +} + diff --git a/scripts/7681605099352870164/AmazingFeature/xshader/Unlit.vert b/scripts/7681605099352870164/AmazingFeature/xshader/Unlit.vert new file mode 100644 index 0000000000000000000000000000000000000000..64a27d816e6146a0fb85643a9991207e5fda2acb --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/xshader/Unlit.vert @@ -0,0 +1,35 @@ +precision highp float; +attribute vec3 attPosition; +attribute vec2 attTexcoord0; + +//#define AMAZING_USE_BONES + +#ifdef AMAZING_USE_BONES +attribute vec4 attBoneIds; +attribute vec4 attWeights; +const int MAX_BONES = 50; +uniform mat4 u_Palatte[MAX_BONES]; +#endif + +uniform mat4 u_Model; +uniform mat4 u_MVP; +varying vec2 g_vary_uv0; + + + +void main () +{ + vec3 modelPostiton = attPosition; + vec4 homogeneous_pos = vec4(attPosition, 1.0); + g_vary_uv0 = attTexcoord0; + +#ifdef AMAZING_USE_BONES + mat4 boneTransform = u_Palatte[int(attBoneIds.x)] * attWeights.x; + boneTransform += u_Palatte[int(attBoneIds.y)] * attWeights.y; + boneTransform += u_Palatte[int(attBoneIds.z)] * attWeights.z; + boneTransform += u_Palatte[int(attBoneIds.w)] * attWeights.w; + gl_Position = u_MVP * boneTransform * homogeneous_pos; +#else + gl_Position = u_MVP * homogeneous_pos; +#endif +} diff --git a/scripts/7681605099352870164/AmazingFeature/xshader/noface.frag b/scripts/7681605099352870164/AmazingFeature/xshader/noface.frag new file mode 100644 index 0000000000000000000000000000000000000000..88e9ec343761b2395bae9430e6e55466b0367d67 --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/xshader/noface.frag @@ -0,0 +1,7 @@ +precision lowp float; +varying highp vec2 uv0; +uniform sampler2D u_albedo; +void main() +{ + gl_FragColor = texture2D(u_albedo, uv0); +} diff --git a/scripts/7681605099352870164/AmazingFeature/xshader/noface.vert b/scripts/7681605099352870164/AmazingFeature/xshader/noface.vert new file mode 100644 index 0000000000000000000000000000000000000000..16450a4b5880cf8d83528ea1ae0f47d10b2ab1d8 --- /dev/null +++ b/scripts/7681605099352870164/AmazingFeature/xshader/noface.vert @@ -0,0 +1,12 @@ +precision highp float; + +attribute vec2 position; +attribute vec2 texcoord0; +varying vec2 uv0; +//uniform mat4 u_MVP; +void main() +{ + //gl_Position = u_MVP * position; + gl_Position = sign(vec4(position.xy, 0.0, 1.0)); + uv0 = texcoord0; +} diff --git a/scripts/7681605099352870164/config.json b/scripts/7681605099352870164/config.json new file mode 100644 index 0000000000000000000000000000000000000000..557ff9895b4c8c8a7d91baae310b40001cd6c20d --- /dev/null +++ b/scripts/7681605099352870164/config.json @@ -0,0 +1,16 @@ +{ + "ae_tool": "AmazingEditor", + "bALG_BACH_CONFIG": false, + "effect": { + "Link": [ + { + "path": "AmazingFeature/", + "type": "AmazingFeature", + "zorder": 8011 + } + ] + }, + "name": "AlgorithmGraph_7bdbHcdcscQkbEdcc9cIlcNdvTdtb", + "version": "13.4.0", + "item_source": "user_post_pc_lumi_ai" +} \ No newline at end of file diff --git a/scripts/7681605099352870164/extra.json b/scripts/7681605099352870164/extra.json new file mode 100644 index 0000000000000000000000000000000000000000..54fa4509a5dd89dd1fe3bf1b103bb7a95ac88b7f --- /dev/null +++ b/scripts/7681605099352870164/extra.json @@ -0,0 +1,43 @@ +{ + "transition": { + "defaultDura": 2.0, + "isOverlap": true + }, + "External_Producer": true, + "setting": { + "lumiai_material_properties": [ + { + "effect_key": "progress", + "effect_key_cn": "\u6548\u679c\u8fdb\u5ea6", + "type": "float", + "default": 0, + "min": 0, + "max": 1 + }, + { + "effect_key": "borderSize", + "effect_key_cn": "\u8fb9\u6846\u5c3a\u5bf8", + "type": "float", + "default": 0.1, + "min": 0.02, + "max": 0.22 + }, + { + "effect_key": "tiltAngle", + "effect_key_cn": "\u503e\u659c\u89d2\u5ea6", + "type": "float", + "default": 0.14, + "min": 0, + "max": 0.35 + }, + { + "effect_key": "flashStrength", + "effect_key_cn": "\u95ea\u5149\u5f3a\u5ea6", + "type": "float", + "default": 0.65, + "min": 0, + "max": 1 + } + ] + } +} \ No newline at end of file diff --git a/scripts/7681618406465916181/AmazingFeature/content.json b/scripts/7681618406465916181/AmazingFeature/content.json new file mode 100644 index 0000000000000000000000000000000000000000..df43720515b1b6981b24c4268c902195fa613d43 --- /dev/null +++ b/scripts/7681618406465916181/AmazingFeature/content.json @@ -0,0 +1,7 @@ +{ + "ae_tool" : "AmazingEditor", + "content" : {}, + "needblend" : false, + "tag" : "AMG_1515088281693380358513659446614427937212", + "version" : "1.0" +} \ No newline at end of file diff --git a/scripts/7681618406465916181/AmazingFeature/js/JSSys.js b/scripts/7681618406465916181/AmazingFeature/js/JSSys.js new file mode 100644 index 0000000000000000000000000000000000000000..bbcbf36f0f75c1beebe88c33dd0464bb4477158e --- /dev/null +++ b/scripts/7681618406465916181/AmazingFeature/js/JSSys.js @@ -0,0 +1,89 @@ +const effect_api = "undefined" != typeof effect ? effect : "undefined" != typeof tt ? tt : "undefined" != typeof lynx ? lynx : {}; +const Amaz = effect_api.getAmaz(); + +const { ScriptScene } = require('./ThreeJS/scriptScene'); +const THREE = require('./ThreeJS/three-amg-wrapper').THREE; + +class JSSys { + constructor() { + this.name = "JSSys"; + this.comps = {} + this.compsdirty = true + } + + onComponentAdded(comp) { + // console.log("running:JSSys:onComponentAdded"); + } + onComponentRemoved(comp) { + // console.log("running:JSSys:onComponentRemoved"); + } + + onStart() { + console.log("running:JSSys:onStart"); + + this.renderTexture = this.scene.assetMgr.SyncLoad('rt/outputTex.rt'); + + // 添加光源到场景 + console.log('JSSys: 创建ScriptScene实例'); + this.scriptScene = new ScriptScene(this.scene); + + this.input = Amaz.AmazingManager.getSingleton("Input"); + const builtinObject = Amaz.AmazingManager.getSingleton("BuiltinObject"); + + if (builtinObject.getUserTexture("#TransitionInput0") && builtinObject.getUserTexture("#TransitionInput1")) { + this.scriptScene.texture1 = new THREE.Texture(); + this.scriptScene.texture1.setImage(builtinObject.getUserTexture("#TransitionInput0")); + this.scriptScene.texture2 = new THREE.Texture(); + this.scriptScene.texture2.setImage(builtinObject.getUserTexture("#TransitionInput1")); + console.log("JSSys: 获取到纹理"); + } + else + { + this.scriptScene.texture1 = new THREE.Texture(); + this.scriptScene.texture1.setImage(this.scene.assetMgr.SyncLoad('image/Sample1.jpg')); + this.scriptScene.texture2 = new THREE.Texture(); + this.scriptScene.texture2.setImage(this.scene.assetMgr.SyncLoad('image/Sample2.jpg')); + console.log("JSSys: 未获取到纹理,使用默认纹理"); + } + + this.scriptScene.setupScene(); + // 初始化后处理效果 + if (this.scriptScene.initPostProcessing != null) { + this.scriptScene.initPostProcessing(); + } + } + + onUpdate(deltaTime) { + this.time = this.input.getFrameTimestamp(); + // this.time = this.time % 2; + // this.time = this.time / 2.0; + this.scriptScene.seekToTime(this.time * this.scriptScene.Duration); + // this.scriptScene.updateScene(); + } + onLateUpdate(deltaTime) { + // console.log("running:JSSys:onLateUpdate"); + this.scriptScene.scene.seekToTime(this.time * this.scriptScene.Duration); + } + + onEvent(event) { + console.log("running:JSSys:onEvent"); + if (event.type == Amaz.EventType.VIEWER) { + // console.log("JSSys: 窗口大小改变"); + console.log("renderTexture.width",this.renderTexture.width); + console.log("renderTexture.height",this.renderTexture.height); + + window.innerWidth = this.renderTexture.width; + window.innerHeight = this.renderTexture.height; + // console.log("JSSys: 窗口大小改变"); + this.scriptScene.handleResize(); + } + } + + onDestroy() { + // console.log("running:JSSys:onDestroy"); + this.scriptScene.destroy(); + } +} + +exports.JSSys = JSSys; + diff --git a/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/EffectComposer.js b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/EffectComposer.js new file mode 100644 index 0000000000000000000000000000000000000000..e7d8fd7a3f3978d9da1a9bf29af1854806f60014 --- /dev/null +++ b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/EffectComposer.js @@ -0,0 +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{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-6*k)*Math.cos(12*k)};const springStiff=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(18*k)};const dampedOscillation=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(10*k)};const Physics=Object.freeze({SpringSoft:springSoft,SpringStiff:springStiff,DampedOscillation:dampedOscillation});const anticipate=k=>{if(k<=0)return 0;if(k>=1)return 1;const pullback=.1;if(k<.3){const p=k/.3;return-pullback*p*(2-p)}const p=(k-.3)/.7;return-pullback+(1+pullback)*p*p*(3-2*p)};const overshootFactory=peak=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return peak*p*(2-p)}const p=(k-.6)/.4;return peak+(1-peak)*(1-Math.pow(1-p,3))};const overshoot110=overshootFactory(1.1);const overshoot125=overshootFactory(1.25);const snapBack=k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return 1.05*(1-Math.pow(1-p,3))}const p=(k-.6)/.4;return 1.05-.05*p*p*(3-2*p)};const swing=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.cos(1.5*Math.PI*k)*Math.exp(-2.5*k)};const Motion=Object.freeze({Anticipate:anticipate,Overshoot110:overshoot110,Overshoot125:overshoot125,SnapBack:snapBack,Swing:swing});const makeStep=(n,jumpTerm="end")=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(jumpTerm==="start")return Math.ceil(k*n)/n;return Math.floor(k*n)/n};const Step=Object.freeze({Steps4End:makeStep(4,"end"),Steps8End:makeStep(8,"end"),Steps12End:makeStep(12,"end")});function buildCubicBezier(x1,y1,x2,y2){const cx=3*x1,bx=3*(x2-x1)-cx,ax=1-cx-bx;const cy=3*y1,by=3*(y2-y1)-cy,ay=1-cy-by;const sampleX=s=>((ax*s+bx)*s+cx)*s;const sampleY=s=>((ay*s+by)*s+cy)*s;const sampleDX=s=>(3*ax*s+2*bx)*s+cx;const solveS=x=>{let s=x;for(let i=0;i<8;i++){const cur=sampleX(s)-x;if(Math.abs(cur)<1e-6)return s;const d=sampleDX(s);if(Math.abs(d)<1e-6)break;s-=cur/d;if(s<0)s=0;if(s>1)s=1}let lo=0,hi=1;for(let i=0;i<32&&hi-lo>1e-6;i++){const mid=(lo+hi)/2;if(sampleX(mid){if(k<=0)return 0;if(k>=1)return 1;return sampleY(solveS(k))}}const BEZIER_PRESETS=Object.freeze({"Material.Standard":[.4,0,.2,1],"Material.Accelerate":[.4,0,1,1],"Material.Decelerate":[0,0,.2,1],"CSS.Ease":[.25,.1,.25,1]});const _bezierCache=new Map;function _cachedBezier(x1,y1,x2,y2){const key=x1+","+y1+","+x2+","+y2;let fn=_bezierCache.get(key);if(!fn){fn=buildCubicBezier(x1,y1,x2,y2);_bezierCache.set(key,fn)}return fn}function cubicBezier(a,b,c,d){if(typeof a==="string"){let preset=BEZIER_PRESETS[a];if(!preset){console.warn("[customEasings.cubicBezier] unknown preset, falling back to Material.Standard:",a);preset=BEZIER_PRESETS["Material.Standard"]}return _cachedBezier(preset[0],preset[1],preset[2],preset[3])}const clamp=(v,lo,hi)=>Math.max(lo,Math.min(hi,v));const x1=clamp(a,0,1);const y1=clamp(b,-.5,1.5);const x2=clamp(c,0,1);const y2=clamp(d,-.5,1.5);return _cachedBezier(x1,y1,x2,y2)}const libSpring=({stiffness=180,damping=12,mass=1}={})=>{const DT=1/240;const T=1.5;let x=0,v=0;const samples=[];for(let t=0;t<=T;t+=DT){const force=-stiffness*(x-1)-damping*v;v+=force/mass*DT;x+=v*DT;samples.push({t:t,x:x})}let T_end=T;for(let i=samples.length-1;i>=0;i--){if(Math.abs(samples[i].x-1)>.01){T_end=samples[i].t;break}}return k=>{if(k<=0)return 0;if(k>=1)return 1;const t=k*T_end;const idx=Math.min(samples.length-1,Math.floor(t/DT));return samples[idx].x}};const libHeartBeat=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c)=>Math.exp(-((t-c)**2)/(2*.07*.07));return peak*(bell(k,.2)+bell(k,.5))};const libSteps=(n=6)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return Math.floor(k*n)/n};const attentionPing=(peak=.35,decay=2)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(Math.PI*k)*Math.exp(-decay*k)};const attentionWiggle=(count=4,amplitude=.25)=>k=>{if(k<=0||k>=1)return 0;const env=1-k;return amplitude*env*Math.sin(k*Math.PI*2*count)};const attentionStrum=(notes=4,peak=.4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*.05*.05))}return peak*sum}};const Attention=Object.freeze({Ping:attentionPing(),Wiggle:attentionWiggle(),Strum:attentionStrum()});const breathNormal=(cycles=2,peak=.15)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(k*Math.PI*2*cycles)*Math.sin(k*Math.PI)};const breathDeep=(peak=.3,riseRatio=.35,holdRatio=.15)=>{const holdEnd=riseRatio+holdRatio;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const envelope=Math.sin(k*Math.PI);const wave=.5+.5*Math.sin(k*Math.PI*2*cycles-Math.PI/2);return peak*envelope*wave};const breathSigh=(peak=.25,riseRatio=.2)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return peak*Math.exp(-((k-center)**2)/(2*width*width))};const heartExcited=(beats=4,peak=.3,width=.04)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*width*width))}return peak*sum}};const heartLubDub=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return peak*(bell(k,.25,.045)+.6*bell(k,.42,.03))};const Heart=Object.freeze({Calm:heartCalm(),Excited:heartExcited(),LubDub:heartLubDub()});const mathJumpArc=()=>k=>{if(k<=0||k>=1)return 0;return 4*k*(1-k)};const mathPendulum=(damping=3,freq=2.5)=>k=>{if(k<=0||k>=1)return 0;return Math.sin(k*Math.PI)*Math.exp(-damping*k)*Math.cos(freq*Math.PI*k)};const mathTremor=(amplitude=.04,freq=22)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return k+amplitude*Math.sin(k*Math.PI*2*freq)};const mathBoomerang=fn=>k=>{if(k<=0||k>=1)return 0;return k<.5?fn(k*2):fn(2-k*2)};const MathExt=Object.freeze({JumpArc:mathJumpArc(),Pendulum:mathPendulum(),Tremor:mathTremor()});const explosionImpulse=(sharpness=6)=>{const tail=sharpness*Math.exp(1-sharpness);return k=>{if(k<=0||k>=1)return 0;const h=sharpness*k;return h*Math.exp(1-h)-tail*k}};const explosionFlash=(rise=.05,decay=5)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return-Math.exp(-decay*k)*Math.cos(freq*Math.PI*k)};const explosionImplosion=(charge=.3,depth=.4,burstPeak=1.2)=>{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const w=Math.sin(k*Math.PI*2*cycles)+.5*Math.sin(k*Math.PI*2*cycles*1.5+1.2)+.25*Math.sin(k*Math.PI*2*cycles*3+2.4);return amplitude*env*w*.6};const natureFlicker=(rate=15,intensity=.2,seed=7)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=rate+1;i++)samples.push(rand());return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*rate;const idx=Math.floor(pos);const t=pos-idx;const a=samples[idx];const b=samples[idx+1];const interp=a+(b-a)*t;return intensity*env*(interp-.5)*2}};const natureGust=(gusts=3,peak=.25)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*.08*.08))}return peak*sum/gusts*1.8}};const Nature=Object.freeze({Wave:natureWave(),Flicker:natureFlicker(),Gust:natureGust()});const impactRain=(impactAt=.7,rippleAmp=.08)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const liftEnd=.35,strikeEnd=.6;return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return t*t}const t=(k-.4)/.6;const env=Math.exp(-2.5*t);const wave=Math.abs(Math.sin(t*Math.PI*bounces));return 1-env*wave*rebound};const impactSlap=(contactAt=.3,holdRatio=.1)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return.4*Math.pow(t,2.5)}if(k<.48){const t=(k-.4)/.08;return.4-.2*t}if(k<.52){const t=(k-.48)/.04;return.2+.8*t}const t=(k-.52)/.48;return 1-.04*Math.sin(t*Math.PI*8)*(1-t)};const rhythmPunchCombo=(peak=.4)=>{const pattern=[{c:.15,w:.04,a:.75},{c:.35,w:.04,a:.75},{c:.7,w:.055,a:1}];return k=>{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of pattern){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return peak*sum}};const rhythmStaccato=(beats=4,duty=.3)=>k=>{if(k<=0||k>=1)return 0;const beatLen=1/beats;const phase=k/beatLen-Math.floor(k/beatLen);if(phase>duty)return 0;const t=phase/duty;return Math.sin(t*Math.PI)};const rhythmKick=(peak=1.2)=>k=>{if(k<=0||k>=1)return 0;if(k<.05)return peak*k/.05;const t=(k-.05)/.95;return peak*Math.exp(-4*t)};const rhythmCrescendo=(beats=4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return sum}};const rhythmDunDunDun=()=>{const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return k=>{if(k<=0||k>=1)return 0;return.3*bell(k,.15,.025)+.6*bell(k,.35,.03)+1*bell(k,.68,.09)}};const rhythmBellToll=(decay=3,freq=8)=>{const strike=.05;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.2){const t=k/.2;return-pressDepth*Math.sin(t*Math.PI/2)}if(k<.5){const t=(k-.2)/.3;return-pressDepth+(pressDepth+reboundPeak)*(1-Math.pow(1-t,3))}const t=(k-.5)/.5;return reboundPeak*Math.exp(-4*t)*Math.cos(t*Math.PI*3)};const uiHoverBloom=(riseRatio=.2,fallRatio=.3)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=1-k;const raw=Math.sin(k*Math.PI*2*count);const clipped=Math.sign(raw)*Math.min(1,Math.abs(raw)*1.8);return amplitude*env*clipped};const uiSuccessPop=(overshoot=.2)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return(1+overshoot)*(1-Math.pow(1-t,2))}const t=(k-.4)/.6;return 1+overshoot*Math.exp(-5*t)*Math.cos(t*Math.PI*3)};const uiRippleOut=()=>k=>{if(k<=0||k>=1)return 0;return 6.75*k*Math.pow(1-k,2)};const UI=Object.freeze({ClickSnap:uiClickSnap(),HoverBloom:uiHoverBloom(),ErrorShake:uiErrorShake(),SuccessPop:uiSuccessPop(),RippleOut:uiRippleOut()});const magicManaCharge=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;const base=(Math.exp(3*k)-1)/(Math.exp(3)-1);const pulse=.04*Math.sin(k*Math.PI*8)*k;return base+pulse};const magicSpellCast=(chargeEnd=.4)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.45){const t=k/.45;return t*t*t}if(k<.55)return 1;const t=(k-.55)/.45;return Math.pow(1-t,3)};const magicShield=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.3){const t=k/.3;return 1.2*(1-Math.pow(1-t,2))}if(k<.6){const t=(k-.3)/.3;return 1.2-.2*t}const t=(k-.6)/.4;return 1+.03*Math.sin(t*Math.PI*3)};const magicAura=(peak=.15)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const fundamental=.6*Math.sin(k*Math.PI*2);const harmonic=.3*Math.sin(k*Math.PI*4+1);const overtone=.1*Math.sin(k*Math.PI*6+2);return peak*env*(fundamental+harmonic+overtone)};const Magic=Object.freeze({ManaCharge:magicManaCharge(),SpellCast:magicSpellCast(),Teleport:magicTeleport(),Shield:magicShield(),MagicAura:magicAura()});const animalCatPounce=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.2){const t=k/.2;return-.2*Math.sin(t*Math.PI)}if(k<.3){const t=(k-.2)/.1;return.5*t*t}if(k<.8){const t=(k-.3)/.5;return.5+.5*t+.2*Math.sin(t*Math.PI)}const t=(k-.8)/.2;return 1+.05*Math.sin(t*Math.PI)};const animalBirdFlap=(flaps=4)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const phase=k*Math.PI*2*flaps;const wave=Math.sin(phase)-.3*Math.sin(phase*2);return.2*env*wave};const animalSnakeSlither=(waves=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const wave=Math.sin(k*Math.PI*2*waves);return.2*env*wave};const animalButterflyFlit=(seed=13)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=26;i++)samples.push(rand()-.5);return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*25;const idx=Math.floor(pos);const t=pos-idx;const smooth=t*t*(3-2*t);const interp=samples[idx]+(samples[idx+1]-samples[idx])*smooth;return.3*env*interp}};const animalHorseGallop=(cycles=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const cyclePos=k*cycles-Math.floor(k*cycles);const bell=(c,w=.04)=>Math.exp(-((cyclePos-c)**2)/(2*w*w));return.25*env*(bell(0)+bell(.18)+bell(.36)+bell(.54))};const Animal=Object.freeze({CatPounce:animalCatPounce(),BirdFlap:animalBirdFlap(),SnakeSlither:animalSnakeSlither(),ButterflyFlit:animalButterflyFlit(),HorseGallop:animalHorseGallop()});const Progress=Object.freeze({Physics:Object.freeze({...Physics,Spring:libSpring()}),Motion:Motion,Step:Object.freeze({...Step,Steps6:libSteps()}),Math:Object.freeze({Tremor:MathExt.Tremor}),Impact:Object.freeze({Rain:Impact.Rain,Hammer:Impact.Hammer,BounceDrop:Impact.BounceDrop,ArrowHit:Impact.ArrowHit,Shatter:Impact.Shatter}),Rhythm:Object.freeze({BassDrop:Rhythm.BassDrop}),UI:Object.freeze({SuccessPop:UI.SuccessPop}),Magic:Object.freeze({ManaCharge:Magic.ManaCharge,Shield:Magic.Shield}),Animal:Object.freeze({CatPounce:Animal.CatPounce})});const Pulse=Object.freeze({Attention:Object.freeze({Ping:Attention.Ping}),Breath:Object.freeze({Deep:Breath.Deep,Sigh:Breath.Sigh}),Heart:Object.freeze({Calm:Heart.Calm}),Math:Object.freeze({JumpArc:MathExt.JumpArc,BoomerangSharp:mathBoomerang(E.Cubic.In),BoomerangSoft:mathBoomerang(E.Cubic.Out)}),Explosion:Object.freeze({Impulse:Explosion.Impulse,Flash:Explosion.Flash,Recoil:Explosion.Recoil,Implosion:Explosion.Implosion}),Impact:Object.freeze({Slap:Impact.Slap}),Rhythm:Object.freeze({Kick:Rhythm.Kick}),UI:Object.freeze({ClickSnap:UI.ClickSnap,HoverBloom:UI.HoverBloom,RippleOut:UI.RippleOut}),Magic:Object.freeze({SpellCast:Magic.SpellCast,Teleport:Magic.Teleport})});const Wave=Object.freeze({Attention:Object.freeze({Wiggle:Attention.Wiggle,Strum:Attention.Strum}),Breath:Object.freeze({Normal:Breath.Normal,Panting:Breath.Panting}),Heart:Object.freeze({Excited:Heart.Excited,LubDub:Heart.LubDub,Beat:libHeartBeat()}),Math:Object.freeze({Pendulum:MathExt.Pendulum}),Nature:Nature,Rhythm:Object.freeze({PunchCombo:Rhythm.PunchCombo,Staccato:Rhythm.Staccato,Crescendo:Rhythm.Crescendo,DunDunDun:Rhythm.DunDunDun,BellToll:Rhythm.BellToll}),UI:Object.freeze({ErrorShake:UI.ErrorShake}),Magic:Object.freeze({MagicAura:Magic.MagicAura}),Animal:Object.freeze({BirdFlap:Animal.BirdFlap,SnakeSlither:Animal.SnakeSlither,ButterflyFlit:Animal.ButterflyFlit,HorseGallop:Animal.HorseGallop})});const customEasings=Object.freeze({makeOutIn:makeOutIn,OutIn:OutIn,Progress:Progress,Pulse:Pulse,Wave:Wave,cubicBezier:cubicBezier});exports.customEasings=customEasings;exports.default=customEasings; \ No newline at end of file diff --git a/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/scriptScene.js b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/scriptScene.js new file mode 100644 index 0000000000000000000000000000000000000000..5d5f0a8bde54f7efa0912b77bb0a8298e3fb04e9 --- /dev/null +++ b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/scriptScene.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/three-amg-wrapper.js b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/three-amg-wrapper.js new file mode 100644 index 0000000000000000000000000000000000000000..c2037e314e032c4d36912923d4cc1258cba3ab19 --- /dev/null +++ b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/three-amg-wrapper.js @@ -0,0 +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;iobj.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; \ No newline at end of file diff --git a/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/tween.js b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/tween.js new file mode 100644 index 0000000000000000000000000000000000000000..690fb9e4284728629129deed5a5a3f4bcec291ed --- /dev/null +++ b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/tween.js @@ -0,0 +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=power1e4?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;_i0){this._tweensAddedDuringUpdate={};for(var i=0;i1){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[m1;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;itotalTime){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;ithis.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;ithis.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.xthis.max.x||box.max.ythis.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; \ No newline at end of file diff --git a/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Box3.js b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Box3.js new file mode 100644 index 0000000000000000000000000000000000000000..4100dc7442d3a622827c8a415e24557f68c491f1 --- /dev/null +++ b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Box3.js @@ -0,0 +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=3?array[offset+2]:0;if(xthis.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=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.xthis.max.x||box.max.ythis.max.y||box.max.zthis.max.z)}}exports.Box3=Box3; \ No newline at end of file diff --git a/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..be3b8b1334a62f5e88c45feee098063a199fca55 --- /dev/null +++ b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js @@ -0,0 +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=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; \ No newline at end of file diff --git a/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..af9a8a13a46500e78f082a35e18d0b5932061234 --- /dev/null +++ b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js @@ -0,0 +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;iObject.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;i1?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; \ No newline at end of file diff --git a/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Constants.js b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Constants.js new file mode 100644 index 0000000000000000000000000000000000000000..6b8adda19a4d67236719804f5170889b39fd4582 --- /dev/null +++ b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Constants.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js new file mode 100644 index 0000000000000000000000000000000000000000..29b0aad5599401be17f967ba1d48851acb70c2ac --- /dev/null +++ b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js @@ -0,0 +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;i0||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;i0?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;imaxX)maxX=p.x;if(p.ymaxY)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; \ No newline at end of file diff --git a/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..f3dee08bf1c089e040fcfef228902ab9a39c93cb --- /dev/null +++ b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Earcut.js b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Earcut.js new file mode 100644 index 0000000000000000000000000000000000000000..953abffdf38c2def26df73fed180eff8c7644ced --- /dev/null +++ b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Earcut.js @@ -0,0 +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;imaxX)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=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=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.x&&p.x>=mx&&hx!==p.x&&pointInTriangle(hym.x||p.x===m.x&§orContainsSector(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.xb.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;i0||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=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;i0){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;imaxX)maxX=contour[i].x;if(contour[i].ymaxY)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;layerIdx0?-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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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; \ No newline at end of file diff --git a/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Group.js b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Group.js new file mode 100644 index 0000000000000000000000000000000000000000..90c4dbef65aa04d7a3bb6b6d76ec3317ea65a228 --- /dev/null +++ b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Group.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");class Group extends Object3D{constructor(name="Group_w"){super(name)}dispose(){super.dispose()}}exports.Group=Group; \ No newline at end of file diff --git a/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Material.js b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Material.js new file mode 100644 index 0000000000000000000000000000000000000000..81b97053ad9d1e4b1ef05d5ac6ed992487b2ca8e --- /dev/null +++ b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Material.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..dcf34d4cffb9de0869382a24690f78f60dda6049 --- /dev/null +++ b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js new file mode 100644 index 0000000000000000000000000000000000000000..41e6cd0a0eee7dd7bc497be5deac584806b68dc3 --- /dev/null +++ b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Mesh.js b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Mesh.js new file mode 100644 index 0000000000000000000000000000000000000000..254d69b074e797dd34c16d7dad723bbcc3b4895d --- /dev/null +++ b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Mesh.js @@ -0,0 +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;imaterial,set:value=>{material=value;if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;im.dispose&&m.dispose());else if(this.material.dispose)this.material.dispose()}}}exports.MeshWrapper=MeshWrapper; \ No newline at end of file diff --git a/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..ac394f66efc4e113a7127ee0f50ec672e4c5e9eb --- /dev/null +++ b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Object3D.js b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Object3D.js new file mode 100644 index 0000000000000000000000000000000000000000..8532c6122f839460aab34fe88957802ff523318b --- /dev/null +++ b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Object3D.js @@ -0,0 +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{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&¤tScene._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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js new file mode 100644 index 0000000000000000000000000000000000000000..ba39801de50d38ec04424f3c2ebfa2ff5d28fded --- /dev/null +++ b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js @@ -0,0 +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&¤tScene._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; \ No newline at end of file diff --git a/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..bc595fb80ad9e7c2f4d8360c67dbef556f3d6cbe --- /dev/null +++ b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js @@ -0,0 +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;iy0){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; \ No newline at end of file diff --git a/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..02dc1be955bc766de744222a7e75c65bf147bb61 --- /dev/null +++ b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js @@ -0,0 +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&¶meters.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{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=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=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=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; \ No newline at end of file diff --git a/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Shape.js b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Shape.js new file mode 100644 index 0000000000000000000000000000000000000000..ecde48b5ceb30812c922aa5c7cfe2aa7b50cabe4 --- /dev/null +++ b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Shape.js @@ -0,0 +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;i0){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;i0||(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;imaxX)maxX=p.x;if(p.ymaxY)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;i0?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;ipoints.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;itwoPi)deltaAngle-=twoPi;if(deltaAngle>4;uuid[i]=chars[i===19?r&3|8:r]}}return uuid.join("")}exports.Shape=Shape; \ No newline at end of file diff --git a/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..3786abc7d64ed80b56101c4ac9d30ce9fcb8f941 --- /dev/null +++ b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js @@ -0,0 +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;i0){const bounds=calculateBounds(flatVertices);const vertexOffset=vertices.length/3;for(let j=0;j0){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;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)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;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)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;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}function calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)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; \ No newline at end of file diff --git a/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..1ea27a55fbce9fc3771c66840c068e5ff6347092 --- /dev/null +++ b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Texture.js b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Texture.js new file mode 100644 index 0000000000000000000000000000000000000000..35bff49d732c9884e07bfcb5682f18a860485e1f --- /dev/null +++ b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Texture.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Vector2.js b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Vector2.js new file mode 100644 index 0000000000000000000000000000000000000000..a30a2431264ee62cec937714dfa9e50932ddedeb --- /dev/null +++ b/scripts/7681618406465916181/AmazingFeature/js/ThreeJS/wrapper/Vector2.js @@ -0,0 +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)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)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){if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-6*k)*Math.cos(12*k)};const springStiff=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(18*k)};const dampedOscillation=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(10*k)};const Physics=Object.freeze({SpringSoft:springSoft,SpringStiff:springStiff,DampedOscillation:dampedOscillation});const anticipate=k=>{if(k<=0)return 0;if(k>=1)return 1;const pullback=.1;if(k<.3){const p=k/.3;return-pullback*p*(2-p)}const p=(k-.3)/.7;return-pullback+(1+pullback)*p*p*(3-2*p)};const overshootFactory=peak=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return peak*p*(2-p)}const p=(k-.6)/.4;return peak+(1-peak)*(1-Math.pow(1-p,3))};const overshoot110=overshootFactory(1.1);const overshoot125=overshootFactory(1.25);const snapBack=k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return 1.05*(1-Math.pow(1-p,3))}const p=(k-.6)/.4;return 1.05-.05*p*p*(3-2*p)};const swing=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.cos(1.5*Math.PI*k)*Math.exp(-2.5*k)};const Motion=Object.freeze({Anticipate:anticipate,Overshoot110:overshoot110,Overshoot125:overshoot125,SnapBack:snapBack,Swing:swing});const makeStep=(n,jumpTerm="end")=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(jumpTerm==="start")return Math.ceil(k*n)/n;return Math.floor(k*n)/n};const Step=Object.freeze({Steps4End:makeStep(4,"end"),Steps8End:makeStep(8,"end"),Steps12End:makeStep(12,"end")});function buildCubicBezier(x1,y1,x2,y2){const cx=3*x1,bx=3*(x2-x1)-cx,ax=1-cx-bx;const cy=3*y1,by=3*(y2-y1)-cy,ay=1-cy-by;const sampleX=s=>((ax*s+bx)*s+cx)*s;const sampleY=s=>((ay*s+by)*s+cy)*s;const sampleDX=s=>(3*ax*s+2*bx)*s+cx;const solveS=x=>{let s=x;for(let i=0;i<8;i++){const cur=sampleX(s)-x;if(Math.abs(cur)<1e-6)return s;const d=sampleDX(s);if(Math.abs(d)<1e-6)break;s-=cur/d;if(s<0)s=0;if(s>1)s=1}let lo=0,hi=1;for(let i=0;i<32&&hi-lo>1e-6;i++){const mid=(lo+hi)/2;if(sampleX(mid){if(k<=0)return 0;if(k>=1)return 1;return sampleY(solveS(k))}}const BEZIER_PRESETS=Object.freeze({"Material.Standard":[.4,0,.2,1],"Material.Accelerate":[.4,0,1,1],"Material.Decelerate":[0,0,.2,1],"CSS.Ease":[.25,.1,.25,1]});const _bezierCache=new Map;function _cachedBezier(x1,y1,x2,y2){const key=x1+","+y1+","+x2+","+y2;let fn=_bezierCache.get(key);if(!fn){fn=buildCubicBezier(x1,y1,x2,y2);_bezierCache.set(key,fn)}return fn}function cubicBezier(a,b,c,d){if(typeof a==="string"){let preset=BEZIER_PRESETS[a];if(!preset){console.warn("[customEasings.cubicBezier] unknown preset, falling back to Material.Standard:",a);preset=BEZIER_PRESETS["Material.Standard"]}return _cachedBezier(preset[0],preset[1],preset[2],preset[3])}const clamp=(v,lo,hi)=>Math.max(lo,Math.min(hi,v));const x1=clamp(a,0,1);const y1=clamp(b,-.5,1.5);const x2=clamp(c,0,1);const y2=clamp(d,-.5,1.5);return _cachedBezier(x1,y1,x2,y2)}const libSpring=({stiffness=180,damping=12,mass=1}={})=>{const DT=1/240;const T=1.5;let x=0,v=0;const samples=[];for(let t=0;t<=T;t+=DT){const force=-stiffness*(x-1)-damping*v;v+=force/mass*DT;x+=v*DT;samples.push({t:t,x:x})}let T_end=T;for(let i=samples.length-1;i>=0;i--){if(Math.abs(samples[i].x-1)>.01){T_end=samples[i].t;break}}return k=>{if(k<=0)return 0;if(k>=1)return 1;const t=k*T_end;const idx=Math.min(samples.length-1,Math.floor(t/DT));return samples[idx].x}};const libHeartBeat=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c)=>Math.exp(-((t-c)**2)/(2*.07*.07));return peak*(bell(k,.2)+bell(k,.5))};const libSteps=(n=6)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return Math.floor(k*n)/n};const attentionPing=(peak=.35,decay=2)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(Math.PI*k)*Math.exp(-decay*k)};const attentionWiggle=(count=4,amplitude=.25)=>k=>{if(k<=0||k>=1)return 0;const env=1-k;return amplitude*env*Math.sin(k*Math.PI*2*count)};const attentionStrum=(notes=4,peak=.4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*.05*.05))}return peak*sum}};const Attention=Object.freeze({Ping:attentionPing(),Wiggle:attentionWiggle(),Strum:attentionStrum()});const breathNormal=(cycles=2,peak=.15)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(k*Math.PI*2*cycles)*Math.sin(k*Math.PI)};const breathDeep=(peak=.3,riseRatio=.35,holdRatio=.15)=>{const holdEnd=riseRatio+holdRatio;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const envelope=Math.sin(k*Math.PI);const wave=.5+.5*Math.sin(k*Math.PI*2*cycles-Math.PI/2);return peak*envelope*wave};const breathSigh=(peak=.25,riseRatio=.2)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return peak*Math.exp(-((k-center)**2)/(2*width*width))};const heartExcited=(beats=4,peak=.3,width=.04)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*width*width))}return peak*sum}};const heartLubDub=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return peak*(bell(k,.25,.045)+.6*bell(k,.42,.03))};const Heart=Object.freeze({Calm:heartCalm(),Excited:heartExcited(),LubDub:heartLubDub()});const mathJumpArc=()=>k=>{if(k<=0||k>=1)return 0;return 4*k*(1-k)};const mathPendulum=(damping=3,freq=2.5)=>k=>{if(k<=0||k>=1)return 0;return Math.sin(k*Math.PI)*Math.exp(-damping*k)*Math.cos(freq*Math.PI*k)};const mathTremor=(amplitude=.04,freq=22)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return k+amplitude*Math.sin(k*Math.PI*2*freq)};const mathBoomerang=fn=>k=>{if(k<=0||k>=1)return 0;return k<.5?fn(k*2):fn(2-k*2)};const MathExt=Object.freeze({JumpArc:mathJumpArc(),Pendulum:mathPendulum(),Tremor:mathTremor()});const explosionImpulse=(sharpness=6)=>{const tail=sharpness*Math.exp(1-sharpness);return k=>{if(k<=0||k>=1)return 0;const h=sharpness*k;return h*Math.exp(1-h)-tail*k}};const explosionFlash=(rise=.05,decay=5)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return-Math.exp(-decay*k)*Math.cos(freq*Math.PI*k)};const explosionImplosion=(charge=.3,depth=.4,burstPeak=1.2)=>{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const w=Math.sin(k*Math.PI*2*cycles)+.5*Math.sin(k*Math.PI*2*cycles*1.5+1.2)+.25*Math.sin(k*Math.PI*2*cycles*3+2.4);return amplitude*env*w*.6};const natureFlicker=(rate=15,intensity=.2,seed=7)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=rate+1;i++)samples.push(rand());return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*rate;const idx=Math.floor(pos);const t=pos-idx;const a=samples[idx];const b=samples[idx+1];const interp=a+(b-a)*t;return intensity*env*(interp-.5)*2}};const natureGust=(gusts=3,peak=.25)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*.08*.08))}return peak*sum/gusts*1.8}};const Nature=Object.freeze({Wave:natureWave(),Flicker:natureFlicker(),Gust:natureGust()});const impactRain=(impactAt=.7,rippleAmp=.08)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const liftEnd=.35,strikeEnd=.6;return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return t*t}const t=(k-.4)/.6;const env=Math.exp(-2.5*t);const wave=Math.abs(Math.sin(t*Math.PI*bounces));return 1-env*wave*rebound};const impactSlap=(contactAt=.3,holdRatio=.1)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return.4*Math.pow(t,2.5)}if(k<.48){const t=(k-.4)/.08;return.4-.2*t}if(k<.52){const t=(k-.48)/.04;return.2+.8*t}const t=(k-.52)/.48;return 1-.04*Math.sin(t*Math.PI*8)*(1-t)};const rhythmPunchCombo=(peak=.4)=>{const pattern=[{c:.15,w:.04,a:.75},{c:.35,w:.04,a:.75},{c:.7,w:.055,a:1}];return k=>{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of pattern){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return peak*sum}};const rhythmStaccato=(beats=4,duty=.3)=>k=>{if(k<=0||k>=1)return 0;const beatLen=1/beats;const phase=k/beatLen-Math.floor(k/beatLen);if(phase>duty)return 0;const t=phase/duty;return Math.sin(t*Math.PI)};const rhythmKick=(peak=1.2)=>k=>{if(k<=0||k>=1)return 0;if(k<.05)return peak*k/.05;const t=(k-.05)/.95;return peak*Math.exp(-4*t)};const rhythmCrescendo=(beats=4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return sum}};const rhythmDunDunDun=()=>{const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return k=>{if(k<=0||k>=1)return 0;return.3*bell(k,.15,.025)+.6*bell(k,.35,.03)+1*bell(k,.68,.09)}};const rhythmBellToll=(decay=3,freq=8)=>{const strike=.05;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.2){const t=k/.2;return-pressDepth*Math.sin(t*Math.PI/2)}if(k<.5){const t=(k-.2)/.3;return-pressDepth+(pressDepth+reboundPeak)*(1-Math.pow(1-t,3))}const t=(k-.5)/.5;return reboundPeak*Math.exp(-4*t)*Math.cos(t*Math.PI*3)};const uiHoverBloom=(riseRatio=.2,fallRatio=.3)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=1-k;const raw=Math.sin(k*Math.PI*2*count);const clipped=Math.sign(raw)*Math.min(1,Math.abs(raw)*1.8);return amplitude*env*clipped};const uiSuccessPop=(overshoot=.2)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return(1+overshoot)*(1-Math.pow(1-t,2))}const t=(k-.4)/.6;return 1+overshoot*Math.exp(-5*t)*Math.cos(t*Math.PI*3)};const uiRippleOut=()=>k=>{if(k<=0||k>=1)return 0;return 6.75*k*Math.pow(1-k,2)};const UI=Object.freeze({ClickSnap:uiClickSnap(),HoverBloom:uiHoverBloom(),ErrorShake:uiErrorShake(),SuccessPop:uiSuccessPop(),RippleOut:uiRippleOut()});const magicManaCharge=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;const base=(Math.exp(3*k)-1)/(Math.exp(3)-1);const pulse=.04*Math.sin(k*Math.PI*8)*k;return base+pulse};const magicSpellCast=(chargeEnd=.4)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.45){const t=k/.45;return t*t*t}if(k<.55)return 1;const t=(k-.55)/.45;return Math.pow(1-t,3)};const magicShield=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.3){const t=k/.3;return 1.2*(1-Math.pow(1-t,2))}if(k<.6){const t=(k-.3)/.3;return 1.2-.2*t}const t=(k-.6)/.4;return 1+.03*Math.sin(t*Math.PI*3)};const magicAura=(peak=.15)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const fundamental=.6*Math.sin(k*Math.PI*2);const harmonic=.3*Math.sin(k*Math.PI*4+1);const overtone=.1*Math.sin(k*Math.PI*6+2);return peak*env*(fundamental+harmonic+overtone)};const Magic=Object.freeze({ManaCharge:magicManaCharge(),SpellCast:magicSpellCast(),Teleport:magicTeleport(),Shield:magicShield(),MagicAura:magicAura()});const animalCatPounce=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.2){const t=k/.2;return-.2*Math.sin(t*Math.PI)}if(k<.3){const t=(k-.2)/.1;return.5*t*t}if(k<.8){const t=(k-.3)/.5;return.5+.5*t+.2*Math.sin(t*Math.PI)}const t=(k-.8)/.2;return 1+.05*Math.sin(t*Math.PI)};const animalBirdFlap=(flaps=4)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const phase=k*Math.PI*2*flaps;const wave=Math.sin(phase)-.3*Math.sin(phase*2);return.2*env*wave};const animalSnakeSlither=(waves=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const wave=Math.sin(k*Math.PI*2*waves);return.2*env*wave};const animalButterflyFlit=(seed=13)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=26;i++)samples.push(rand()-.5);return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*25;const idx=Math.floor(pos);const t=pos-idx;const smooth=t*t*(3-2*t);const interp=samples[idx]+(samples[idx+1]-samples[idx])*smooth;return.3*env*interp}};const animalHorseGallop=(cycles=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const cyclePos=k*cycles-Math.floor(k*cycles);const bell=(c,w=.04)=>Math.exp(-((cyclePos-c)**2)/(2*w*w));return.25*env*(bell(0)+bell(.18)+bell(.36)+bell(.54))};const Animal=Object.freeze({CatPounce:animalCatPounce(),BirdFlap:animalBirdFlap(),SnakeSlither:animalSnakeSlither(),ButterflyFlit:animalButterflyFlit(),HorseGallop:animalHorseGallop()});const Progress=Object.freeze({Physics:Object.freeze({...Physics,Spring:libSpring()}),Motion:Motion,Step:Object.freeze({...Step,Steps6:libSteps()}),Math:Object.freeze({Tremor:MathExt.Tremor}),Impact:Object.freeze({Rain:Impact.Rain,Hammer:Impact.Hammer,BounceDrop:Impact.BounceDrop,ArrowHit:Impact.ArrowHit,Shatter:Impact.Shatter}),Rhythm:Object.freeze({BassDrop:Rhythm.BassDrop}),UI:Object.freeze({SuccessPop:UI.SuccessPop}),Magic:Object.freeze({ManaCharge:Magic.ManaCharge,Shield:Magic.Shield}),Animal:Object.freeze({CatPounce:Animal.CatPounce})});const Pulse=Object.freeze({Attention:Object.freeze({Ping:Attention.Ping}),Breath:Object.freeze({Deep:Breath.Deep,Sigh:Breath.Sigh}),Heart:Object.freeze({Calm:Heart.Calm}),Math:Object.freeze({JumpArc:MathExt.JumpArc,BoomerangSharp:mathBoomerang(E.Cubic.In),BoomerangSoft:mathBoomerang(E.Cubic.Out)}),Explosion:Object.freeze({Impulse:Explosion.Impulse,Flash:Explosion.Flash,Recoil:Explosion.Recoil,Implosion:Explosion.Implosion}),Impact:Object.freeze({Slap:Impact.Slap}),Rhythm:Object.freeze({Kick:Rhythm.Kick}),UI:Object.freeze({ClickSnap:UI.ClickSnap,HoverBloom:UI.HoverBloom,RippleOut:UI.RippleOut}),Magic:Object.freeze({SpellCast:Magic.SpellCast,Teleport:Magic.Teleport})});const Wave=Object.freeze({Attention:Object.freeze({Wiggle:Attention.Wiggle,Strum:Attention.Strum}),Breath:Object.freeze({Normal:Breath.Normal,Panting:Breath.Panting}),Heart:Object.freeze({Excited:Heart.Excited,LubDub:Heart.LubDub,Beat:libHeartBeat()}),Math:Object.freeze({Pendulum:MathExt.Pendulum}),Nature:Nature,Rhythm:Object.freeze({PunchCombo:Rhythm.PunchCombo,Staccato:Rhythm.Staccato,Crescendo:Rhythm.Crescendo,DunDunDun:Rhythm.DunDunDun,BellToll:Rhythm.BellToll}),UI:Object.freeze({ErrorShake:UI.ErrorShake}),Magic:Object.freeze({MagicAura:Magic.MagicAura}),Animal:Object.freeze({BirdFlap:Animal.BirdFlap,SnakeSlither:Animal.SnakeSlither,ButterflyFlit:Animal.ButterflyFlit,HorseGallop:Animal.HorseGallop})});const customEasings=Object.freeze({makeOutIn:makeOutIn,OutIn:OutIn,Progress:Progress,Pulse:Pulse,Wave:Wave,cubicBezier:cubicBezier});exports.customEasings=customEasings;exports.default=customEasings; \ No newline at end of file diff --git a/scripts/7681620607473126677/AmazingFeature/js/ThreeJS/scriptScene.js b/scripts/7681620607473126677/AmazingFeature/js/ThreeJS/scriptScene.js new file mode 100644 index 0000000000000000000000000000000000000000..5d5f0a8bde54f7efa0912b77bb0a8298e3fb04e9 --- /dev/null +++ b/scripts/7681620607473126677/AmazingFeature/js/ThreeJS/scriptScene.js @@ -0,0 +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; \ No newline at end of file diff --git a/scripts/7681620607473126677/AmazingFeature/js/ThreeJS/three-amg-wrapper.js b/scripts/7681620607473126677/AmazingFeature/js/ThreeJS/three-amg-wrapper.js new file mode 100644 index 0000000000000000000000000000000000000000..c2037e314e032c4d36912923d4cc1258cba3ab19 --- /dev/null +++ b/scripts/7681620607473126677/AmazingFeature/js/ThreeJS/three-amg-wrapper.js @@ -0,0 +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;iobj.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; \ No newline at end of file diff --git a/scripts/7681620607473126677/AmazingFeature/js/ThreeJS/tween.js b/scripts/7681620607473126677/AmazingFeature/js/ThreeJS/tween.js new file mode 100644 index 0000000000000000000000000000000000000000..690fb9e4284728629129deed5a5a3f4bcec291ed --- /dev/null +++ b/scripts/7681620607473126677/AmazingFeature/js/ThreeJS/tween.js @@ -0,0 +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=power1e4?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;_i0){this._tweensAddedDuringUpdate={};for(var i=0;i1){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[m1;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;itotalTime){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;ithis.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;ithis.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.xthis.max.x||box.max.ythis.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; \ No newline at end of file diff --git a/scripts/7681620607473126677/AmazingFeature/js/ThreeJS/wrapper/Box3.js b/scripts/7681620607473126677/AmazingFeature/js/ThreeJS/wrapper/Box3.js new file mode 100644 index 0000000000000000000000000000000000000000..4100dc7442d3a622827c8a415e24557f68c491f1 --- /dev/null +++ b/scripts/7681620607473126677/AmazingFeature/js/ThreeJS/wrapper/Box3.js @@ -0,0 +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=3?array[offset+2]:0;if(xthis.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=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.xthis.max.x||box.max.ythis.max.y||box.max.zthis.max.z)}}exports.Box3=Box3; \ No newline at end of file diff --git a/scripts/7681620607473126677/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js b/scripts/7681620607473126677/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..be3b8b1334a62f5e88c45feee098063a199fca55 --- /dev/null +++ b/scripts/7681620607473126677/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js @@ -0,0 +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=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; \ No newline at end of file diff --git a/scripts/7681620607473126677/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js b/scripts/7681620607473126677/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..af9a8a13a46500e78f082a35e18d0b5932061234 --- /dev/null +++ b/scripts/7681620607473126677/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js @@ -0,0 +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;iObject.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