【问题标题】:Cannot get rid of White outline in three js canvas无法摆脱三个js画布中的白色轮廓
【发布时间】:2023-03-16 17:12:01
【问题描述】:

我最近尝试从 codepen 修改脚本,但遇到了一些麻烦。我必须在一个 HTML 文件中插入所有代码,但是当我这样做时,我的画布周围会出现一个白色轮廓/边框。

这是我正在上传显示问题的代码的网站https://alsndr.altervista.org/midnightmadness/

风格是这样的

    overflow:hidden;
        width:100%;
        border:0!important;
  }
.vsc-initialized{
  border: none!important;
  padding:none!important;
}
  canvas {
    display: block;
    width:100%;
    height:100%;
    margin: 0;
    align: center;
    outline:none;
    overflow:hidden;
  }

  .world {
    position: absolute;
    margin:0;
    padding:0;
    border:0;
    background: #FF4066;
  } 

这是我声明画布大小的 js

this.renderer.setPixelRatio(window.devicePixelRatio);
    this.renderer.setSize(width, height);
    this.container = document.getElementsByClassName("world")[0];
    this.scene = new THREE.Scene();
    this.width = width;
    this.height = height;
    this.aspectRatio = width / height;

这里是调整大小的函数:

updateSize(w, h) {
    this.renderer.setSize(w, h);
    this.camera.aspect = w / h;
    this.camera.updateProjectionMatrix();
  }

function domIsReady() {
  world = new World(this.container, this.renderer, window.innerWidth, window.innerHeight);
  window.addEventListener('resize', handleWindowResize, false);
  document.addEventListener("mousemove", handleMouseMove, false);
  handleWindowResize();
  world.loop();
}



function handleWindowResize() {
  world.updateSize(window.innerWidth, window.innerHeight);
}

【问题讨论】:

    标签: javascript html css wordpress


    【解决方案1】:

    试试下面的 CSS。

    body{ margin: 0; }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-04-12
      • 1970-01-01
      • 2014-05-08
      • 2012-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多