ecctrl icon indicating copy to clipboard operation
ecctrl copied to clipboard

some time its getting fallingdown and Stuck from map how to respawn the model lot of bug here.

Open DevaPandiyan opened this issue 1 year ago • 17 comments

`

import { Canvas, useFrame } from '@react-three/fiber' import { Environment, KeyboardControls, OrbitControls } from "@react-three/drei" import { Perf } from 'r3f-perf'; import './App.css' import Light from './Components/Light' import { Map } from './Components/Map' import { Map2 } from './Components/Map2' import { Map4 } from './Components/Map4' import { Map3 } from './Components/Map3' // import { Map } from './Components/Map' import { Physics, RigidBody } from '@react-three/rapier' import { Suspense, useEffect, useRef } from 'react'; import { AnimaCharacterModel } from './Components/AnimaCharacterModel'; import { Avatar } from './Components/Avatar'; import Ecctrl, { EcctrlAnimation, EcctrlJoystick } from 'ecctrl'; import { useConfigurator } from './contexts/Configurator';

function App() {

const { loading, setLoading } = useConfigurator(); const keyboardMap = [ { name: 'forward', keys: ['ArrowUp', 'KeyW'] }, { name: 'backward', keys: ['ArrowDown', 'KeyS'] }, { name: 'leftward', keys: ['ArrowLeft', 'KeyA'] }, { name: 'rightward', keys: ['ArrowRight', 'KeyD'] }, { name: 'jump', keys: ['Space'] }, { name: 'run', keys: ['Shift'] }, { name: 'action1', keys: ['1'] }, { name: 'action2', keys: ['2'] }, { name: 'action3', keys: ['3'] }, { name: 'action4', keys: ['KeyF'] } ]

const characterURL = './AnimatedWoman.glb';

const animationSet = { idle: 'CharacterArmature|Idle', walk: 'CharacterArmature|Walk', run: 'CharacterArmature|Run', jump: 'CharacterArmature|Idle', jumpIdle: 'CharacterArmature|Idle', jumpLand: 'CharacterArmature|Idle', fall: 'CharacterArmature|Idle', // This is for falling from high sky action1: 'CharacterArmature|Wave', action2: 'CharacterArmature|Death', action3: 'CharacterArmature|HitRecieve', action4: 'CharacterArmature|Punch_Left'

}

return ( <> <EcctrlJoystick /> <Canvas shadows > {/* <Perf position="top-left"/> */} <Environment background files="/night.hdr" /> <Light /> <Physics timeStep={"vary"} > <KeyboardControls map={keyboardMap}>

        <Suspense fallback={null}>
          {loading === true && (
            <Ecctrl animated position={[0, 10, 0]} >

              <EcctrlAnimation characterURL={characterURL}
                animationSet={animationSet}>
                <Avatar />

              </EcctrlAnimation>

            </Ecctrl>
          )}
        </Suspense>


      </KeyboardControls>
      <RigidBody type="fixed" name="ground">
        <mesh position-y={-5.3} receiveShadow>
          <boxGeometry args={[50, 0.5, 50]} />
          <meshStandardMaterial color="mediumpurple" />
        </mesh>
      </RigidBody>
      {/* <Map4 /> */}
      {/* <Map2 /> */}
      <Map4 />




    </Physics>

    <OrbitControls />

  </Canvas>
</>

) }

export default App

`

https://github.com/pmndrs/ecctrl/assets/25933803/0da24652-f301-43de-8cd1-e04d4294ab23

Map4 here `import React, { useEffect, useRef } from 'react' import { useGLTF } from '@react-three/drei' import { useConfigurator } from '../contexts/Configurator'; import { GLTFLoader } from 'three-stdlib'; import { RigidBody } from '@react-three/rapier';

export function Map4(props) { const { nodes, materials } = useGLTF('/metafactory_booth.glb')

const loader = new GLTFLoader(); const { loading, setLoading } = useConfigurator();

useEffect(()=>{ loader.load( "/metafactory_booth.glb", ( gltf ) => {

      setLoading(true)
     
  },
  ( xhr ) => {
   
      // called while loading is progressing
      console.log( `${( xhr.loaded / xhr.total * 100 )}% loaded` );
  },
  ( error ) => {

      // called when loading has errors
      console.error( 'An error happened', error );
  },
  );

});

return ( <RigidBody type="fixed" colliders="trimesh"> <group {...props} dispose={null} position={[0,-3,0]}> <group name="Clothes_rack_8" position={[0, 1.827, 0]} rotation={[-Math.PI / 2, 0, 0]} scale={0.024}> <group name="Object_6_7" position={[-23.032, 260.432, -5.813]} rotation={[0, 0, -3.133]} scale={0.604}> <group name="B1_Teal_9" position={[3.29, 7.184, 5.46]} rotation={[0, -1.54, 0]} scale={[0.822, 0.822, 0.009]}> <group name="Sketchfab_model_14" position={[16.228, 0, 0]} rotation={[-Math.PI / 2, 0, 0]} scale={0.526}> <mesh name="Object_27" geometry={nodes.Object_27.geometry} material={materials['Materiale.002']} position={[-30.794, -0.149, 2.86]} scale={[0.698, 0.928, 0.695]} /> <mesh name="Object_29" geometry={nodes.Object_29.geometry} material={materials.aiStandard2SG} position={[3.799, 0, 0]} scale={[1.735, 1, 1]} /> <group name="B1_Teal001_15" position={[-0.666, 2.041, 4.385]} rotation={[-Math.PI, 0, -Math.PI]} scale={[0.211, 0.211, 0.002]}> <group name="Cube001_26" position={[-2.906, 1.746, -3.9]} rotation={[0, Math.PI / 2, 0]} scale={[0.445, 0.325, 0.877]}> <mesh name="Object_57" geometry={nodes.Object_57.geometry} material={materials['Materiale.004']} /> <group name="Cube002_30" position={[-2.91, 1.746, -5.816]} rotation={[0, Math.PI / 2, 0]} scale={[0.445, 0.325, 0.877]}> <mesh name="Object_60" geometry={nodes.Object_60.geometry} material={materials['Materiale.004']} /> <group name="Cube003_31" position={[1.839, 1.746, -5.816]} rotation={[0, Math.PI / 2, 0]} scale={[0.445, 0.325, 0.877]}> <mesh name="Object_63" geometry={nodes.Object_63.geometry} material={materials['Materiale.004']} /> {/* <mesh name="Object_7_1" geometry={nodes.Object_7_1.geometry} material={materials.Materiale} rotation={[-Math.PI / 2, 0, 0]} /> */} <mesh name="Object_11" geometry={nodes.Object_11.geometry} material={materials.boothsheet_branding} rotation={[-Math.PI / 2, 0, 0]} /> <mesh name="Object_23" geometry={nodes.Object_23.geometry} material={materials['tshirt.003']} position={[-2.483, 2.37, -4.051]} scale={0.782} /> <mesh name="Object_36" geometry={nodes.Object_36.geometry} material={materials.material} position={[2.273, 2.496, -5.983]} rotation={[0.004, -0.32, 0.002]} scale={1.22} /> <mesh name="Object_38" geometry={nodes.Object_38.geometry} material={materials.hoodie} position={[-3.305, 2.479, -5.865]} rotation={[0, 0.096, 0]} /> <mesh name="Object_40" geometry={nodes.Object_40.geometry} material={materials.longsleeve} position={[1.427, 2.204, -5.966]} rotation={[0, -0.014, 0]} scale={1.206} /> <mesh name="Object_42" geometry={nodes.Object_42.geometry} material={materials.Atlas1} position={[1.918, 2.477, 6.525]} rotation={[Math.PI / 2, 0, 0]} scale={0.01} /> <mesh name="Object_44" geometry={nodes.Object_44.geometry} material={materials.material_0} position={[-1.327, 2.54, 4.819]} rotation={[Math.PI / 2, 0, 0]} scale={0.012} /> <mesh name="Object_46" geometry={nodes.Object_46.geometry} material={materials.Jacket} position={[-0.723, 3.126, 4.932]} rotation={[Math.PI / 2, 0, 0]} scale={0.012} /> <mesh name="Object_48" geometry={nodes.Object_48.geometry} material={materials.Materiale} position={[-0.685, 3.372, 4.791]} rotation={[Math.PI / 2, 0, 0]} scale={0.012} /> <mesh name="Object_50" geometry={nodes.Object_50.geometry} material={materials.tanktop} position={[-3.366, 2.367, -4.047]} rotation={[-Math.PI, -0.015, -Math.PI]} /> <mesh name="Object_52" geometry={nodes.Object_52.geometry} material={materials.sneakers} position={[-2.303, 2.065, -5.932]} rotation={[-Math.PI, 0.515, -Math.PI]} /> <mesh name="Object_54" geometry={nodes.Object_54.geometry} material={materials.Material} position={[2.28, 2.31, -5.987]} rotation={[0, 1.54, 0]} /> <mesh name="Object_65" geometry={nodes.Object_65.geometry} material={materials['Materiale.003']} position={[-2.9, 1.599, -3.896]} scale={[0.957, 0.006, 0.529]} /> <mesh name="Object_67" geometry={nodes.Object_67.geometry} material={materials['Materiale.003']} position={[-2.9, 1.599, -5.808]} scale={[0.957, 0.006, 0.529]} /> <mesh name="Object_69" geometry={nodes.Object_69.geometry} material={materials['Materiale.003']} position={[1.836, 1.599, -5.808]} scale={[0.957, 0.006, 0.529]} /> <mesh name="Object_71" geometry={nodes.Object_71.geometry} material={materials['Materiale.003']} position={[-0.672, 1.599, 4.86]} scale={[2.546, 0.006, 0.529]} /> </RigidBody> ) }

useGLTF.preload('/metafactory_booth.glb')`

DevaPandiyan avatar Jan 07 '24 16:01 DevaPandiyan

Is your map4 wrapped inside < RigidBody > ?

ErdongChen-Andrew avatar Jan 07 '24 23:01 ErdongChen-Andrew

yes

DevaPandiyan avatar Jan 08 '24 04:01 DevaPandiyan

It seems alright to me. Does it work properly when using just the ground?

ErdongChen-Andrew avatar Jan 08 '24 06:01 ErdongChen-Andrew

It seems alright to me. Does it work properly when using just the ground?

yes ground work fine buy get and tried from free map models cant working properly its falling out of the model before loading map or once map is loaded confirmed after get character loading it not working

DevaPandiyan avatar Jan 08 '24 09:01 DevaPandiyan

It seems alright to me. Does it work properly when using just the ground?

Only in groundworks fine, Additionally add map its not working again

https://ckk2kc-5173.csb.app/

`import { Canvas, useFrame } from "@react-three/fiber"; import { Environment, KeyboardControls, OrbitControls, } from "@react-three/drei"; import { Perf } from "r3f-perf"; import "./App.css"; import Light from "./Components/Light"; import { Map } from "./Components/Map"; import { Map2 } from "./Components/Map2"; import { Map4 } from "./Components/Map4"; import { Map3 } from "./Components/Map3"; // import { Map } from './Components/Map' import { Physics, RigidBody } from "@react-three/rapier";

import { useConfigurator } from "./contexts/Configurator"; import { Experience } from "./Components/Experience"; import Ecctrl, { EcctrlAnimation, EcctrlJoystick } from "ecctrl"; import { Suspense } from "react"; import { Avatar } from "./Components/Avatar"; import { Playground } from "./Components/Playground"; import { Map5 } from "./Components/Map5";

function App() { const { loading, setLoading } = useConfigurator(); const keyboardMap = [ { name: "forward", keys: ["ArrowUp", "KeyW"] }, { name: "backward", keys: ["ArrowDown", "KeyS"] }, { name: "leftward", keys: ["ArrowLeft", "KeyA"] }, { name: "rightward", keys: ["ArrowRight", "KeyD"] }, { name: "jump", keys: ["Space"] }, { name: "run", keys: ["Shift"] }, { name: "action1", keys: ["1"] }, { name: "action2", keys: ["2"] }, { name: "action3", keys: ["3"] }, { name: "action4", keys: ["KeyF"] }, ];

const characterURL = "./AnimatedWoman.glb";

const animationSet = { idle: "CharacterArmature|Idle", walk: "CharacterArmature|Walk", run: "CharacterArmature|Run", jump: "CharacterArmature|Idle", jumpIdle: "CharacterArmature|Idle", jumpLand: "CharacterArmature|Idle", fall: "CharacterArmature|Idle", // This is for falling from high sky action1: "CharacterArmature|Wave", action2: "CharacterArmature|Death", action3: "CharacterArmature|HitRecieve", action4: "CharacterArmature|Punch_Left", };

return ( <> <EcctrlJoystick /> <Canvas shadows> {/* <Perf position="top-left"/> */} <Environment background files="/night.hdr" /> <Light />

    <Physics timeStep={"vary"}>
      <KeyboardControls map={keyboardMap}>
        <RigidBody type="fixed" colliders="trimesh">
          <mesh position-y={-3.3} receiveShadow>
            <boxGeometry args={[50, 0.5, 50]} />
            <meshStandardMaterial color="mediumpurple" />
          </mesh>
        </RigidBody>
        {loading === true && (
          <Experience
            characterURL={characterURL}
            animationSet={animationSet}
          />
        )}
      </KeyboardControls>
      <Map4 />
      {/* <Map2 /> */}
      {/* <Map /> */}
    </Physics>

    <OrbitControls />
  </Canvas>
</>

); }

export default App; `

DevaPandiyan avatar Jan 08 '24 10:01 DevaPandiyan

Could you set up a simple CodeSandbox? If the ground works there, the issue is likely related to the map setup.

ErdongChen-Andrew avatar Jan 08 '24 22:01 ErdongChen-Andrew

Could you set up a simple CodeSandbox? If the ground works there, the issue is likely related to the map setup.

my sandbox account is now free not access to general edit. This is My Mail id [email protected] Pls sent it your mail ID ill request to you edit access it...

DevaPandiyan avatar Jan 09 '24 03:01 DevaPandiyan

I think you can just creat a public CodeSandbox. I can fork it and make edits, similar to the one I created: https://codesandbox.io/p/sandbox/ecctrl-with-animations-nr4493

ErdongChen-Andrew avatar Jan 09 '24 05:01 ErdongChen-Andrew

I think you can just creat a public CodeSandbox. I can fork it and make edits, similar to the one I created: https://codesandbox.io/p/sandbox/ecctrl-with-animations-nr4493

you can try with another map like(above 15 MB to 20 MB) Maps using it some devices it can falling down. in case i loaded the map first after loaded the character im facing same issues

DevaPandiyan avatar Jan 09 '24 07:01 DevaPandiyan

icant share sandbox link because general public share isn't free. i can share the zip file. can you make it public sandbox link

here is it https://drive.google.com/file/d/1TtNuybcncKjePDuXvlijaVS54UcI7r_2/view?usp=sharing

pls check it bro

DevaPandiyan avatar Jan 09 '24 13:01 DevaPandiyan

How come? I'm using the same free account, and you can make edits on it. If you have a large map, try loading ecctrl once the map is ready

ErdongChen-Andrew avatar Jan 09 '24 19:01 ErdongChen-Andrew

**> {loading === true && (

      <Experience
        characterURL={characterURL}
        animationSet={animationSet}
      />
    )} 

**

i m already did it. not work and same issue, 15 Mb map is very below low configuration ecctrl not work perfectly. incase it may be by my mistake, and I shared the whole file in drive pls check the file in my drive. Or atleast give your mail id i request to you in code sandbox

DevaPandiyan avatar Jan 10 '24 04:01 DevaPandiyan

https://github.com/pmndrs/ecctrl/assets/84251107/147cb64d-2ebd-417c-9454-d15cc1615206

I tested your map, and it worked perfectly on my end.

ErdongChen-Andrew avatar Jan 10 '24 23:01 ErdongChen-Andrew

Wow Amazing . what have you done can you share code . it was help me a lot just show me the code. i have too show the same scenario but the problem is some device make it network related. like once the map loaded after i do it character loading here i face real problem is born. then its not getting perfect. thats why because you show the code i can relate it what is happening what is what pls share and Show me.

https://github.com/pmndrs/ecctrl/assets/25933803/d5749edc-0d0c-4422-be4b-a78382af99cd

and Then

https://github.com/pmndrs/ecctrl/assets/25933803/f02039b6-769e-4a7d-a0f1-ca615fc05759

real problems

https://github.com/pmndrs/ecctrl/assets/25933803/66ad90a3-4e05-4adc-8509-4348be409df1

https://github.com/pmndrs/ecctrl/assets/25933803/5b11796b-e0ac-4604-9c3e-4ef24a9731d9

DevaPandiyan avatar Jan 11 '24 03:01 DevaPandiyan

I just used the same code as yours without including the loading process. Unfortunately, I am not able to use that loading method due to too many errors.

ErdongChen-Andrew avatar Jan 11 '24 07:01 ErdongChen-Andrew

I just used the same code as yours without including the loading process. Unfortunately, I am not able to use that loading method due to too many errors.

Pls give your Or Demo mail iD request to edit code sandbox .. pls pls Or check it the new file https://drive.google.com/file/d/1pNr8vwST013WXpY_ZwKtV3pioZbkTj3i/view?usp=sharing

DevaPandiyan avatar Jan 11 '24 07:01 DevaPandiyan

Isn't there some way to load the world before loading the falling character?

I'm currently experiencing issues when I load a larger map of models (some instanced). I still fall through the floor it seems because the map is still loading.

campbellgoe avatar Apr 15 '24 11:04 campbellgoe