feat:初始一次js文件格式化
parent
f374f4c12c
commit
d4602681c7
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,18 +1,17 @@
|
|||||||
function Debug(){
|
function Debug() {
|
||||||
this.res_count = 0;
|
this.res_count = 0;
|
||||||
|
|
||||||
this.alloc = function(){
|
this.alloc = function () {
|
||||||
this.res_count++;
|
this.res_count++;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.free = function(){
|
this.free = function () {
|
||||||
this.res_count--;
|
this.res_count--;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.dump = function(){
|
this.dump = function () {
|
||||||
console.log(`number of resources: ${this.res_count}`);
|
console.log(`number of resources: ${this.res_count}`);
|
||||||
}
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
export {Debug};
|
|
||||||
|
|
||||||
|
export { Debug };
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,30 +1,27 @@
|
|||||||
import { logger } from "./log.js";
|
import { logger } from "./log.js";
|
||||||
|
|
||||||
|
function checkScene(scene) {
|
||||||
function checkScene(scene)
|
|
||||||
{
|
|
||||||
const req = new Request(`/checkscene?scene=${scene}`);
|
const req = new Request(`/checkscene?scene=${scene}`);
|
||||||
let init = {
|
let init = {
|
||||||
method: 'GET',
|
method: "GET",
|
||||||
//body: JSON.stringify({"points": data})
|
//body: JSON.stringify({"points": data})
|
||||||
};
|
};
|
||||||
// we defined the xhr
|
// we defined the xhr
|
||||||
|
|
||||||
return fetch(req, init)
|
return fetch(req, init)
|
||||||
.then(response=>{
|
.then((response) => {
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`HTTP error! status: ${response.status}`);
|
throw new Error(`HTTP error! status: ${response.status}`);
|
||||||
}else{
|
} else {
|
||||||
return response.json();
|
return response.json();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(ret=>
|
.then((ret) => {
|
||||||
{
|
|
||||||
logger.setErrorsContent(ret);
|
logger.setErrorsContent(ret);
|
||||||
})
|
})
|
||||||
.catch(reject=>{
|
.catch((reject) => {
|
||||||
console.log("error check scene!");
|
console.log("error check scene!");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export {checkScene}
|
export { checkScene };
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,42 +1,30 @@
|
|||||||
|
class KeyDownManager {
|
||||||
|
|
||||||
class KeyDownManager
|
|
||||||
{
|
|
||||||
|
|
||||||
handlerList = [];
|
handlerList = [];
|
||||||
|
|
||||||
// return id;
|
// return id;
|
||||||
register(handler, name)
|
register(handler, name) {
|
||||||
{
|
|
||||||
this.handlerList.push([name, handler]);
|
this.handlerList.push([name, handler]);
|
||||||
console.log("register keydown", name);
|
console.log("register keydown", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
deregister(name)
|
deregister(name) {
|
||||||
{
|
|
||||||
console.log("deregister keydown", name);
|
console.log("deregister keydown", name);
|
||||||
this.handlerList = this.handlerList.filter(v=>v[0]!== name);
|
this.handlerList = this.handlerList.filter((v) => v[0] !== name);
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor()
|
constructor() {
|
||||||
{
|
document.addEventListener("keydown", (event) => {
|
||||||
document.addEventListener( 'keydown', (event)=>{
|
for (let i = this.handlerList.length - 1; i >= 0; i--) {
|
||||||
|
|
||||||
for (let i = this.handlerList.length-1; i >= 0; i--)
|
|
||||||
{
|
|
||||||
let ret = this.handlerList[i][1](event);
|
let ret = this.handlerList[i][1](event);
|
||||||
|
|
||||||
if (!ret)
|
if (!ret) {
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var globalKeyDownManager = new KeyDownManager();
|
var globalKeyDownManager = new KeyDownManager();
|
||||||
|
|
||||||
export{globalKeyDownManager};
|
export { globalKeyDownManager };
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,6 @@
|
|||||||
var settings= {
|
var settings = {
|
||||||
ground_filter_height: 0.2,
|
ground_filter_height: 0.2,
|
||||||
initial_z_position: -0.9,
|
initial_z_position: -0.9,
|
||||||
|
};
|
||||||
|
|
||||||
}
|
export { settings };
|
||||||
|
|
||||||
export {settings}
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,80 +1,84 @@
|
|||||||
|
import * as THREE from "./lib/three.module.js";
|
||||||
|
|
||||||
import * as THREE from './lib/three.module.js';
|
|
||||||
//import Stats from './lib/stats.module.js';
|
//import Stats from './lib/stats.module.js';
|
||||||
import { OrthographicTrackballControls } from './lib/OrthographicTrackballControls.js';
|
import { OrthographicTrackballControls } from "./lib/OrthographicTrackballControls.js";
|
||||||
var camera, controls, scene, renderer, stats;
|
var camera, controls, scene, renderer, stats;
|
||||||
init();
|
init();
|
||||||
animate();
|
animate();
|
||||||
function init() {
|
function init() {
|
||||||
camera = new THREE.OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, 1, 2000 );
|
camera = new THREE.OrthographicCamera(
|
||||||
|
window.innerWidth / -2,
|
||||||
|
window.innerWidth / 2,
|
||||||
|
window.innerHeight / 2,
|
||||||
|
window.innerHeight / -2,
|
||||||
|
1,
|
||||||
|
2000
|
||||||
|
);
|
||||||
camera.position.z = 1000;
|
camera.position.z = 1000;
|
||||||
// world
|
// world
|
||||||
scene = new THREE.Scene();
|
scene = new THREE.Scene();
|
||||||
scene.background = new THREE.Color( 0xcccccc );
|
scene.background = new THREE.Color(0xcccccc);
|
||||||
scene.fog = new THREE.FogExp2( 0xcccccc, 0.001 );
|
scene.fog = new THREE.FogExp2(0xcccccc, 0.001);
|
||||||
var geometry = new THREE.CylinderBufferGeometry( 0, 10, 30, 4, 1 );
|
var geometry = new THREE.CylinderBufferGeometry(0, 10, 30, 4, 1);
|
||||||
var material = new THREE.MeshPhongMaterial( { color: 0xffffff, flatShading: true } );
|
var material = new THREE.MeshPhongMaterial({
|
||||||
for ( var i = 0; i < 50; i ++ ) {
|
color: 0xffffff,
|
||||||
var mesh = new THREE.Mesh( geometry, material );
|
flatShading: true,
|
||||||
mesh.position.x = ( Math.random() - 0.5 ) * 1000;
|
});
|
||||||
mesh.position.y = ( Math.random() - 0.5 ) * 1000;
|
for (var i = 0; i < 50; i++) {
|
||||||
mesh.position.z = ( Math.random() - 0.5 ) * 1000;
|
var mesh = new THREE.Mesh(geometry, material);
|
||||||
|
mesh.position.x = (Math.random() - 0.5) * 1000;
|
||||||
|
mesh.position.y = (Math.random() - 0.5) * 1000;
|
||||||
|
mesh.position.z = (Math.random() - 0.5) * 1000;
|
||||||
mesh.updateMatrix();
|
mesh.updateMatrix();
|
||||||
mesh.matrixAutoUpdate = false;
|
mesh.matrixAutoUpdate = false;
|
||||||
scene.add( mesh );
|
scene.add(mesh);
|
||||||
}
|
}
|
||||||
// lights
|
// lights
|
||||||
var light = new THREE.DirectionalLight( 0xffffff );
|
var light = new THREE.DirectionalLight(0xffffff);
|
||||||
light.position.set( 1, 1, 1 );
|
light.position.set(1, 1, 1);
|
||||||
scene.add( light );
|
scene.add(light);
|
||||||
var light = new THREE.DirectionalLight( 0x002288 );
|
var light = new THREE.DirectionalLight(0x002288);
|
||||||
light.position.set( - 1, - 1, - 1 );
|
light.position.set(-1, -1, -1);
|
||||||
scene.add( light );
|
scene.add(light);
|
||||||
var light = new THREE.AmbientLight( 0x222222 );
|
var light = new THREE.AmbientLight(0x222222);
|
||||||
scene.add( light );
|
scene.add(light);
|
||||||
// renderer
|
// renderer
|
||||||
renderer = new THREE.WebGLRenderer( { antialias: true } );
|
renderer = new THREE.WebGLRenderer({ antialias: true });
|
||||||
renderer.setPixelRatio( window.devicePixelRatio );
|
renderer.setPixelRatio(window.devicePixelRatio);
|
||||||
renderer.setSize( window.innerWidth, window.innerHeight );
|
renderer.setSize(window.innerWidth, window.innerHeight);
|
||||||
document.body.appendChild( renderer.domElement );
|
document.body.appendChild(renderer.domElement);
|
||||||
|
|
||||||
|
|
||||||
|
controls = new OrthographicTrackballControls(camera, renderer.domElement);
|
||||||
controls = new OrthographicTrackballControls( camera, renderer.domElement );
|
|
||||||
controls.rotateSpeed = 1.0;
|
controls.rotateSpeed = 1.0;
|
||||||
controls.zoomSpeed = 1.2;
|
controls.zoomSpeed = 1.2;
|
||||||
controls.noZoom = false;
|
controls.noZoom = false;
|
||||||
controls.noPan = false;
|
controls.noPan = false;
|
||||||
controls.staticMoving = true;
|
controls.staticMoving = true;
|
||||||
controls.dynamicDampingFactor = 0.3;
|
controls.dynamicDampingFactor = 0.3;
|
||||||
controls.keys = [ 65, 83, 68 ];
|
controls.keys = [65, 83, 68];
|
||||||
controls.addEventListener( 'change', render );
|
controls.addEventListener("change", render);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//stats = new Stats();
|
//stats = new Stats();
|
||||||
//document.body.appendChild( stats.dom );
|
//document.body.appendChild( stats.dom );
|
||||||
//
|
//
|
||||||
window.addEventListener( 'resize', onWindowResize, false );
|
window.addEventListener("resize", onWindowResize, false);
|
||||||
//
|
//
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
function onWindowResize() {
|
function onWindowResize() {
|
||||||
camera.left = window.innerWidth / - 2;
|
camera.left = window.innerWidth / -2;
|
||||||
camera.right = window.innerWidth / 2;
|
camera.right = window.innerWidth / 2;
|
||||||
camera.top = window.innerHeight / 2;
|
camera.top = window.innerHeight / 2;
|
||||||
camera.bottom = window.innerHeight / - 2;
|
camera.bottom = window.innerHeight / -2;
|
||||||
camera.updateProjectionMatrix();
|
camera.updateProjectionMatrix();
|
||||||
renderer.setSize( window.innerWidth, window.innerHeight );
|
renderer.setSize(window.innerWidth, window.innerHeight);
|
||||||
controls.handleResize();
|
controls.handleResize();
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
function animate() {
|
function animate() {
|
||||||
requestAnimationFrame( animate );
|
requestAnimationFrame(animate);
|
||||||
controls.update();
|
controls.update();
|
||||||
//stats.update();
|
//stats.update();
|
||||||
}
|
}
|
||||||
function render() {
|
function render() {
|
||||||
renderer.render( scene, camera );
|
renderer.render(scene, camera);
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue