nova64 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +786 -0
- package/index.html +651 -0
- package/package.json +255 -0
- package/public/os9-shell/assets/index-B1Uvacma.js +32825 -0
- package/public/os9-shell/assets/index-B1Uvacma.js.map +1 -0
- package/public/os9-shell/assets/index-DIHfrTaW.css +1 -0
- package/public/os9-shell/index.html +14 -0
- package/public/os9-shell/nova-icon.svg +12 -0
- package/runtime/api-2d.js +878 -0
- package/runtime/api-3d/camera.js +73 -0
- package/runtime/api-3d/instancing.js +180 -0
- package/runtime/api-3d/lights.js +51 -0
- package/runtime/api-3d/materials.js +47 -0
- package/runtime/api-3d/models.js +84 -0
- package/runtime/api-3d/pbr.js +69 -0
- package/runtime/api-3d/primitives.js +304 -0
- package/runtime/api-3d/scene.js +169 -0
- package/runtime/api-3d/transforms.js +161 -0
- package/runtime/api-3d.js +154 -0
- package/runtime/api-effects.js +753 -0
- package/runtime/api-presets.js +85 -0
- package/runtime/api-skybox.js +178 -0
- package/runtime/api-sprites.js +100 -0
- package/runtime/api-voxel.js +601 -0
- package/runtime/api.js +201 -0
- package/runtime/assets.js +27 -0
- package/runtime/audio.js +114 -0
- package/runtime/collision.js +47 -0
- package/runtime/console.js +101 -0
- package/runtime/editor.js +233 -0
- package/runtime/font.js +233 -0
- package/runtime/framebuffer.js +28 -0
- package/runtime/fullscreen-button.js +185 -0
- package/runtime/gpu-canvas2d.js +47 -0
- package/runtime/gpu-threejs.js +639 -0
- package/runtime/gpu-webgl2.js +310 -0
- package/runtime/index.js +22 -0
- package/runtime/input.js +225 -0
- package/runtime/logger.js +60 -0
- package/runtime/physics.js +101 -0
- package/runtime/screens.js +213 -0
- package/runtime/storage.js +38 -0
- package/runtime/store.js +151 -0
- package/runtime/textinput.js +68 -0
- package/runtime/ui/buttons.js +124 -0
- package/runtime/ui/panels.js +105 -0
- package/runtime/ui/text.js +86 -0
- package/runtime/ui/widgets.js +141 -0
- package/runtime/ui.js +111 -0
- package/src/main.js +474 -0
- package/vite.config.js +63 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// runtime/api-3d.js
|
|
2
|
+
// Thin orchestrator — delegates to runtime/api-3d/*.js sub-modules
|
|
3
|
+
import * as THREE from 'three';
|
|
4
|
+
globalThis.THREE = THREE;
|
|
5
|
+
import { materialsModule } from './api-3d/materials.js';
|
|
6
|
+
import { primitivesModule } from './api-3d/primitives.js';
|
|
7
|
+
import { transformsModule } from './api-3d/transforms.js';
|
|
8
|
+
import { cameraModule } from './api-3d/camera.js';
|
|
9
|
+
import { lightsModule } from './api-3d/lights.js';
|
|
10
|
+
import { modelsModule } from './api-3d/models.js';
|
|
11
|
+
import { instancingModule } from './api-3d/instancing.js';
|
|
12
|
+
import { pbrModule } from './api-3d/pbr.js';
|
|
13
|
+
import { sceneModule } from './api-3d/scene.js';
|
|
14
|
+
|
|
15
|
+
export function threeDApi(gpu) {
|
|
16
|
+
if (!gpu.getScene) return { exposeTo: () => {} };
|
|
17
|
+
|
|
18
|
+
const scene = gpu.getScene();
|
|
19
|
+
const camera = gpu.getCamera();
|
|
20
|
+
const renderer = gpu.getRenderer();
|
|
21
|
+
|
|
22
|
+
// Shared state — passed by reference into every sub-module
|
|
23
|
+
const meshes = new Map();
|
|
24
|
+
const mixers = new Map();
|
|
25
|
+
const modelAnimations = new Map();
|
|
26
|
+
const materialCache = new Map();
|
|
27
|
+
const cartLights = new Map();
|
|
28
|
+
const instancedMeshes = new Map();
|
|
29
|
+
const lodObjects = new Map();
|
|
30
|
+
const counters = { mesh: 0, light: 0, instance: 0, lod: 0 };
|
|
31
|
+
|
|
32
|
+
// Build context — each module appends its exports so later modules can call earlier ones
|
|
33
|
+
const ctx = {
|
|
34
|
+
scene,
|
|
35
|
+
camera,
|
|
36
|
+
renderer,
|
|
37
|
+
gpu,
|
|
38
|
+
meshes,
|
|
39
|
+
mixers,
|
|
40
|
+
modelAnimations,
|
|
41
|
+
materialCache,
|
|
42
|
+
cartLights,
|
|
43
|
+
instancedMeshes,
|
|
44
|
+
lodObjects,
|
|
45
|
+
counters,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
Object.assign(ctx, materialsModule(ctx));
|
|
49
|
+
Object.assign(ctx, primitivesModule(ctx));
|
|
50
|
+
Object.assign(ctx, transformsModule(ctx));
|
|
51
|
+
Object.assign(ctx, cameraModule(ctx));
|
|
52
|
+
Object.assign(ctx, lightsModule(ctx));
|
|
53
|
+
Object.assign(ctx, modelsModule(ctx));
|
|
54
|
+
Object.assign(ctx, instancingModule(ctx));
|
|
55
|
+
Object.assign(ctx, pbrModule(ctx));
|
|
56
|
+
Object.assign(ctx, sceneModule(ctx)); // last: uses late binding to call other modules
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
exposeTo(target) {
|
|
60
|
+
Object.assign(target, {
|
|
61
|
+
// Primitive creation
|
|
62
|
+
createCube: ctx.createCube,
|
|
63
|
+
createSphere: ctx.createSphere,
|
|
64
|
+
createCylinder: ctx.createCylinder,
|
|
65
|
+
createPlane: ctx.createPlane,
|
|
66
|
+
createAdvancedCube: ctx.createAdvancedCube,
|
|
67
|
+
createAdvancedSphere: ctx.createAdvancedSphere,
|
|
68
|
+
createTorus: ctx.createTorus,
|
|
69
|
+
createCone: ctx.createCone,
|
|
70
|
+
createCapsule: ctx.createCapsule,
|
|
71
|
+
|
|
72
|
+
// Mesh management
|
|
73
|
+
destroyMesh: ctx.destroyMesh,
|
|
74
|
+
removeMesh: ctx.removeMesh,
|
|
75
|
+
|
|
76
|
+
// Model and texture loading
|
|
77
|
+
loadModel: ctx.loadModel,
|
|
78
|
+
playAnimation: ctx.playAnimation,
|
|
79
|
+
updateAnimations: ctx.updateAnimations,
|
|
80
|
+
loadTexture: ctx.loadTexture,
|
|
81
|
+
|
|
82
|
+
// Transforms
|
|
83
|
+
setPosition: ctx.setPosition,
|
|
84
|
+
setRotation: ctx.setRotation,
|
|
85
|
+
setScale: ctx.setScale,
|
|
86
|
+
getPosition: ctx.getPosition,
|
|
87
|
+
getRotation: ctx.getRotation,
|
|
88
|
+
rotateMesh: ctx.rotateMesh,
|
|
89
|
+
moveMesh: ctx.moveMesh,
|
|
90
|
+
|
|
91
|
+
// Mesh helpers
|
|
92
|
+
setFlatShading: ctx.setFlatShading,
|
|
93
|
+
setMeshVisible: ctx.setMeshVisible,
|
|
94
|
+
setMeshOpacity: ctx.setMeshOpacity,
|
|
95
|
+
setCastShadow: ctx.setCastShadow,
|
|
96
|
+
setReceiveShadow: ctx.setReceiveShadow,
|
|
97
|
+
|
|
98
|
+
// Camera
|
|
99
|
+
setCameraPosition: ctx.setCameraPosition,
|
|
100
|
+
setCameraTarget: ctx.setCameraTarget,
|
|
101
|
+
setCameraLookAt: ctx.setCameraLookAt,
|
|
102
|
+
setCameraFOV: ctx.setCameraFOV,
|
|
103
|
+
|
|
104
|
+
// Scene / atmosphere
|
|
105
|
+
setFog: ctx.setFog,
|
|
106
|
+
clearFog: ctx.clearFog,
|
|
107
|
+
setLightDirection: ctx.setLightDirection,
|
|
108
|
+
setLightColor: ctx.setLightColor,
|
|
109
|
+
setAmbientLight: ctx.setAmbientLight,
|
|
110
|
+
setDirectionalLight: ctx.setDirectionalLight,
|
|
111
|
+
clearScene: ctx.clearScene,
|
|
112
|
+
|
|
113
|
+
// Effects
|
|
114
|
+
enablePixelation: ctx.enablePixelation,
|
|
115
|
+
enableDithering: ctx.enableDithering,
|
|
116
|
+
|
|
117
|
+
// Dynamic lights
|
|
118
|
+
createPointLight: ctx.createPointLight,
|
|
119
|
+
setPointLightPosition: ctx.setPointLightPosition,
|
|
120
|
+
setPointLightColor: ctx.setPointLightColor,
|
|
121
|
+
removeLight: ctx.removeLight,
|
|
122
|
+
|
|
123
|
+
// GPU instancing
|
|
124
|
+
createInstancedMesh: ctx.createInstancedMesh,
|
|
125
|
+
setInstanceTransform: ctx.setInstanceTransform,
|
|
126
|
+
setInstanceColor: ctx.setInstanceColor,
|
|
127
|
+
finalizeInstances: ctx.finalizeInstances,
|
|
128
|
+
removeInstancedMesh: ctx.removeInstancedMesh,
|
|
129
|
+
|
|
130
|
+
// LOD system
|
|
131
|
+
createLODMesh: ctx.createLODMesh,
|
|
132
|
+
setLODPosition: ctx.setLODPosition,
|
|
133
|
+
removeLODMesh: ctx.removeLODMesh,
|
|
134
|
+
updateLODs: ctx.updateLODs,
|
|
135
|
+
|
|
136
|
+
// Normal / PBR maps
|
|
137
|
+
loadNormalMap: ctx.loadNormalMap,
|
|
138
|
+
setNormalMap: ctx.setNormalMap,
|
|
139
|
+
setPBRMaps: ctx.setPBRMaps,
|
|
140
|
+
|
|
141
|
+
// Interaction / stats / convenience
|
|
142
|
+
raycastFromCamera: ctx.raycastFromCamera,
|
|
143
|
+
get3DStats: ctx.get3DStats,
|
|
144
|
+
setupScene: ctx.setupScene,
|
|
145
|
+
|
|
146
|
+
// Direct Three.js access for advanced users
|
|
147
|
+
getScene: () => scene,
|
|
148
|
+
getCamera: () => camera,
|
|
149
|
+
getRenderer: () => renderer,
|
|
150
|
+
getMesh: ctx.getMesh,
|
|
151
|
+
});
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
}
|