當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Engine.setHardwareScalingLevel方法代碼示例

本文整理匯總了TypeScript中@babylonjs/core/Engines/engine.Engine.setHardwareScalingLevel方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Engine.setHardwareScalingLevel方法的具體用法?TypeScript Engine.setHardwareScalingLevel怎麽用?TypeScript Engine.setHardwareScalingLevel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@babylonjs/core/Engines/engine.Engine的用法示例。


在下文中一共展示了Engine.setHardwareScalingLevel方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

        var initScene = function() {
            // Creates the canvas
            var renderedCanvas = document.createElement("canvas");
            renderedCanvas.className = "vjs-tech";
            videoEl.parentElement.insertBefore(renderedCanvas, videoEl);
            videoEl.style.display = "none";

            // Creates the default babylonjs scene
            var engine = new Engine(renderedCanvas, true, {
                disableWebGL2Support: settings.disableWebGL2Support
            });

            // Workaround http://localhost:8080/indexCode.html
            engine.getCaps().vertexArrayObject = false;
            var scene = new Scene(engine);

            // Set the hardware scaling level
            const scaling = Math.max(settings.hardwareScalingLevel, 1 / (window.devicePixelRatio || 4));
            engine.setHardwareScalingLevel(scaling);

            // Helps reducing the needed number of draw calls
            scene.renderTargetsEnabled = false;
            scene.clearColor = new Color4(0, 0, 0, 1);
            scene.onPointerObservable.add(function() {
                player.userActive(true);
            });

            // No need of clear or depth buffer as it is a 360 video only
            scene.autoClear = false;
            scene.autoClearDepthAndStencil = false;
            engine.setDepthBuffer(false);
            
            // Creates the 360 video
            var dome = new VideoDome("testdome", videoEl, { autoPlay: false, size: 2000 }, scene);
            dome.rotation.x = -settings.defaultCameraOrientationX;
            dome.rotation.y = -settings.defaultCameraOrientationY;

            // Create the custom vr helper if requested
            var vrHelper = new VRExperienceHelper(scene, {
                useCustomVRButton: true,
                controllerMeshes: false
            });

            // Prevent pointer lock to let the menu accessible
            vrHelper.requestPointerLockOnFullScreen = false;

            // Records VR state
            vrHelper.onEnteringVRObservable.add(() => {
                isInVRMode = true;
            });
            vrHelper.onExitingVRObservable.add(() => {
                isInVRMode = false;
                player.controls(true);
            });

            // Adapt the camera to the requested settings.
            scene.activeCamera.fov = settings.fov;

            // Adapt the video type to the requested one.
            if (settings.videoType === "stereoscopicSideBySide") {
                dome.videoMode = VideoDome.MODE_SIDEBYSIDE;
            }
            else if (settings.videoType === "stereoscopicTopBottom") {
                dome.videoMode = VideoDome.MODE_TOPBOTTOM;
            }
            else {
                // Default to monoscopicPanoramic
                dome.videoMode = VideoDome.MODE_MONOSCOPIC;
            }

            // VR Switch function.
            toggleWebVR = function() {
                if (!isInVRMode) {
                    player.controls(false);
                    vrHelper.enterVR();
                } else {
                    vrHelper.exitVR();
                }
            }

            // Resize
            window.addEventListener("resize", function() {
                engine.resize();
            });

            // And finally starts the render loop
            engine.runRenderLoop(function() {
                scene.render();
            });
        };
開發者ID:BabylonJS,項目名稱:Extensions,代碼行數:90,代碼來源:amp-360video.ts


注:本文中的@babylonjs/core/Engines/engine.Engine.setHardwareScalingLevel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。