1
0
This commit is contained in:
2024-08-05 19:09:38 +09:00
parent 602ffa7550
commit d5d5838953

View File

@ -17,7 +17,7 @@ interface ModelProps {
scale?: number scale?: number
} }
const VRMModel: React.FC<ModelProps> = ({ url = "./models/ai.vrm", url_anim="./models/default.vrma", position = [0, 0, 0], scale = 1, rotation = [0, 0, 0] }) => { const VRMModel: React.FC<ModelProps> = ({ url = "./models/ai.vrm", url_anim="./models/default.vrma", position = [0, 0, 0], scale = 1, rotation = [0, 1.5, 0] }) => {
const [vrm, setVrm] = useState<VRM | null>(null); const [vrm, setVrm] = useState<VRM | null>(null);
const mixerRef = useRef<THREE.AnimationMixer | null>(null); const mixerRef = useRef<THREE.AnimationMixer | null>(null);
@ -31,7 +31,7 @@ const VRMModel: React.FC<ModelProps> = ({ url = "./models/ai.vrm", url_anim="./m
VRMUtils.removeUnnecessaryJoints(vrmModel.scene); VRMUtils.removeUnnecessaryJoints(vrmModel.scene);
setVrm(vrmModel); setVrm(vrmModel);
if (vrmModel) { if (vrmModel) {
vrmModel.scene.rotation.set(0,1.5,0); vrmModel.scene.rotation.set(...rotation);
vrmModel.scene.position.set(...position); vrmModel.scene.position.set(...position);
vrmModel.scene.scale.setScalar(scale); vrmModel.scene.scale.setScalar(scale);
} }
@ -70,8 +70,9 @@ export function Galaxy(props: JSX.IntrinsicElements['group']) {
const searchParams = new URLSearchParams(window.location.search); const searchParams = new URLSearchParams(window.location.search);
var g = searchParams.get('g') ?? 'galaxy'; var g = searchParams.get('g') ?? 'galaxy';
var model_galaxy = "./models/galaxy.glb" var model_galaxy = "./models/galaxy.glb"
var model_custom = "./models/ai.vrm"
var model_scale = 0.01; var model_scale = 0.01;
var position_custom = [-0.3, -0.7, -0.2] as [number, number, number]; var position_custom = [-0.2, -0.8, -0.3] as [number, number, number];
var sphereGeometry = new SphereGeometry(1, 332, 332); var sphereGeometry = new SphereGeometry(1, 332, 332);
var anim_custom = "./models/emote.vrma"; var anim_custom = "./models/emote.vrma";
const { nodes } = useGLTF(model_galaxy) as GLTFResult const { nodes } = useGLTF(model_galaxy) as GLTFResult
@ -89,6 +90,7 @@ export function Galaxy(props: JSX.IntrinsicElements['group']) {
model_scale = 0.01; model_scale = 0.01;
position_custom = [-0.5,-1,0]; position_custom = [-0.5,-1,0];
anim_custom = "./models/fly.vrma"; anim_custom = "./models/fly.vrma";
model_custom = "./models/ai_default.vrm";
} else if (g === 'earth'){ } else if (g === 'earth'){
sphereGeometry = new SphereGeometry(1, 232, 232); sphereGeometry = new SphereGeometry(1, 232, 232);
nodes.Object_2.geometry = sphereGeometry; nodes.Object_2.geometry = sphereGeometry;
@ -96,6 +98,7 @@ export function Galaxy(props: JSX.IntrinsicElements['group']) {
model_scale = 0.3; model_scale = 0.3;
position_custom = [-1,-1,0]; position_custom = [-1,-1,0];
anim_custom = "./models/fly.vrma"; anim_custom = "./models/fly.vrma";
model_custom = "./models/ai_default.vrm";
} else if (g === 'neutron') { } else if (g === 'neutron') {
model_color = 1; model_color = 1;
} }
@ -138,11 +141,11 @@ export function Galaxy(props: JSX.IntrinsicElements['group']) {
return ( return (
<group {...props} dispose={null} ref={ref}> <group {...props} dispose={null} ref={ref}>
<VRMModel url="./models/ai.vrm" url_anim={anim_custom} position={position_custom} scale={1}/> <VRMModel url={model_custom} url_anim={anim_custom} position={position_custom} scale={1}/>
<pointLight <pointLight
position={[0, 0, 0]} position={[0, 0, 0]}
ref={galaxyCenterLightRef} ref={galaxyCenterLightRef}
intensity={0.1} intensity={0.2}
/> />
<Points scale={model_scale} positions={positions} colors={colors} rotation={[1.5,0,0]}> <Points scale={model_scale} positions={positions} colors={colors} rotation={[1.5,0,0]}>
<pointsMaterial <pointsMaterial