首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >汇编脚本与WebXR

汇编脚本与WebXR
EN

Stack Overflow用户
提问于 2021-07-23 08:15:55
回答 1查看 97关注 0票数 0

因此,到目前为止,我使用three.js和webXR已经有一段时间了,并且希望将它们集成到程序集脚本中。我知道如何让webXR在类型记录中工作,但是当我试图在程序集脚本中使用它时,它会在导入中出错。下面是index.ts代码和错误:

Index.ts:

代码语言:javascript
复制
// The entry file of your WebAssembly module.
import type { Navigator } from 'webxr';

export function add(a: i32, b: i32): i32 {
    return a + b;
}

错误:

代码语言:javascript
复制
ERROR TS1005: 'from' expected.

import type { Navigator } from 'webxr';
    ~~~~
in assembly/index.ts(2,8)

FAILURE 1 parse error(s)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! pad-ar@1.0.0 asbuild:untouched: `asc assembly/index.ts --target debug`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the pad-ar@1.0.0 asbuild:untouched script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\...\AppData\Roaming\npm-cache\_logs\2021-07-23T08_01_08_112Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! pad-ar@1.0.0 asbuild: `npm run asbuild:untouched && npm run asbuild:optimized`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the pad-ar@1.0.0 asbuild:untouched script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\...\AppData\Roaming\npm-cache\_logs\2021-07-23T08_05_44_373Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! pad-ar@1.0.0 asbuild: `npm run asbuild:untouched && npm run asbuild:optimized`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the pad-ar@1.0.0 asbuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

asconfig.json

代码语言:javascript
复制
{
   "targets": {
    "debug": {
     "binaryFile": "build/untouched.wasm",
     "textFile": "build/untouched.wat",
     "sourceMap": true,
     "debug": true
    },
    "release": {
      "binaryFile": "build/optimized.wasm",
      "textFile": "build/optimized.wat",
      "sourceMap": true,
      "optimizeLevel": 3,
      "shrinkLevel": 0,
      "converge": false,
      "noAssert": false
    }
  },
  "options": {}
}

Dependencies:

代码语言:javascript
复制
"dependencies": {
    "@assemblyscript/loader": "^0.19.7",
    "@types/webxr": "^0.2.3",
    "typescript": "^4.3.5",
    "webxr": "0.0.0",
    "webxr-polyfill": "^2.0.3"
},
"devDependencies": {
    "@as-pect/cli": "^6.2.4",
    "@types/node": "^16.4.1",
    "assemblyscript": "^0.19.7"
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-02-17 08:10:33

Assemblyscript编译为Web程序集,此时Web程序集无法访问DOM。其思想是将Assemblyscript用于游戏逻辑,使用常规javascript / typescript与WebXR API交互。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68496114

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档