Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Signboards Poster of Labex IMU studio #376

Merged
merged 5 commits into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 9 additions & 7 deletions client/assets/localScripts/Signboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ module.exports = class Signboard {
const go = arguments[0];

this.renderPlane = go.getComponent(Game.Render.TYPE);

if (go.children[0].name === 'Frame') {
const renderFrame = go.children[0].getComponent(Game.Render.TYPE);
if (renderFrame) {
this.renderFrame = go.children[0].getComponent(Game.Render.TYPE);
} else {
console.error("Signboard's first child should be a Frame");
console.error(
'No render component found for the first child of the game object'
);
}

this.buildMesh();
Expand Down Expand Up @@ -65,12 +67,12 @@ module.exports = class Signboard {
const _this = this;
/* Loading the image from the url and then using the image to create the signboard. */
new THREE.TextureLoader().load(imageURL, function (texture) {
let h = texture.image.height;
let w = texture.image.width;
const heightImage = texture.image.height;
const widthImage = texture.image.width;
const sF = _this.sizeFactor;

h = h > w ? sF : (h / w) * sF;
w = w > h ? sF : (w / h) * sF;
const h = heightImage > widthImage ? sF : (heightImage / widthImage) * sF;
const w = widthImage > heightImage ? sF : (widthImage / heightImage) * sF;

_this.planeFrontBuilded = _this.buildPlaneFront(texture, h, w);
_this.renderPlane.addObject3D(_this.planeFrontBuilded);
Expand Down
Loading