所以到目前为止,我一直在使用 three.js 和 webXR 一段时间,并希望将其集成到汇编脚本中。我知道如何让 webXR 在 typescript 中工作,但是当我尝试在汇编脚本中使用它时,它会在导入时出错。这是 index.ts 代码和错误:
索引.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": {
"@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"
}