• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript engine.Engine类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中@babylonjs/core/Engines/engine.Engine的典型用法代码示例。如果您正苦于以下问题:TypeScript Engine类的具体用法?TypeScript Engine怎么用?TypeScript Engine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Engine类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例2: Engine

import { Engine } from "@babylonjs/core/Engines/engine";
import { Scene } from "@babylonjs/core/scene";
import { Vector3 } from "@babylonjs/core/Maths/math";
import { FreeCamera } from "@babylonjs/core/Cameras/freeCamera";
import { HemisphericLight } from "@babylonjs/core/Lights/hemisphericLight";
import { Mesh } from "@babylonjs/core/Meshes/mesh";

import { GridMaterial } from "@babylonjs/materials/grid/gridMaterial";

import "@babylonjs/core/Meshes/Builders/boxBuilder";
import "@babylonjs/core/Meshes/Builders/sphereBuilder";

const canvas = document.getElementById("renderCanvas") as HTMLCanvasElement;
const engine = new Engine(canvas);
var scene = new Scene(engine);

// This creates and positions a free camera (non-mesh)
var camera = new FreeCamera("camera1", new Vector3(0, 5, -10), scene);

// This targets the camera to scene origin
camera.setTarget(Vector3.Zero());

// This attaches the camera to the canvas
camera.attachControl(canvas, true);

// This creates a light, aiming 0,1,0 - to the sky (non-mesh)
var light = new HemisphericLight("light1", new Vector3(0, 1, 0), scene);

// Default intensity is 1. Let's dim the light a small amount
light.intensity = 0.7;
开发者ID:BabylonJS,项目名称:Babylon.js,代码行数:30,代码来源:minGridMaterial.ts



注:本文中的@babylonjs/core/Engines/engine.Engine类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript scene.Scene类代码示例发布时间:2022-05-28
下一篇:
TypeScript types.variableDeclarator函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap