the-world-engine
Version:
three.js based, unity like game engine for browser
105 lines (103 loc) • 3.2 kB
JavaScript
import { Transform } from "../../hierarchy_object/Transform";
import { CssRenderer } from "./CssRenderer";
export class CssIframeRenderer extends CssRenderer {
Qe=4;
Ve=4;
qa="";
Ba="";
Ha=false;
Ja="";
renderInitialize() {
this.htmlElement = document.createElement("iframe");
this.htmlElement.title = this.gameObject.name + "_iframe";
this.htmlElement.width = (this.Qe / this.viewScale).toString();
this.htmlElement.height = (this.Ve / this.viewScale).toString();
this.htmlElement.src = this.qa;
this.htmlElement.allow = this.Ba;
this.htmlElement.allowFullscreen = this.Ha;
this.htmlElement.referrerPolicy = this.Ja;
this.htmlElement.style.border = "none";
const t = this.initializeBaseComponents(false);
t.scale.set(this.viewScale, this.viewScale, this.viewScale);
Transform.updateRawObject3DWorldMatrixRecursively(t);
this.transform.enqueueRenderAttachedObject3D(t);
}
updateCenterOffset(t) {
if (!this.css3DObject) return;
this.css3DObject.position.set(this.Qe * this.centerOffset.x, this.Ve * this.centerOffset.y, 0);
if (t) {
Transform.updateRawObject3DWorldMatrixRecursively(this.css3DObject);
this.transform.enqueueRenderAttachedObject3D(this.css3DObject);
}
}
updateViewScale(t) {
if (!this.css3DObject) return;
const i = this.viewScale;
this.htmlElement.width = (this.Qe / this.viewScale).toString();
this.htmlElement.height = (this.Ve / this.viewScale).toString();
this.css3DObject.scale.set(i, i, i);
if (t) {
Transform.updateRawObject3DWorldMatrixRecursively(this.css3DObject);
this.transform.enqueueRenderAttachedObject3D(this.css3DObject);
}
}
get width() {
return this.Qe;
}
set width(t) {
this.Qe = t;
if (this.htmlElement) {
this.htmlElement.width = (t / this.viewScale).toString();
}
this.updateCenterOffset(true);
}
get height() {
return this.Ve;
}
set height(t) {
this.Ve = t;
if (this.htmlElement) {
this.htmlElement.height = (t / this.viewScale).toString();
}
this.updateCenterOffset(true);
}
get iframeSource() {
return this.qa;
}
set iframeSource(t) {
this.qa = t;
if (this.htmlElement) {
this.htmlElement.src = t;
}
}
get allow() {
return this.Ba;
}
set allow(t) {
this.Ba = t;
if (this.htmlElement) {
this.htmlElement.allow = t;
}
}
get allowFullscreen() {
return this.Ha;
}
set allowFullscreen(t) {
this.Ha = t;
}
get contentDocument() {
return this.htmlElement?.contentDocument ?? null;
}
get contentWindow() {
return this.htmlElement?.contentWindow ?? null;
}
get referrerPolicy() {
return this.Ja;
}
set referrerPolicy(t) {
this.Ja = t;
if (this.htmlElement) {
this.htmlElement.referrerPolicy = t;
}
}
}