因此,到目前为止,我使用three.js和webXR已经有一段时间了,并且希望将它们集成到程序集脚本中。我知道如何让webXR在类型记录中工作,但是当我试图在程序集脚本中使用它时,它会在导入中出错。下面是index.ts代码和错误:
Index.ts:
// The entry file of your WebAssembly module.
import type { Navigator } from 'webxr';
export function add(a: i32, b: i32): i32 {
return a + b;
}错误:
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
{
"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:
"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"
}发布于 2022-02-17 08:10:33
Assemblyscript编译为Web程序集,此时Web程序集无法访问DOM。其思想是将Assemblyscript用于游戏逻辑,使用常规javascript / typescript与WebXR API交互。
https://stackoverflow.com/questions/68496114
复制相似问题