| 1092 | private _resize = this.resize.bind(this); |
| 1093 | private _onVisibility?: () => void; |
| 1094 | constructor(props: any) { |
| 1095 | this.props = props; |
| 1096 | Common.init(props.$wrapper); |
| 1097 | Mouse.init(props.$wrapper); |
| 1098 | Mouse.autoIntensity = props.autoIntensity; |
| 1099 | Mouse.takeoverDuration = props.takeoverDuration; |
| 1100 | Mouse.onInteract = () => { |
| 1101 | this.lastUserInteraction = performance.now(); |
| 1102 | if (this.autoDriver) this.autoDriver.forceStop(); |
| 1103 | }; |
| 1104 | this.autoDriver = new AutoDriver(Mouse, this as any, { |
| 1105 | enabled: props.autoDemo, |
| 1106 | speed: props.autoSpeed, |
| 1107 | resumeDelay: props.autoResumeDelay, |
| 1108 | rampDuration: props.autoRampDuration, |
| 1109 | }); |
| 1110 | this.init(); |
| 1111 | window.addEventListener("resize", this._resize); |
| 1112 | this._onVisibility = () => { |
| 1113 | const hidden = document.hidden; |
| 1114 | if (hidden) { |
| 1115 | this.pause(); |
| 1116 | } else if (isVisibleRef.current) { |
| 1117 | this.start(); |
| 1118 | } |
| 1119 | }; |
| 1120 | document.addEventListener("visibilitychange", this._onVisibility); |
| 1121 | } |
| 1122 | init() { |
| 1123 | if (!Common.renderer) return; |
| 1124 | this.props.$wrapper.prepend(Common.renderer.domElement); |