小编KBh*_*ray的帖子

无法在react-三/drei/native中使用远程url加载纹理

我正在尝试使用加载图像纹理useTexture并将其应用到meshStandardMaterial我的反应本机应用程序中。当我从本地资源文件夹导入图像时,纹理工作正常。但是,当我将图像更改为远程 URL 时,纹理不会被应用,材质会呈现黑色。我添加了下面的代码

import React, { Suspense, useRef } from 'react';
import { View } from 'react-native';
import { Canvas } from '@react-three/fiber/native';
import { useTexture } from '@react-three/drei/native';
import useWindowDimensions from 'react-native/Libraries/Utilities/useWindowDimensions';
import localTexturePath from './assets/duck_texture.png'

function Plane() {
  const ref = useRef();
  // THIS DOESN'T WORK
  const textureUrl = 'https://cdntest.metatube.studio/public/Texture.png'
  // THIS WORKS
  // const textureUrl = localTexturePath
  useTexture(textureUrl, (t) => {
    ref.current.map = t
    ref.current.needsUpdate = true
  })
  return(
    <mesh>
      <planeBufferGeometry attach="geometry" args={[3, …
Run Code Online (Sandbox Code Playgroud)

three.js react-native react-three-fiber drei react-three-drei

5
推荐指数
0
解决办法
353
查看次数

Hyperledger Sawtooth - 提交交易时的预检错误

我正在尝试使用javascript向Hyperledger Sawtooth v1.0.1提交一个事务到在localhost上运行的验证器.邮寄请求的代码如下:

request.post({
        url: constants.API_URL + '/batches',
        body: batchListBytes,
        headers: { 'Content-Type': 'application/octet-stream' }
    }, (err, response) => {
        if (err) {
            console.log(err);
            return cb(err)
        }
        console.log(response.body);
        return cb(null, response.body);
    });
Run Code Online (Sandbox Code Playgroud)

从后端nodejs应用程序提交时会处理事务,但从OPTIONS http://localhost:8080/batches 405 (Method Not Allowed)客户端提交时会返回错误.这些是我尝试过的选项:

  1. Access-Control-Allow-*使用扩展名将标头插入响应中:响应仍然会产生相同的错误
  2. 删除自定义标头以绕过预检请求:这会使验证程序抛出错误,如下所示:

    ...
    sawtooth-rest-api-default | KeyError: "Key not found: 'Content-Type'"
    sawtooth-rest-api-default | [2018-03-15 08:07:37.670 ERROR    web_protocol] Error handling request
    sawtooth-rest-api-default | Traceback (most recent call last):
    ...
    
    Run Code Online (Sandbox Code Playgroud)

POST来自浏览器的未修改请求从验证器获取以下响应头:

HTTP/1.1 405 Method Not Allowed
Content-Type: text/plain; charset=utf-8
Allow: GET,HEAD,POST …
Run Code Online (Sandbox Code Playgroud)

hyperledger hyperledger-sawtooth

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