Skip to content

Commit

Permalink
add sampleCube
Browse files Browse the repository at this point in the history
  • Loading branch information
leoncoolmoon committed Sep 4, 2023
1 parent f783965 commit 32f678d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
/* background-color: lightgray; */
/* display: block; */
z-index: 100;
display: block;
display: none;
justify-content: center;
align-items: center;
}
Expand Down
34 changes: 31 additions & 3 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

var cubeRenderer, cubeScene, cubeMesh, cubeCamera, cubeControls, cubeContainer, cubeCamZ, cubeCamY, cubeCamX;
var renderer, scene, camera, controls, stats, CamZ, CamY, CamX;
var sampleCube;
var isDragging = false;
var axises, cubeAxises, gCode, tGcode, sTl, isolateModel = new THREE.Group();
var selectedLineContent;
Expand Down Expand Up @@ -679,6 +680,7 @@ function read_file(file) {
alert("file size is too big");
return;
}
scene.remove(sampleCube);
if (gCode !== undefined) {
gCodeClear();
txar.setValue("");
Expand Down Expand Up @@ -998,7 +1000,7 @@ function init() {
// 调用函数禁用键盘输入
disableKeyboardInput();
camera = new THREE.PerspectiveCamera(75, document.documentElement.clientWidth /document.documentElement.clientHeight, 0.1, 1000);
console.log("init, width:" + document.documentElement.clientWidth + ",height:" +document.documentElement.clientHeight);
//console.log("init, width:" + document.documentElement.clientWidth + ",height:" +document.documentElement.clientHeight);
camera.position.set(0, -200, 200);
camera.up = new THREE.Vector3(0, 0, 1);

Expand All @@ -1016,7 +1018,7 @@ function init() {
menu.style.zIndex = '100';
menu.style.color = 'white';

console.log('check0 width:' + document.documentElement.clientWidth + ' height:' +document.documentElement.clientHeight);
//console.log('check0 width:' + document.documentElement.clientWidth + ' height:' +document.documentElement.clientHeight);

codeViewer = document.getElementById('codeViewer');
codeViewer.style.position = 'absolute';
Expand Down Expand Up @@ -1128,7 +1130,32 @@ function init() {
axises.add(coneZMesh);

scene.add(axises);

//创建实例矩形
var loader = new THREE.TextureLoader();
loader.setCrossOrigin('anonymous');
var textures = [
loader.load('alipay.jpg'),
loader.load('paypal.jpg'),
loader.load('wechat.jpg')
];
// var texture = loader.load('alipay.jpg', function(texture) {
// console.log('Texture loaded');
// }, undefined, function(error) {
// console.log('Error loading texture:', error);
// });
//if(textures[0]) { console.log('Texture loaded'); }else{console.log('Texture not loaded');}
var materials = [
new THREE.MeshBasicMaterial({map: textures[0]}),
new THREE.MeshBasicMaterial({map: textures[1]}),
new THREE.MeshBasicMaterial({map: textures[2]}),
new THREE.MeshBasicMaterial({map: textures[0]}),
new THREE.MeshBasicMaterial({map: textures[1]}),
new THREE.MeshBasicMaterial({map: textures[2]})
];

var sampleGeometry = new THREE.BoxGeometry(198, 198, 198);
sampleCube = new THREE.Mesh(sampleGeometry, materials);
scene.add(sampleCube);

// 视角控制器
//创建一个用于显示小立方体的HTML元素,并将其添加到页面的适当位置。为了在右上角显示,并设置合适的top和right样式属性。
Expand Down Expand Up @@ -1345,6 +1372,7 @@ function createTextTexture(text) {

return texture;
}

//初始化性能插件
function initStats() {
stats = new Stats();
Expand Down

0 comments on commit 32f678d

Please sign in to comment.