58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
import {
|
|
CameraC_internal,
|
|
CameraType,
|
|
Physics_internal,
|
|
Template,
|
|
Template3d,
|
|
ThreeC_internal,
|
|
FilterScene,
|
|
InstallBanner,
|
|
} from "@24tools/playable_template";
|
|
import { CameraC } from "../controllers/CameraC";
|
|
import { ThreeC } from "../controllers/ThreeC";
|
|
import { Color } from "three";
|
|
import { Vec3 } from "cannon-es";
|
|
export const beforeResourcesLoadedCb = () => {
|
|
FilterScene.init();
|
|
InstallBanner.init();
|
|
|
|
Template3d.init();
|
|
CameraC_internal.init(CameraType.perspective);
|
|
CameraC.setCamera(window.screenSize.portrait);
|
|
ThreeC_internal.init();
|
|
ThreeC.createBaseLights();
|
|
ThreeC.setupDirectionalLight();
|
|
|
|
Physics_internal.init(new Vec3(0, -9.81, 0));
|
|
|
|
Template.updateVariableConfig.addDelegate(([category, variable, value]) => {
|
|
if (category === "global") {
|
|
switch (variable) {
|
|
case "light_intensity":
|
|
ThreeC_internal.defaultAmbientLight.intensity = Number(value);
|
|
break;
|
|
|
|
case "light_color":
|
|
ThreeC_internal.defaultAmbientLight.color = new Color(value as any);
|
|
break;
|
|
|
|
default:
|
|
if (
|
|
[
|
|
"camera_fov_p",
|
|
"camera_position_p",
|
|
"camera_rotation_p",
|
|
"camera_fov_l",
|
|
"camera_position_l",
|
|
"camera_rotation_l",
|
|
].includes(variable)
|
|
) {
|
|
CameraC.setCamera(window.screenSize.portrait);
|
|
}
|
|
break;
|
|
}
|
|
return;
|
|
}
|
|
});
|
|
};
|