Commit 0c6b6e75 authored by lixiaoyi's avatar lixiaoyi

update 模型颜色

parent c70549dd
File added
......@@ -8,7 +8,7 @@ export const environments = [
{
id: 'venice-sunset',
name: 'Venice Sunset',
path: './js/venice_sunset_1k.hdr',
path: './js/0615.hdr',
format: '.hdr'
},
{
......
......@@ -20,7 +20,6 @@ import {
import {
DRACOLoader
} from './jsm/loaders/DRACOLoader.js';
let mixer;
const clock = new THREE.Clock();
const container = document.getElementsByClassName('main')[0];
const renderer = new THREE.WebGLRenderer({
......@@ -37,8 +36,6 @@ scene.background = new THREE.Color(0x0C1C38);
scene.environment = pmremGenerator.fromScene(new RoomEnvironment(), 0.04).texture;
var select = '没有选中' //判断table有没有选中变量
const camera = new THREE.PerspectiveCamera(40, window.innerWidth / window.innerHeight, 1, 100);
var allanimations = [] //打簧机的动画组合
var allanimations1 = [] //绕线机的动画组合
camera.position.set(5, 4, 1.5);
var num = 0
var clipAction = []
......@@ -55,35 +52,8 @@ dracoLoader.setDecoderPath('js/libs/draco/gltf/');
var variablearr = [] //选中变量的组合
var oldvariablearr = [] //变量旧值的组合
let needUpdateModel = false; // 是否需要更新模型
// 打簧机动画下标
var numarr = {
num0: 0,
num1: 0,
num2: 0,
num3: 0,
num4: 0,
num5: 0,
num6: 0,
num7: 0,
num8: 0,
num9: 0,
num10: 0
}
// 绕线机动画下标
var numarr1 = {
num0: 0,
num1: 0,
num2: 0,
num3: 0,
num4: 0,
num5: 0,
num6: 0,
num7: 0,
num8: 0,
num9: 0,
num10: 0,
num11: 0
}
let allmixer1;
let allmixer2;
if (localStorage.getItem('b1')) {
$('.b1')[0].innerText = localStorage.getItem('b1')
}
......@@ -461,18 +431,16 @@ var arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k']
//绕线机模型的名称
var arr1 = ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll']
for (let i in arr) {
await allpromise(arr[i])
}
allpromise()
allpromise1()
for (let i in arr) {
await promise(arr[i])
}
for (let i in arr1) {
await promise2(arr1[i])
}
for (let i in arr1) {
await allpromise1(arr1[i])
}
tb(onetable, mixerarr)
tb(twotable, mixerarr)
variablearr = [...new Set(variablearr)]
......@@ -491,62 +459,10 @@ function animate() {
requestAnimationFrame(animate);
const delta = clock.getDelta();
if ($('.b1')[0].innerText == '变量运行') {
document.getElementById('fileDragArea').style.display = 'none'
allanimations.forEach((item, key) => {
item.allmixer1.update(delta)
if (item.animations.length !== 0) {
if (numarr['num' + key] > item.animations.length - 1) {
numarr['num' + key] = 0
}
item.animations[numarr['num' + key]].clipAction.play()
if (item.animations[numarr['num' + key]]) {
if (item.animations[numarr['num' + key]].clipAction.time === item.animations[numarr['num' + key]].clipAction._clip
.duration) {
numarr['num' + key]++;
if (item.animations[numarr['num' + key]]) {
item.animations[numarr['num' + key]].clipAction.play()
setTimeout(() => {
s(item.animations, numarr['num' + key])
})
}
}
}
}
})
allanimations1.forEach((item, key) => {
item.allmixer2.update(delta)
if (item.animations.length !== 0) {
if (numarr1['num' + key] > item.animations.length - 1) {
numarr1['num' + key] = 0
}
item.animations[numarr1['num' + key]].clipAction.play()
if (item.animations[numarr1['num' + key]]) {
if (item.animations[numarr1['num' + key]].clipAction.time === item.animations[numarr1['num' + key]].clipAction._clip
.duration) {
numarr1['num' + key]++;
if (item.animations[numarr1['num' + key]]) {
item.animations[numarr1['num' + key]].clipAction.play()
setTimeout(() => {
s(item.animations, numarr1['num' + key])
})
}
}
}
}
})
allmixer1 && allmixer1.update( delta );
allmixer2 && allmixer2.update(delta)
} else {
mixerarr.forEach((item) => {
item.mixer1.update(delta)
......@@ -791,79 +707,52 @@ function promise3(a, b, c, d) {
})
}
var initvalue = 0
var allmixer1 = ''
function allpromise(a, c) {
function allpromise() {
return new Promise((resolve, reject) => {
loader.load('models/gltf/动画组/' + a + '.glb', function(gltf) {
loader.load('models/gltf/dahuangji.glb', function(gltf) {
const model = gltf.scene;
allmixer1 = new THREE.AnimationMixer(model);
let animations = []
gltf.animations.forEach((item1, key) => {
allmixer1.clipAction(item1).clampWhenFinished = true
allmixer1.clipAction(item1).setLoop(THREE.LoopOnce, 0)
animations.push({
clipAction: allmixer1.clipAction(item1)
})
})
allanimations.push({
allmixer1,
animations
})
group2.add(model)
group2.name = '打簧机11'
group2.position.set(1, 0.3, 1.2);
group2.scale.set(1.2, 1.2, 1.2);
scene.add(group2)
allmixer1 = new THREE.AnimationMixer( group2 );
allmixer1.clipAction( gltf.animations[ 0 ] ).play();
animate()
if (localStorage.getItem('moxi1') && localStorage.getItem('b1') == '整体运行') {
group2.visible = false
} else if ($('.b1')[0].innerText == '变量运行') {
group2.visible = true
} else {
group2.visible = false
}
if (a == 'k') {
group2.name = '打簧机1'
group2.position.set(1, 0.3, 1.2);
group2.scale.set(1.2, 1.2, 1.2);
// console.log(gltf)
scene.add(group2)
group2.visible = $('.b1')[0].innerText == '变量运行'
}
resolve()
})
})
}
var allmixer2 = ''
function allpromise1(a, c) {
function allpromise1() {
return new Promise((resolve, reject) => {
loader.load('models/gltf/绕线机glb220429/' + a + '.glb', function(gltf) {
loader.load('models/gltf/raoxianji.glb', function(gltf) {
const model = gltf.scene;
allmixer2 = new THREE.AnimationMixer(model);
let animations = []
gltf.animations.forEach((item1, key) => {
allmixer2.clipAction(item1).clampWhenFinished = true
allmixer2.clipAction(item1).setLoop(THREE.LoopOnce, 0)
animations.push({
clipAction: allmixer2.clipAction(item1)
})
})
allanimations1.push({
allmixer2,
animations
})
group3.add(model)
if (localStorage.getItem('moxi2')) {
group3.name = '绕线机11'
group3.position.set(0.93, 1.15, -1.55);
group3.scale.set(1.2, 1.2, 1.2);
scene.add(group3)
allmixer2 = new THREE.AnimationMixer( group3 );
allmixer2.clipAction( gltf.animations[ 0 ] ).play();
animate()
if (localStorage.getItem('moxi2') && localStorage.getItem('b1') == '整体运行') {
group3.visible = false
} else if ($('.b1')[0].innerText == '变量运行') {
group3.visible = true
} else {
group3.visible = false
}
if (a == 'll') {
group3.name = '绕线机1'
group3.position.set(0.93, 1.15, -1.55);
group3.scale.set(1.2, 1.2, 1.2);
scene.add(group3)
group3.visible = $('.b1')[0].innerText == '变量运行'
}
resolve()
})
......@@ -942,7 +831,6 @@ function promise(a, c) {
group.name = '打簧机'
group.position.set(1, 0.3, 1.2);
group.scale.set(1.2, 1.2, 1.2);
// console.log(gltf)
scene.add(group)
}
resolve()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment