-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-cwthreejs.html
82 lines (70 loc) · 2.58 KB
/
test-cwthreejs.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!DOCTYPE html>
<html lang="en">
<head>
<title>CW to threeJS</title>
</head>
<body>
<script src="./js/bootstrap.bundle.js"></script>
<script src="./js/loader-min.js"></script>
Example to show the creating an image in a ImageData buffer<br>
<canvas width="800" height="600" id="3dSpace"></canvas>
<script async src="https://unpkg.com/[email protected]/dist/es-module-shims.js"></script>
<script type="importmap">
{
"imports": {
"three": "https://unpkg.com/[email protected]/build/three.module.js",
"three/addons/": "https://unpkg.com/[email protected]/examples/jsm/"
}
}
</script>
<script type="module">
import {dsector} from "./js/dsjs/dsector.js";
import {CWSYSTEM} from "./js/CWS/CWSYSTEM.js";
function preloadImages(paths, callback) {
let loaded = 0;
paths.forEach(function (values, keys) {
let img = new Image();
img.src = keys;
img.onload = onImagePreloaded;
preImages.set(keys, img);
});
function onImagePreloaded() {
loaded++;
if (loaded === paths.length && callback) {
callback(preImages);
}
}
}
CWSYSTEM.Global.__static_initialize();
dsector.DSGlobal.__static_initialize();
CWSYSTEM.CWUtils.__static_initialize();
CWSYSTEM.Environment.__static_initialize();
dsector.DSecPlayWindow.__static_initialize();
CWSYSTEM.Global.initialize();
preloadImages(preImages);
import * as THREE from 'three';
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, 1.3333, 0.1, 1000);
const renderer = new THREE.WebGLRenderer();
renderer.setSize(800, 600);
document.body.appendChild(renderer.domElement);
let dsMain;
const planeGeometry = new THREE.PlaneGeometry(5, 5); // Adjust the size as needed
const texture = new THREE.TextureLoader().load('assets/images/dsectorTitle.jpg');//new THREE.CanvasTexture(imgdata); // Create the texture using ImageData
const material = new THREE.MeshBasicMaterial({map: texture});
const plane = new THREE.Mesh(planeGeometry, material);
scene.add(plane);
camera.position.z = 5; // Adjust the camera position as needed
// Post-loading functions and processes
document.addEventListener('DOMContentLoaded', function () {
document.body.addEventListener("contextmenu", function (evt) {
evt.preventDefault();
return false;
});
preloadImages(preImages);
dsMain = new dsector.DSMain();
dsMain.main();
});
</script>
</body>
</html>