Recent Posts

How to embed HTML into a web page without using “iframe

While coding my personal website, I ran into a problem: I want to create a modal window with an “iframe” tag, but Google Translate does not support text in the iframe. So I tried to embed another HTML file in index.html with JavaScript or PHP.

GOAL

The goal today is to embed sub.html in index.html without using iframe tags so that Google Translate will work for the embedded text.

Below is how to embed the code in an iframe tag.

<iframe src="sub.html"></iframe>

Environment

PHP8.3.8
Latest Google Chrome (Version 127.0.6533.90)

Method

Method1: Using php include function

<?php include 'sub.html'; ?>
//<?php include('sub.html'); ?> also works

Change index.html into index.php to use PHP function in index file.
Or you can use html as PHP by using “AddType” in .htaccess. Reference: Parse HTML as PHP using HTACCESS File

Method2: JQuery .load() in JavaScript

<div id="frame-content"></div>

<!-- need to read jQuery -->
<script src="jquery.min.js"></script>

<script>
    $("#frame-content").load('sub.html');
</script>

Trouble Shooting

Opening index.html in a local environment causes a CROS policy error as below. For correct results, we must use a web server or a local HTTP server.

Access to XMLHttpRequest at 'file:///C:/.../sub.html' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, isolated-app, chrome-extension, chrome, https, chrome-untrusted.

Reference: How do you set up a local testing server?

How to Bake Normal Map in Blender

GOAL

Today’s goal is to bake normal, i.e., generate a normal map from an uneven mesh in Blender.

In my case, I baked normal map from high-level model and apply it into the low-level model as below.

Environment

Blender2.83(LTS)
Windows 10

Method

First generate add image to bake normal. You can create an Image from Shader Editor or Image Editor. And select the added image on the Shader Editor.

Open “Bake” tab from Cycles Render Properties and click “Bake” button. You can choose either “Tangent” space or “Object” space you like.

Then save the baked image from Image Editor.

Result

Apply result image as a normal map. For example, we can connect nodes as below in the cycle renderer.

Shader Editor

The following is rendered result. It looks well.

A strange thickness of faces in Blender

This is trouble shooting in Blender. Actually it was a foolish mistake…

Problem

I found a strange thickness in my model in Blender. Though this is only one surface, it looks like a cube with thickness.

Cause and Solution

In my case, I’ve added “Solidify” modifier by mistake before.
So the solution was to check modifiers and remove unused one.

Categories

AfterEffects Algorithm Artificial Intelligence Blender C++ Computer Graphics Computer Science Daily Life DataAnalytics Event Game ImageProcessing JavaScript Kotlin mathematics Maya PHP Python SoftwareEngineering Tips Today's paper Tools TroubleShooting Unity Visual Sudio Web Windows WordPress 未分類