Sie sind nicht angemeldet.

1

Samstag, 11. März 2023, 17:19

How to remove or disable plugin when change scene?

I added plugin ThreeJs to show model 3D , but the problem is it show model 3d in all scene, i just want it show in a scene, how to do it?
i tried with set(plugin[threejs].visible,false) and removeplugin(threejs) but it's not work *whistling*

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<plugin name="threejs" url="gltfloader.js" keep="true" /><action name="remove">js(console.log("Test"))set(plugin[threejs].visible,false)
</action>
		<scene name="scene_1" title="0" onstart="remove()"  thumburl="panos/1.tiles/thumb.jpg" lat="" lng="" heading="">
		<view hlookat="1.245" vlookat="-14.021" fovtype="MFOV" fov="140.000" maxpixelzoom="2.0" fovmin="70" fovmax="140" limitview="auto" />
		<preview url="panos/1.tiles/preview.jpg" />
		<image type="CUBE" multires="true" tilesize="512">			<level tiledimagewidth="2624" tiledimageheight="2624">				<cube url="panos/1.tiles/%s/l3/%v/l3_%s_%v_%h.jpg" />			</level>			<level tiledimagewidth="1280" tiledimageheight="1280">				<cube url="panos/1.tiles/%s/l2/%v/l2_%s_%v_%h.jpg" />			</level>			<level tiledimagewidth="640" tiledimageheight="640">				<cube url="panos/1.tiles/%s/l1/%v/l1_%s_%v_%h.jpg" />			</level>		</image>		<hotspot name="scene_2" style="hs_circle" ath="-1.231" atv="-2.748" tag="1" />
	</scene>
	<scene name="scene_2" title="1" onstart="" thumburl="panos/2.tiles/thumb.jpg" lat="" lng="" heading="">
		<view hlookat="6.420" vlookat="-11.392" fovtype="MFOV" fov="120.000" maxpixelzoom="2.0" fovmin="70" fovmax="140" limitview="auto" />
		<preview url="panos/2.tiles/preview.jpg" />
		<image type="CUBE" multires="true" tilesize="512">			<level tiledimagewidth="2624" tiledimageheight="2624">				<cube url="panos/2.tiles/%s/l3/%v/l3_%s_%v_%h.jpg" />			</level>			<level tiledimagewidth="1280" tiledimageheight="1280">				<cube url="panos/2.tiles/%s/l2/%v/l2_%s_%v_%h.jpg" />			</level>			<level tiledimagewidth="640" tiledimageheight="640">				<cube url="panos/2.tiles/%s/l1/%v/l1_%s_%v_%h.jpg" />			</level>		</image>		<hotspot name="scene_1" style="hs_circle" ath="6.539" atv="-7.554" tag="Cổng" />		<hotspot name="scene_3" style="hs_circle" ath="-172.139" atv="-10.359" tag="2" />
	</scene>
	<scene name="scene_3" title="2" onstart="" thumburl="panos/3.tiles/thumb.jpg" lat="" lng="" heading="">
		<view hlookat="169.390" vlookat="-16.326" fovtype="MFOV" fov="120.000" maxpixelzoom="2.0" fovmin="70" fovmax="140" limitview="auto" />
		<preview url="panos/3.tiles/preview.jpg" />
		<image type="CUBE" multires="true" tilesize="512">			<level tiledimagewidth="2560" tiledimageheight="2560">				<cube url="panos/3.tiles/%s/l3/%v/l3_%s_%v_%h.jpg" />			</level>			<level tiledimagewidth="1280" tiledimageheight="1280">				<cube url="panos/3.tiles/%s/l2/%v/l2_%s_%v_%h.jpg" />			</level>			<level tiledimagewidth="640" tiledimageheight="640">				<cube url="panos/3.tiles/%s/l1/%v/l1_%s_%v_%h.jpg" />			</level>		</image>		<hotspot name="scene_2" style="hs_circle" ath="-2.235" atv="-3.448" tag="Quảng trường 1" />		<hotspot name="scene_SAN_KHAU" style="hs_circle" ath="170.731" atv="-10.698" tag="Sân khấu" />
	</scene>
*thumbup* Woody *thumbup* KEEP MOVING FORWARD *thumbup*

2

Samstag, 11. März 2023, 19:21

Quellcode

1
2
3
4
5
6
7
8
9
10
11
	<scene name="scene_1" title="0" onstart="remove()"  thumburl="panos/1.tiles/thumb.jpg" lat="" lng="" heading="">
		<plugin name="threejs" url="gltfloader.js" />
		<view hlookat="1.245" vlookat="-14.021" fovtype="MFOV" fov="140.000" maxpixelzoom="2.0" fovmin="70" fovmax="140" limitview="auto" />
		<preview url="panos/1.tiles/preview.jpg" />
		<image type="CUBE" multires="true" tilesize="512">			<level tiledimagewidth="2624" tiledimageheight="2624">				<cube url="panos/1.tiles/%s/l3/%v/l3_%s_%v_%h.jpg" />			</level>			<level tiledimagewidth="1280" tiledimageheight="1280">				<cube url="panos/1.tiles/%s/l2/%v/l2_%s_%v_%h.jpg" />			</level>			<level tiledimagewidth="640" tiledimageheight="640">				<cube url="panos/1.tiles/%s/l1/%v/l1_%s_%v_%h.jpg" />			</level>		</image>		<hotspot name="scene_2" style="hs_circle" ath="-1.231" atv="-2.748" tag="1" />
	</scene>
	<scene name="scene_2" title="1" onstart="" thumburl="panos/2.tiles/thumb.jpg" lat="" lng="" heading="">
		<view hlookat="6.420" vlookat="-11.392" fovtype="MFOV" fov="120.000" maxpixelzoom="2.0" fovmin="70" fovmax="140" limitview="auto" />
		<preview url="panos/2.tiles/preview.jpg" />
		<image type="CUBE" multires="true" tilesize="512">			<level tiledimagewidth="2624" tiledimageheight="2624">				<cube url="panos/2.tiles/%s/l3/%v/l3_%s_%v_%h.jpg" />			</level>			<level tiledimagewidth="1280" tiledimageheight="1280">				<cube url="panos/2.tiles/%s/l2/%v/l2_%s_%v_%h.jpg" />			</level>			<level tiledimagewidth="640" tiledimageheight="640">				<cube url="panos/2.tiles/%s/l1/%v/l1_%s_%v_%h.jpg" />			</level>		</image>		<hotspot name="scene_1" style="hs_circle" ath="6.539" atv="-7.554" tag="Cổng" />		<hotspot name="scene_3" style="hs_circle" ath="-172.139" atv="-10.359" tag="2" />
	</scene>


put your plugin into the scene and remove keep="true"

3

Sonntag, 12. März 2023, 04:23

Quellcode

1

				


put your plugin into the scene and remove keep="true"

It's still show Model 3D in all scene when i change scene :(
*thumbup* Woody *thumbup* KEEP MOVING FORWARD *thumbup*

4

Sonntag, 12. März 2023, 07:19

then your plugin is not working correctly.
its unloadplugin() function should remove threejs and everything it installed (events etc)

5

Sonntag, 12. März 2023, 13:04

then your plugin is not working correctly.
its unloadplugin() function should remove threejs and everything it installed (events etc)

then your plugin is not working correctly.
its unloadplugin() function should remove threejs and everything it installed (events etc)

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
function krpanoplugin()
{
	let local  = this;
	let krpano = null;
	let device = null;
	let plugin = null;


	local.registerplugin = function(krpanointerface, pluginpath, pluginobject)
	{
		krpano = krpanointerface;
		device = krpano.device;
		plugin = pluginobject;

		if (krpano.version < "1.19")
		{
			krpano.trace(3,"ThreeJS plugin - too old krpano version (min. 1.19)");
			return;
		}

		if (!device.webgl)
		{
			// show warning
			krpano.trace(2,"ThreeJS plugin - WebGL required");
			return;
		}

		krpano.debugmode = true;
		krpano.trace(0, "ThreeJS krpano plugin");

		// load the requiered three.js scripts
		load_scripts(["three.min.js","gltf.js"], start);
	}


	function resolve_url_path(url)
	{
		if (url.charAt(0) != "/" && url.indexOf("://") < 0)
		{
			// adjust relative url path
			url = krpano.parsepath("%CURRENTXML%/" + url);
		}

		return url;
	}


	function load_scripts(urls, callback)
	{
		if (urls.length > 0)
		{
			let url = resolve_url_path( urls.splice(0,1)[0] );

			let script = document.createElement("script");
			script.src = url;
			script.addEventListener("load", function(){ load_scripts(urls,callback); });
			script.addEventListener("error", function(){ krpano.trace(3,"loading file '"+url+"' failed!"); });
			document.getElementsByTagName("head")[0].appendChild(script);
		}
		else
		{
			// done
			callback();
		}
	}


	// helper
	const M_RAD = Math.PI / 180.0;


	// ThreeJS/krpano objects
	let renderer = null;
	let scene = null;
	let camera = null;
	let stereocamera = null;
	let camera_hittest_raycaster = null;
	let krpano_panoview = null;
	let krpano_panoview_euler = null;
	let krpano_projection = new Float32Array(16);		// krpano projection matrix
	let krpano_depthbuffer_scale = 1.0001;				// depthbuffer scaling (use ThreeJS defaults: znear=0.1, zfar=2000)
	let krpano_depthbuffer_offset = -0.2;


	function start()
	{
		// create the ThreeJS WebGL renderer, but use the WebGL context from krpano
		renderer = new THREE.WebGLRenderer({canvas:krpano.webGL.canvas, context:krpano.webGL.context});
		renderer.autoClear = false;
		renderer.setPixelRatio(1);	// krpano handles the pixel ratio scaling

		// restore the krpano WebGL settings (for correct krpano rendering)
		restore_krpano_WebGL_state();

		// use the krpano onviewchanged event as render-frame callback (this event will be directly called after the krpano pano rendering)
		krpano.set("events[__threejs__].keep", true);
		krpano.set("events[__threejs__].onviewchange", adjust_krpano_rendering);	// correct krpano view settings before the rendering
		krpano.set("events[__threejs__].onviewchanged", render_frame);

		// enable continuous rendering (that means render every frame, not just when the view has changed)
		krpano.view.continuousupdates = true;

		// register mouse and touch events
	

		// basic ThreeJS objects
		scene = new THREE.Scene();
		camera = new THREE.Camera();
		stereocamera = new THREE.Camera();
		camera_hittest_raycaster = new THREE.Raycaster();
		krpano_panoview_euler = new THREE.Euler();

		// build the ThreeJS scene (start adding custom code there)
		build_scene();
		
		// restore the krpano WebGL settings (for correct krpano rendering)
		restore_krpano_WebGL_state();
	}

	
	function restore_krpano_WebGL_state()
	{
		let gl = krpano.webGL.context;

		gl.disable(gl.DEPTH_TEST);
		gl.cullFace(gl.FRONT);
		gl.frontFace(gl.CCW);
		gl.enable(gl.BLEND);
		gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
		gl.activeTexture(gl.TEXTURE0);
		gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
		gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
		gl.pixelStorei(gl.UNPACK_ALIGNMENT, 4);
		
		// restore the current krpano WebGL program
		krpano.webGL.restoreProgram();
		
	}


	function restore_ThreeJS_WebGL_state()
	{
		let gl = krpano.webGL.context;

		gl.enable(gl.DEPTH_TEST);
		gl.depthFunc(gl.LEQUAL);
		gl.enable(gl.CULL_FACE);
		gl.cullFace(gl.BACK);
		gl.clearDepth(1);
		gl.clear(gl.DEPTH_BUFFER_BIT);
		renderer.state.reset();
		
	}


	function krpano_projection_matrix(sw,sh, zoom, xoff,yoff)
	{
		let m = krpano_projection;

		let pr = device.pixelratio;
		sw = pr / (sw*0.5);
		sh = pr / (sh*0.5);

		m[0]  = zoom*sw;    m[1]  = 0;          m[2]  = 0;                          m[3]  = 0;
		m[4]  = 0;          m[5]  = -zoom*sh;   m[6]  = 0;                          m[7]  = 0;
		m[8]  = xoff;       m[9]  = -yoff*sh;   m[10] = krpano_depthbuffer_scale;   m[11] = 1;
		m[12] = 0;          m[13] = 0;          m[14] = krpano_depthbuffer_offset;  m[15] = 1;
	}


	function update_camera_matrix(camera)
	{
		let m = krpano_projection;
		camera.projectionMatrix.set(m[0],m[4],m[8],m[12], m[1],m[5],m[9],m[13], m[2],m[6],m[10],m[14], m[3],m[7],m[11],m[15]);
	}


	function adjust_krpano_rendering()
	{
		if (krpano.view.fisheye != 0.0)
		{
			// disable the fisheye distortion, ThreeJS objects can't be rendered with it
			krpano.view.fisheye = 0.0;
		}
	}


	function render_frame()
	{
		let gl = krpano.webGL.context;
		let vr = krpano.webVR && krpano.webVR.enabled ? krpano.webVR : null;

		let sw = gl.drawingBufferWidth;
		let sh = gl.drawingBufferHeight;


		// setup WebGL for ThreeJS
		restore_ThreeJS_WebGL_state();

		// set the camera/view rotation
		krpano_panoview = krpano.view.getState(krpano_panoview);	// the 'krpano_panoview' object will be created and cached inside getState()
		krpano_panoview_euler.set(-krpano_panoview.v * M_RAD, (krpano_panoview.h-90) * M_RAD, krpano_panoview.r * M_RAD, "YXZ");
		camera.quaternion.setFromEuler(krpano_panoview_euler);
		camera.updateMatrixWorld(true);

		// set the camera/view projection
		krpano_projection_matrix(sw,sh, krpano_panoview.z, 0, krpano_panoview.yf);
		update_camera_matrix(camera);


		// render the scene
		if (krpano.display.stereo == false)
		{
			// normal rendering
			renderer.setViewport(10,10, sw,sh);
			renderer.render(scene, camera);
		}
		else
		{
			// stereo / VR rendering
			sw *= 0.5;	// use half screen width

			let stereo_scale = 0.05;
			let stereo_offset = Number(krpano.display.stereooverlap);

			// use a different camera for stereo rendering to keep the normal one for hit-testing
			stereocamera.quaternion.copy(camera.quaternion);
			stereocamera.updateMatrixWorld(true);

			// render left eye
			let eye_offset = -0.03;
			krpano_projection_matrix(sw,sh, krpano_panoview.z, stereo_offset, krpano_panoview.yf);

			if (vr)
			{
				eye_offset = vr.eyetranslt(1);						// get the eye offset (from the WebVR API)
				vr.prjmatrix(1, krpano_projection);					// replace the projection matrix (with the one from WebVR)
				krpano_projection[10] = krpano_depthbuffer_scale;	// adjust the depthbuffer scaling
				krpano_projection[14] = krpano_depthbuffer_offset;
			}

			// add the eye offset
			krpano_projection[12] = krpano_projection[0] * -eye_offset * stereo_scale;

			update_camera_matrix(stereocamera);
			renderer.setViewport(0,0, sw,sh);
			renderer.render(scene, stereocamera);

			// render right eye
			eye_offset = +0.03;
			krpano_projection[8] = -stereo_offset;	// mod the projection matrix (only change the stereo offset)

			if (vr)
			{
				eye_offset = vr.eyetranslt(2);						// get the eye offset (from the WebVR API)
				vr.prjmatrix(2, krpano_projection);					// replace the projection matrix (with the one from WebVR)
				krpano_projection[10] = krpano_depthbuffer_scale;	// adjust the depthbuffer scaling
				krpano_projection[14] = krpano_depthbuffer_offset;
			}

			// add the eye offset
			krpano_projection[12] = krpano_projection[0] * -eye_offset * stereo_scale;

			update_camera_matrix(stereocamera);
			renderer.setViewport(sw,0, sw,sh);
			renderer.render(scene, stereocamera);
		}

		// important - restore the krpano WebGL state for correct krpano rendering
		restore_krpano_WebGL_state();
	}



	// -----------------------------------------------------------------------
	// ThreeJS User Content - START HERE
	// add a krpano hotspot like handling for the 3d objects
	function assign_object_properties(obj, name, properties)
	{
		// set defaults (krpano hotspot like properties)
		if (properties          === undefined)	properties         = {};
		if (properties.name     === undefined)	properties.name    = name;
		if (properties.ath      === undefined)	properties.ath     = 0;
		if (properties.atv      === undefined)	properties.atv     = 0;
		if (properties.depth    === undefined)	properties.depth   = 1000;
		if (properties.scale    === undefined)	properties.scale   = 1;
		if (properties.rx       === undefined)	properties.rx      = 0;
		if (properties.ry       === undefined)	properties.ry      = 0;
		if (properties.rz       === undefined)	properties.rz      = 0;
		if (properties.rorder   === undefined)	properties.rorder  = "YXZ";
		if (properties.enabled  === undefined)	properties.enabled = true;
		if (properties.capture  === undefined)	properties.capture = true;
		if (properties.onover   === undefined)	properties.onover  = null;
		if (properties.onout    === undefined)	properties.onout   = null;
		if (properties.ondown   === undefined)	properties.ondown  = null;
		if (properties.onup     === undefined)	properties.onup    = null;
		if (properties.onclick  === undefined)	properties.onclick = null;
		properties.pressed  = false;
		properties.hovering = false;
		obj.properties = properties;
		obj.frustumCulled = false;
		update_object_properties(obj);
	}


	function update_object_properties(obj)
	{
		let p = obj.properties;

		let px = p.depth * Math.cos(p.atv * M_RAD)*Math.cos((180-p.ath) * M_RAD);
		let py = p.depth * Math.sin(p.atv * M_RAD);
		let pz = p.depth * Math.cos(p.atv * M_RAD)*Math.sin((180-p.ath) * M_RAD);
		obj.position.set(px,py,pz);

		obj.rotation.set(p.rx*M_RAD, p.ry*M_RAD, p.rz*M_RAD, p.rorder);

		obj.scale.set(p.scale, p.scale, p.scale);

		obj.updateMatrix();
	}


	
	function load_object_glb(url,properties,donecall)
	{
		url = resolve_url_path(url);
		let loader = new THREE.GLTFLoader();
		loader.load(url, (gltf) => {
			const sceneload = gltf.scene
            assign_object_properties(sceneload,url,properties)
			scene.add(sceneload);
			if (donecall)
			{
				donecall(sceneload);
			}
		  })
	}
	let mesh = null
	function build_scene()
	{
		// create a mesh 
		mesh = new THREE.Mesh(new THREE.BoxGeometry(), new THREE.MeshBasicMaterial({map:THREE.ImageUtils.loadTexture(resolve_url_path("box.jpg"))}));
		assign_object_properties(mesh, "meshbox", {ath:160, atv:-3,scale: 0.001, depth:200000});
		scene.add( mesh );

		// load 3d objects
		load_object_glb("sp3.glb",{ath:+130,  atv:+15, depth:8,  scale:1, rx:180, ry:40  ,rz:0})
		load_object_glb("sp8.glb",{ath:+30,  atv:+15, depth:8,  scale:1, rx:180, ry:110  ,rz:0})
		load_object_glb("sp8.glb",{ath:-110,  atv:+15, depth:80,  scale:1, rx:180, ry:110  ,rz:0})
		load_object_glb("sp8.glb",{ath:-10,  atv:+15, depth:80,  scale:1, rx:180, ry:110  ,rz:0})
		load_object_glb("sp8.glb",{ath:-40,  atv:-20, depth:80,  scale:1, rx:180, ry:110  ,rz:0})
		load_object_glb("sp8.glb",{ath:-40,  atv:-40, depth:80,  scale:1, rx:180, ry:110  ,rz:0})
		scene.add( new THREE.AmbientLight(0xFFFFFF) );

		let directionalLight = new THREE.DirectionalLight(0xFFFFFF);
		directionalLight.position.x = 5;
		directionalLight.position.y = -1;
		directionalLight.position.z = 0;
		directionalLight.position.normalize();
		scene.add( directionalLight );
	}


	


	


}

This is my threejs plugin, i dont know what's wrong :( *confused*
*thumbup* Woody *thumbup* KEEP MOVING FORWARD *thumbup*

6

Sonntag, 12. März 2023, 14:07

you can have a look at the default plugin example here:
https://krpano.com/docu/plugininterface/#top

Quellcode

1
2
3
4
5
6
7
8
9
    // unloadplugin - exit point for the plugin (optionally)
    // - will be called from krpano when the plugin will be removed
    // - everything that was added by the plugin should be removed here
    local.unloadplugin = function()
    {
        /* REMOVE YOUR THREEJS STUFF HERE */
        plugin = null;
        krpano = null;
    }

your plugin has no unloadplugin() function at all

7

Sonntag, 12. März 2023, 14:53

you can have a look at the default plugin example here:
https://krpano.com/docu/plugininterface/#top

Quellcode

1
2
3
4
5
6
7
8
9
    // unloadplugin - exit point for the plugin (optionally)
    // - will be called from krpano when the plugin will be removed
    // - everything that was added by the plugin should be removed here
    local.unloadplugin = function()
    {
        /* REMOVE YOUR THREEJS STUFF HERE */
        plugin = null;
        krpano = null;
    }

your plugin has no unloadplugin() function at all

Quellcode

1
2
3
4
5
6
7
8
9
10
11
VM214:190 Uncaught TypeError: Cannot read properties of null (reading 'view')
    at adjust_krpano_rendering (eval at G.c.loading (eval at embedpano (tour.js:10:76)), <anonymous>:190:14)
    at k.callaction (eval at embedpano (tour.js:10:76), <anonymous>:1:76620)
    at od (eval at embedpano (tour.js:10:76), <anonymous>:1:7126)
    at Ba (eval at embedpano (tour.js:10:76), <anonymous>:1:4076)
    at e (eval at embedpano (tour.js:10:76), <anonymous>:1:129251)
    at p (eval at embedpano (tour.js:10:76), <anonymous>:1:136521)
    at r (eval at embedpano (tour.js:10:76), <anonymous>:1:134498)
    at v (eval at embedpano (tour.js:10:76), <anonymous>:1:133402)
    at eval (eval at embedpano (tour.js:10:76), <anonymous>:1:129819)
    at eval (eval at embedpano (tour.js:10:76), <anonymous>:1:65467)
i tried add that code but have this problem
*thumbup* Woody *thumbup* KEEP MOVING FORWARD *thumbup*

8

Sonntag, 12. März 2023, 17:18

problem solved, i try add

Quellcode

1
if(krpano !== null) { }
inside function containing "krpano" and remove keep ="true" then it worked *g*
*thumbup* Woody *thumbup* KEEP MOVING FORWARD *thumbup*

9

Montag, 13. März 2023, 04:00

if(krpano !== null) { }

put this code in that place *confused*

10

Montag, 13. März 2023, 08:44

if(krpano !== null) { }

put this code in that place *confused*

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
	function restore_ThreeJS_WebGL_state()
	{
		if(krpano !== null) {
		let gl = krpano.webGL.context;

		gl.enable(gl.DEPTH_TEST);
		gl.depthFunc(gl.LEQUAL);
		gl.enable(gl.CULL_FACE);
		gl.cullFace(gl.BACK);
		gl.clearDepth(1);
		gl.clear(gl.DEPTH_BUFFER_BIT);
		renderer.state.reset();
		}
	}
for example. put if(krpano !== null) in function has "krapno" *thumbup*
*thumbup* Woody *thumbup* KEEP MOVING FORWARD *thumbup*

11

Montag, 13. März 2023, 11:23

OK
*love* *love* *love*

12

Montag, 13. März 2023, 14:41

just FYI, this is not a very safe method.
in unloadplugin you should UNLOAD everything.
that means destroy any threejs content, free resources, disable active events and renderloops, etc

13

Dienstag, 14. März 2023, 03:26

just FYI, this is not a very safe method.
in unloadplugin you should UNLOAD everything.
that means destroy any threejs content, free resources, disable active events and renderloops, etc
*thumbup* *thumbup* thank you very much
*thumbup* Woody *thumbup* KEEP MOVING FORWARD *thumbup*

14

Dienstag, 14. März 2023, 04:12

Can you share your case to see what kind of results it is?

15

Dienstag, 14. März 2023, 09:50

maybe to add...

if your plugin is in a scene it gets (re-)initialized every time you enter the scene
and with keep=false removed using unloadplugin() when you leave.
a proper initialization and unloading is very important.

if you for example would do not remove an installed renderloop,
you would get a 2nd one when you enter the scene again.
such things can hog down the performance and your devices memory etc.

by the way
plugin[..].visible does not work in this case, because the plugin doesn't handle it.
visible is a krpano attribute, it would need special code to your hide threejs stuff

in general combining threejs with krpano is complicated and not ideal for performance
it is maybe better to wait for 3d object support in krpano itself

ps. yes it would be nice to see your online example *smile*

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »indexofrefraction« (14. März 2023, 10:07)


16

Mittwoch, 15. März 2023, 03:16

I'm just doing it on localhost at the moment :( *cry*
*thumbup* Woody *thumbup* KEEP MOVING FORWARD *thumbup*

cuongdevjs

Anfänger

Beiträge: 13

Wohnort: Viet Nam

Beruf: JavaScript Engineer

  • Nachricht senden

17

Freitag, 31. März 2023, 06:35

Hi yenph. I tried with your code, but the event "ondown" doesn't fire in glb model. Can you give me some instructions?