mirror of
https://github.com/beestat/app.git
synced 2025-05-24 02:14:03 -04:00
A few more fixes to scene rendering/resizing
This commit is contained in:
parent
4fa7651189
commit
35d4d0b1f3
@ -27,6 +27,7 @@ beestat.component.card.three_d = function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
beestat.dispatcher.addEventListener('cache.data.three_d__runtime_sensor', function() {
|
beestat.dispatcher.addEventListener('cache.data.three_d__runtime_sensor', function() {
|
||||||
|
self.state_.scene_camera_state = self.scene_.get_camera_state();
|
||||||
self.get_data_(true);
|
self.get_data_(true);
|
||||||
self.rerender();
|
self.rerender();
|
||||||
});
|
});
|
||||||
@ -322,15 +323,25 @@ beestat.component.card.three_d.prototype.decorate_drawing_pane_ = function(paren
|
|||||||
this.scene_.set_date(this.date_m_);
|
this.scene_.set_date(this.date_m_);
|
||||||
|
|
||||||
// Manage width of the scene.
|
// Manage width of the scene.
|
||||||
setTimeout(function() {
|
if (this.state_.width === undefined) {
|
||||||
if (parent.getBoundingClientRect().width > 0) {
|
setTimeout(function() {
|
||||||
self.scene_.set_width(parent.getBoundingClientRect().width);
|
if (parent.getBoundingClientRect().width > 0) {
|
||||||
}
|
self.state_.width = parent.getBoundingClientRect().width;
|
||||||
}, 0);
|
self.scene_.set_width(self.state_.width);
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
|
} else {
|
||||||
|
this.scene_.set_width(this.state_.width);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.state_.scene_camera_state !== undefined) {
|
||||||
|
this.scene_.set_camera_state(this.state_.scene_camera_state);
|
||||||
|
}
|
||||||
|
|
||||||
beestat.dispatcher.removeEventListener('resize.three_d');
|
beestat.dispatcher.removeEventListener('resize.three_d');
|
||||||
beestat.dispatcher.addEventListener('resize.three_d', function() {
|
beestat.dispatcher.addEventListener('resize.three_d', function() {
|
||||||
self.scene_.set_width(parent.getBoundingClientRect().width);
|
self.state_.width = parent.getBoundingClientRect().width;
|
||||||
|
self.scene_.set_width(self.state_.width);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -65,7 +65,6 @@ beestat.component.scene.prototype.set_width = function(width) {
|
|||||||
this.camera_.updateProjectionMatrix();
|
this.camera_.updateProjectionMatrix();
|
||||||
|
|
||||||
this.renderer_.setSize(this.width_, this.height_);
|
this.renderer_.setSize(this.width_, this.height_);
|
||||||
this.renderer_.render(this.scene_, this.camera_);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -92,7 +91,7 @@ beestat.component.scene.prototype.decorate_ = function(parent) {
|
|||||||
this.height_ = 500;
|
this.height_ = 500;
|
||||||
|
|
||||||
this.add_scene_(parent);
|
this.add_scene_(parent);
|
||||||
this.add_background_(parent);
|
// this.add_background_(parent);
|
||||||
this.add_renderer_(parent);
|
this.add_renderer_(parent);
|
||||||
this.add_camera_();
|
this.add_camera_();
|
||||||
this.add_controls_(parent);
|
this.add_controls_(parent);
|
||||||
@ -181,6 +180,9 @@ beestat.component.scene.prototype.add_renderer_ = function(parent) {
|
|||||||
this.renderer_ = new THREE.WebGLRenderer({
|
this.renderer_ = new THREE.WebGLRenderer({
|
||||||
'antialias': true
|
'antialias': true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.renderer_.setSize(this.width_, this.height_);
|
||||||
|
|
||||||
// this.renderer_.setSize(window.innerWidth, window.innerHeight);
|
// this.renderer_.setSize(window.innerWidth, window.innerHeight);
|
||||||
// this.renderer_.shadowMap.enabled = true;
|
// this.renderer_.shadowMap.enabled = true;
|
||||||
// this.renderer_.shadowMap.autoUpdate = false;
|
// this.renderer_.shadowMap.autoUpdate = false;
|
||||||
@ -725,9 +727,9 @@ beestat.component.scene.prototype.update_ = function() {
|
|||||||
/**
|
/**
|
||||||
* Add a background.
|
* Add a background.
|
||||||
*/
|
*/
|
||||||
beestat.component.scene.prototype.add_background_ = function() {
|
// beestat.component.scene.prototype.add_background_ = function() {
|
||||||
this.scene_.background = new THREE.Color(beestat.style.color.bluegray.dark);
|
// this.scene_.background = new THREE.Color(beestat.style.color.bluegray.dark);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -995,3 +997,26 @@ beestat.component.scene.prototype.set_gradient = function(gradient) {
|
|||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the state of the camera.
|
||||||
|
*
|
||||||
|
* @return {object}
|
||||||
|
*/
|
||||||
|
beestat.component.scene.prototype.get_camera_state = function() {
|
||||||
|
return this.camera_.matrix.toArray();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restore the state of the camera.
|
||||||
|
*
|
||||||
|
* @param {object} camera_state
|
||||||
|
*/
|
||||||
|
beestat.component.scene.prototype.set_camera_state = function(camera_state) {
|
||||||
|
this.camera_.matrix.fromArray(camera_state);
|
||||||
|
this.camera_.matrix.decompose(
|
||||||
|
this.camera_.position,
|
||||||
|
this.camera_.quaternion,
|
||||||
|
this.camera_.scale
|
||||||
|
);
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user