try to fix problem of 3d preview

This commit is contained in:
printempw 2016-03-05 21:03:22 +08:00
parent 537fe6a5bf
commit 88ecd13c24
2 changed files with 23 additions and 13 deletions

View File

@ -2,7 +2,7 @@
* @Author: prpr
* @Date: 2016-01-21 13:56:40
* @Last Modified by: printempw
* @Last Modified time: 2016-03-05 18:41:09
* @Last Modified time: 2016-03-05 20:36:43
*/
'use strict';
@ -51,11 +51,11 @@ function handleFiles(files, type) {
var run = false, stop = false;
$("[title='Movements']").click(function(){
stop = !stop;
MSP.stopPlay(stop);
speed = stop ? 0 : 1;
});
$("[title='Running']").click(function(){
run = !run;
MSP.playQuickly(run);
speed = run ? 4 : 1;
});
$('#model-alex').on('change', function() {

View File

@ -48,9 +48,9 @@ scene = new THREE.Scene();
// Skin Part
canvas = document.createElement('canvas');;
canvas.width = 64;
canvas.height = 64;
var context = canvas.getContext("2d");
canvas.width = 64;
canvas.height = 64;
var context = canvas.getContext("2d");
var skinTexture = new THREE.Texture(canvas);
skinTexture.magFilter = THREE.NearestFilter;
@ -878,7 +878,7 @@ function RenderSkin() {
container = document.getElementById('skinpreview');
renderer = new THREE.WebGLRenderer({alpha: true});
onWindowResize();
renderer.setSize(600, 350);
window.addEventListener('resize', onWindowResize, false);
@ -898,20 +898,30 @@ function RenderSkin() {
isMouseDown = false;
}, false);
container.appendChild(renderer.domElement);
var canvas3d = renderer.domElement;
canvas3d.setAttribute('id', 'canvas3d');
canvas3d.style = '';
container.appendChild(canvas3d);
onWindowResize();
}
function onWindowResize() {
camera.aspect = (window.innerWidth - sidebarWidth) / window.innerHeight;
camera.updateProjectionMatrix();
if (window.innerWidth > 768) {
renderer.setSize(container.clientWidth, container.clientWidth/1.8);
} else {
renderer.setSize(container.clientWidth/1.5, container.clientWidth/1.8);
}
var canvas3d = document.getElementById('canvas3d');
canvas3d.width = 600;
canvas3d.height = 350;
canvas3d.setSize(container.clientWidth, container.clientWidth/12*7);
}
Element.prototype.setSize = function (w, h) {
this.style.width = w + "px";
this.style.height = h + "px";
return this;
};
function Animate() {
scene.getObjectByName("cape", false).visible = capeLoaded;