小编Don*_*rdy的帖子

Archilogic gltf模型无法加载到框架中

我在故障上编写了一个演示场景来测试我在a-frame中输出的gltf模型,但是我在控制台中遇到错误:

我的代码

<!DOCTYPE html>
<html>
  <head>
    <title>Basic Scene - A-Frame</title>
    <meta name="description" content="Basic Scene - A-Frame">
    <script src="https://aframe.io/releases/0.6.0/aframe.min.js"></script>
  </head>
  <body>
    <a-scene>
      <a-assets>
        <a-asset-item id="gltfDemo" src="https://cdn.glitch.com/a3c2afff-dcc6-4918-bb73-5716b35f39b0%2Fexport.gltf?1499844855169"></a-asset-item>
        <a-asset-item id="buffer_0.bin" src="https://cdn.glitch.com/a3c2afff-dcc6-4918-bb73-5716b35f39b0%2Fbuffer_0.bin?1499844851189"></a-asset-item>
        <a-asset-item id="buffer_1.bin" src="https://cdn.glitch.com/a3c2afff-dcc6-4918-bb73-5716b35f39b0%2Fbuffer_1.bin?1499844853034"></a-asset-item>
      </a-assets>
      
      <a-entity gltf-model="#gltfDemo"></a-entity>
      
      <a-sky color="#000"></a-sky>
      <a-light type="ambient" color="#445451"></a-light>
      <a-plane color="#050" rotation="-90 0 0" height="100" width="100"></a-plane>  
      <a-camera>
        <a-cursor color="#FAFAFA"></a-cursor>
      </a-camera>
    </a-scene>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

错误:

VM1762:1 Uncaught SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at e.parse (GLTFLoader.js:68)
at GLTFLoader.js:32
at three.js:29160
Run Code Online (Sandbox Code Playgroud)

源文件: Glitch Fiddle包含源文件

我有一种感觉,我错误地将gltf导入故障或以错误的方式使用它.有谁能够帮我?

aframe gltf archilogic

6
推荐指数
1
解决办法
748
查看次数

将抗锯齿圆圈与 regl 混合

我正在使用 regl 渲染圆圈,并且有三个目标:

  1. 画布应该是透明的,在其后面显示 HTML 内容。
  2. 圆应该平滑地抗锯齿。
  3. 重叠的圆圈应该看起来合理(混合颜色,没有角落显示)

到目前为止,我有这个:故障代码演示

更新:演示链接现在反映了有效的、已接受的答案。下面的代码不变。

索引.js

const regl = require('regl');
const glsl = require('glslify');
const vertexShader = glsl.file('../shaders/vertex.glsl');
const fragmentShader = glsl.file('../shaders/fragment.glsl');

// Create webgl context and clear.
const canvasEl = document.querySelector('canvas');
const app = regl({
  canvas: canvasEl,
  extensions: ['OES_standard_derivatives']
});
app.clear({color: [0, 0, 0, 0], depth: 1});

// Generate random points and colors.
const attributes = {position: [], color: []};
for (let i = 0; i < 100; i++) { …
Run Code Online (Sandbox Code Playgroud)

shader blending alphablending glsl regl

5
推荐指数
2
解决办法
1049
查看次数

定义基于递归泛型接口的 TypeScript 类

我正在为一个项目设置一个基础数据结构,希望有一个抽象的基础GraphNode对象,许多其他对象将从中继承。每个 GraphNode 子类都具有元数据,其中可能包括文字(字符串、数字等)和对其他 GraphNode 派生类型的引用。

\n

子类示例:

\n
interface IPerson {\n  name: string;\n  age: number;\n  friend: Person;\n  pet: Pet;\n}\n\ninterface IPet {\n  type: \'dog\' | \'cat\';\n  name: string;\n}\n\nclass Person extends GraphNode<IPerson> {}\nclass Pet extends GraphNode<IPet> {}\n
Run Code Online (Sandbox Code Playgroud)\n

用法示例:

\n
const spot = new Pet()\n  .set(\'type\', \'dog\')\n  .set(\'name\', \'Spot\');\n\nconst jo = new Person()\n  .set(\'name\', \'Jo\')\n  .set(\'age\', 41)\n  .set(\'pet\', spot) // \xe2\x9a\xa0\xef\xb8\x8f Should not accept GraphNode argument.\n  .setRef(\'pet\', spot); // \xe2\x9c\x85 Correct.\n\nconst sam = new Person()\n  .set(\'name\', \'Sam\')\n  .set(\'age\', 45)\n  .set(\'friend\', …
Run Code Online (Sandbox Code Playgroud)

generics typescript typescript-generics

5
推荐指数
1
解决办法
1263
查看次数

为A-Frame的WASD控件添加速度

如何为WebVR页面提高WASD控件的速度?因为现在它变得非常慢.

<a-entity position="0 1.8 0" camera look-controls wasd-controls>
  <a-camera id="camera">
    <a-cursor color="#333" maxDistance="30"></a-cursor>
  </a-camera>
</a-entity>
Run Code Online (Sandbox Code Playgroud)

webvr aframe

4
推荐指数
1
解决办法
1680
查看次数

“引发RangeError:无效类型数组长度”为看似-有效输入

我有以下片段:

new Uint16Array( arraybuffer, 0, 18108 );
Run Code Online (Sandbox Code Playgroud)

我知道,arraybuffer是的一个实例ArrayBuffer,那arraybuffer.byteLength是31984.该arraybuffer的内容是一个黑盒子给我。因为缓冲区的byteLength> 18108,所以我希望它能正常工作。相反,我得到以下错误:

铬:

RangeError:无效的类型化数组长度

Firefox:

TypeError:无效的参数

是什么原因导致失败,或者如何检查无法打开的ArrayBuffer?

javascript typed-arrays arraybuffer

3
推荐指数
1
解决办法
2742
查看次数

如何在 Deno 中递归读取目录?

我正在尝试使用 Deno 递归读取文件Deno.readDir,但他们提供的示例仅执行给定的文件夹:

for await (const entry of Deno.readDir(Deno.cwd())) {
  console.log(entry.name);
}
Run Code Online (Sandbox Code Playgroud)

我怎样才能使这个递归?

file-io deno

3
推荐指数
1
解决办法
837
查看次数